Skip to content

Commit

Permalink
feat(ci): merge non-critical & long-running CI into one workflow (#4614)
Browse files Browse the repository at this point in the history
Description:
Match cargo build args with CI
Take advantage of GHA caching
Split out Ubuntu package dependencies into a bash script for reuse
Include binaries in report artifacts

Motivation and Context:
Reduce workflows and make easier to read and re-use

How Has This Been Tested?
Run in local fork - both non-critical & long-running
  • Loading branch information
leet4tari authored Sep 6, 2022
1 parent 3c75b9a commit a81228c
Show file tree
Hide file tree
Showing 9 changed files with 169 additions and 200 deletions.
147 changes: 147 additions & 0 deletions .github/workflows/integration_tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,147 @@
---
name: Integration tests

'on':
push:
paths-ignore:
- '**/*.md'
branches:
- 'ci-*'
schedule:
- cron: '0 2 * * *' # daily @ 02h00
- cron: '0 12 * * 6' # weekly - Saturday @ noon
workflow_dispatch:

env:
toolchain: nightly-2022-05-01
# space seperated string list
build_binaries: "tari_base_node tari_console_wallet tari_merge_mining_proxy tari_miner"

jobs:
long-running:
name: Cucumber tests
runs-on: ubuntu-latest
steps:
- name: Checkout source code
uses: actions/checkout@v3

- name: Envs setup for ${{ env.CI_RUN }}
id: envs_setup
shell: bash
run: |
VAPPS_STRING="${{ env.build_binaries }}"
VAPPS_ARRAY=(${VAPPS_STRING})
for i in "${!VAPPS_ARRAY[@]}"; do
if [ "${VAPPS_ARRAY[$i]:0:5}" = "tari_" ] ; then
VAPPS_TARGET_BINS="${VAPPS_TARGET_BINS} --bin ${VAPPS_ARRAY[$i]}"
fi
done
echo "TARGET_BINS=${VAPPS_TARGET_BINS}" >> $GITHUB_ENV
if [ "${{ github.event_name }}" == "schedule" ] ; then
if [ "${{ github.event.schedule }}" == "0 2 * * *" ] ; then
echo "CI_RUN=non-critical" >> $GITHUB_ENV
elif [ "${{ github.event.schedule }}" == "0 12 * * 6" ] ; then
echo "CI_RUN=long-running" >> $GITHUB_ENV
fi
else
echo "CI_RUN=non-critical" >> $GITHUB_ENV
fi
- name: Install ubuntu dependencies
shell: bash
run: |
sudo apt-get update
sudo bash scripts/install_ubuntu_dependencies.sh
- name: Setup rust toolchain
uses: actions-rs/toolchain@v1
with:
profile: minimal
components: rustfmt, clippy
toolchain: ${{ env.toolchain }}
override: true

- name: Cache cargo files and outputs
uses: Swatinem/rust-cache@v2

- name: Build binaries
uses: actions-rs/cargo@v1
with:
use-cross: false
command: build
args: >
--release
--locked
${{ env.TARGET_BINS }}
- name: Build ffi
uses: actions-rs/cargo@v1
with:
use-cross: false
command: build
args: >
--release
--locked
--package tari_wallet_ffi
- name: CI folder prep
shell: bash
working-directory: integration_tests
run: |
mkdir -p cucumber_output
mkdir -p temp/reports
mkdir -p temp/out
cd ../target/release/
cp -v ${{ env.build_binaries }} "$GITHUB_WORKSPACE/integration_tests/temp/out"
cd $GITHUB_WORKSPACE/integration_tests/temp/out
shasum -a 256 ${{ env.build_binaries }} > integration_tests.sha256sums
cat integration_tests.sha256sums
ls -alht
- name: Setup Node.js
uses: actions/setup-node@v3
with:
node-version: 18
cache: 'npm'
cache-dependency-path: integration_tests/package-lock.json

- name: Run npm ci and lint
shell: bash
working-directory: integration_tests
run: |
node -v
npm install
npm run check-fmt
npm run lint
npm ci
cd ../clients/base_node_grpc_client
npm install
cd ../wallet_grpc_client
npm install
npm ci
- name: Run ${{ env.CI_RUN }} integration tests
continue-on-error: true
shell: bash
working-directory: integration_tests
run: |
node_modules/.bin/cucumber-js --profile "${{ env.CI_RUN }}" \
--tags "not @wallet-ffi" --format json:cucumber_output/tests.cucumber \
--exit --retry 2 --retry-tag-filter "@flaky and not @broken"
- name: Generate report
continue-on-error: true
if: always()
shell: bash
working-directory: integration_tests
run: node ./generate_report.js

- name: Store ${{ env.CI_RUN }} test results
uses: actions/upload-artifact@v3
if: always()
with:
name: ${{ env.CI_RUN }} test results
path: |
integration_tests/cucumber_output
integration_tests/temp/reports
integration_tests/temp/out
95 changes: 0 additions & 95 deletions .github/workflows/long_running.yml

This file was deleted.

95 changes: 0 additions & 95 deletions .github/workflows/non_critical_integration_tests.yml

This file was deleted.

3 changes: 2 additions & 1 deletion integration_tests/helpers/baseNodeProcess.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ class BaseNodeProcess {
await this.runCommand("cargo", [
"build",
"--release",
"--locked",
"--bin",
"tari_base_node",
"-Z",
Expand Down Expand Up @@ -157,7 +158,7 @@ class BaseNodeProcess {
// Create convenience script - this is NOT used to start the base node in cucumber
fs.writeFileSync(
`${this.baseDir}/start_node.sh`,
"bash -c \"RUST_BACKTRACE=1 cargo run --release --bin tari_base_node -- -n --watch status -b . --network localnet $(grep -v '^#' .overrides)\"",
"bash -c \"RUST_BACKTRACE=1 cargo run --release --locked --bin tari_base_node -- -n --watch status -b . --network localnet $(grep -v '^#' .overrides)\"",
{ mode: 0o777 }
);

Expand Down
11 changes: 2 additions & 9 deletions integration_tests/helpers/ffi/ffiInterface.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ class InterfaceFFI {
const args = [
"build",
"--release",
"--locked",
"--package",
"tari_wallet_ffi",
"-Z",
Expand All @@ -49,13 +50,7 @@ class InterfaceFFI {
fs.mkdirSync(baseDir, { recursive: true });
fs.mkdirSync(baseDir + "/log", { recursive: true });
}
const ps = spawn(cmd, args, {
cwd: baseDir,
env: {
...process.env,
CARGO_TARGET_DIR: process.cwd() + "/temp/ffi-target",
},
});
const ps = spawn(cmd, args);
ps.on("close", (_code) => {
resolve(ps);
});
Expand Down Expand Up @@ -361,7 +356,6 @@ class InterfaceFFI {
this.ptr,
this.ptr,
this.ulonglong,
this.ptr,
this.ulonglong,
this.string,
this.bool,
Expand Down Expand Up @@ -1461,7 +1455,6 @@ class InterfaceFFI {
ptr,
destination,
amount,
null,
fee_per_gram,
message,
one_sided,
Expand Down
Loading

0 comments on commit a81228c

Please sign in to comment.