From b1394b4056ff42643ad856b56659b891e6f2d344 Mon Sep 17 00:00:00 2001 From: Prasanna Loganathar Date: Wed, 4 Oct 2023 10:08:33 +0800 Subject: [PATCH] Cargo tweaks for CI (#2527) * Disable cargo incremental builds on CI * Add cargo cache * Reduce debug to 1 * Cache only direct builds, move incremental * Set lintchecks --- .cargo/config.toml | 3 +++ .github/workflows/lint.yaml | 5 +++++ .github/workflows/tests-ethlibs.yaml | 9 +++++++-- .github/workflows/tests-frontier.yml | 9 +++++++-- .github/workflows/tests-sync.yml | 9 +++++++-- .github/workflows/tests.yaml | 12 +++++++++++- make.sh | 2 ++ 7 files changed, 42 insertions(+), 7 deletions(-) diff --git a/.cargo/config.toml b/.cargo/config.toml index 1d679e25fc..4792853988 100644 --- a/.cargo/config.toml +++ b/.cargo/config.toml @@ -12,6 +12,9 @@ rustflags = [ # "-C", "force-unwind-tables=y", ] +[profile.dev] +debug = 1 + [target.x86_64-apple-darwin] rustflags = [ "-C", "link-arg=-undefined", diff --git a/.github/workflows/lint.yaml b/.github/workflows/lint.yaml index 798215be79..2fe3913456 100644 --- a/.github/workflows/lint.yaml +++ b/.github/workflows/lint.yaml @@ -55,6 +55,11 @@ jobs: - name: Setup dependencies for target run: ./make.sh ci-setup-deps-target + - uses: Swatinem/rust-cache@v2 + with: + workspaces: lib -> ../build/lib/target + save-if: ${{ github.ref == 'refs/heads/master' }} + - name: Build depends and configure run: ./make.sh build-deps && ./make.sh build-conf diff --git a/.github/workflows/tests-ethlibs.yaml b/.github/workflows/tests-ethlibs.yaml index ea873682a2..ca3ce37b28 100644 --- a/.github/workflows/tests-ethlibs.yaml +++ b/.github/workflows/tests-ethlibs.yaml @@ -32,13 +32,18 @@ jobs: - name: Setup dependencies for target run: ./make.sh ci-setup-deps-target + - uses: Swatinem/rust-cache@v2 + with: + workspaces: lib -> ../build/lib/target + save-if: ${{ github.ref == 'refs/heads/master' }} + - name: Build binaries run: ./make.sh build - name: Upload binaries uses: actions/upload-artifact@v3 with: - name: defibins + name: defi-bins path: | build/src/defid build/src/defi-cli @@ -57,7 +62,7 @@ jobs: - name: Download binaries uses: actions/download-artifact@v3 with: - name: defibins + name: defi-bins - name: Download shell commands uses: actions/download-artifact@v3 diff --git a/.github/workflows/tests-frontier.yml b/.github/workflows/tests-frontier.yml index 11981fbbd4..42cef9f74a 100644 --- a/.github/workflows/tests-frontier.yml +++ b/.github/workflows/tests-frontier.yml @@ -25,13 +25,18 @@ jobs: - name: Setup dependencies for target run: ./make.sh ci-setup-deps-target + - uses: Swatinem/rust-cache@v2 + with: + workspaces: lib -> ../build/lib/target + save-if: ${{ github.ref == 'refs/heads/master' }} + - name: Build binaries run: ./make.sh build - name: Upload binaries uses: actions/upload-artifact@v3 with: - name: defibins + name: defi-bins path: | build/src/defid @@ -50,7 +55,7 @@ jobs: - name: Download binaries uses: actions/download-artifact@v3 with: - name: defibins + name: defi-bins - name: Setup permissions run: | diff --git a/.github/workflows/tests-sync.yml b/.github/workflows/tests-sync.yml index 4c9777bfcf..55e53c329a 100644 --- a/.github/workflows/tests-sync.yml +++ b/.github/workflows/tests-sync.yml @@ -37,6 +37,11 @@ jobs: - name: Setup dependencies for target run: ./make.sh ci-setup-deps-target + - uses: Swatinem/rust-cache@v2 + with: + workspaces: lib -> ../build/lib/target + save-if: ${{ github.ref == 'refs/heads/master' }} + # TODO: Switch this to a docker build later and this builds on the native # VM toolchain and loses disparity with the CI release builds - name: Build binaries @@ -45,7 +50,7 @@ jobs: - name: Upload binaries uses: actions/upload-artifact@v3 with: - name: defibins + name: defi-bins path: | build/src/defid build/src/defi-cli @@ -123,7 +128,7 @@ jobs: - name: Download Binaries uses: actions/download-artifact@v3 with: - name: defibins + name: defi-bins - name: Download Shell Commands uses: actions/download-artifact@v3 diff --git a/.github/workflows/tests.yaml b/.github/workflows/tests.yaml index ec39772947..cd5c95dc57 100644 --- a/.github/workflows/tests.yaml +++ b/.github/workflows/tests.yaml @@ -14,7 +14,7 @@ on: concurrency: group: ${{ github.workflow }}-${{ github.ref || github.run_id }} cancel-in-progress: ${{ github.ref != 'refs/heads/master' }} - + jobs: e2e-tests: runs-on: ubuntu-latest @@ -43,6 +43,11 @@ jobs: - name: Install dependencies for target run: ./make.sh ci-setup-deps-target + - uses: Swatinem/rust-cache@v2 + with: + workspaces: lib -> ../build/lib/target + save-if: ${{ github.ref == 'refs/heads/master' }} + - name: Build deps and configure run: ./make.sh build @@ -65,6 +70,11 @@ jobs: - name: Setup dependencies for target run: ./make.sh ci-setup-deps-target + - uses: Swatinem/rust-cache@v2 + with: + workspaces: lib -> ../build/lib/target + save-if: ${{ github.ref == 'refs/heads/master' }} + - name: Build deps and configure run: ./make.sh build-deps && ./make.sh build-conf diff --git a/make.sh b/make.sh index 105943c725..ecbcca3699 100755 --- a/make.sh +++ b/make.sh @@ -1070,11 +1070,13 @@ _nproc() { # CI # --- +# shellcheck disable=SC2129 ci_export_vars() { if [[ -n "${GITHUB_ACTIONS-}" ]]; then # GitHub Actions echo "BUILD_VERSION=${IMAGE_VERSION}" >> "$GITHUB_ENV" echo "PATH=$HOME/.cargo/bin:$PATH" >> "$GITHUB_ENV" + echo "CARGO_INCREMENTAL=0" >> "$GITHUB_ENV" fi }