diff --git a/.github/workflows/build-and-test.yml b/.github/workflows/build-and-test.yml index 63dbf47666..aefd016b67 100644 --- a/.github/workflows/build-and-test.yml +++ b/.github/workflows/build-and-test.yml @@ -16,7 +16,6 @@ on: env: RUST_BACKTRACE: full - RUSTC_WRAPPER: sccache SCCACHE_DOWNLOAD_LINK: https://github.com/mozilla/sccache/releases/download SCCACHE_VERSION: v0.2.15 SCCACHE_CACHE_SIZE: 2G @@ -39,6 +38,7 @@ jobs: sccache-path: C:\\Users\\runner\\AppData\\Local\\Mozilla\\sccache\\cache env: SCCACHE_DIR: ${{ matrix.sccache-path }} + RUSTC_WRAPPER: sccache steps: - uses: actions/checkout@v2 @@ -74,15 +74,22 @@ jobs: ${{ matrix.os }}-cargo-${{ github.job }}- ${{ matrix.os }}-cargo- + # Generate Cargo.lock files for build, sccache cache keys. + # Allows dependencies updated on crates.io between runs to trigger storing an updated cache, + # which hashing Cargo.toml files alone does not. + - name: Cargo update + uses: actions-rs/cargo@v1 + with: + command: update + - name: Cache build target uses: actions/cache@v2.1.4 with: path: target # Add date to the cache to keep it up to date - key: ${{ matrix.os }}-target-${{ github.job }}-${{ hashFiles('**/Cargo.toml') }}-${{ env.CURRENT_DATE }} + key: ${{ matrix.os }}-target-${{ github.job }}-${{ hashFiles('**/Cargo.lock') }} # Restore from outdated cache for speed restore-keys: | - ${{ matrix.os }}-target-${{ github.job }}-${{ hashFiles('**/Cargo.toml') }}- ${{ matrix.os }}-target-${{ github.job }}- ${{ matrix.os }}-target- @@ -91,9 +98,8 @@ jobs: continue-on-error: false with: path: ${{ matrix.sccache-path }} - key: ${{ runner.os }}-sccache-${{ github.job }}-${{ hashFiles('**/Cargo.toml') }}-${{ env.CURRENT_DATE }} + key: ${{ runner.os }}-sccache-${{ github.job }}-${{ hashFiles('**/Cargo.lock') }} restore-keys: | - ${{ runner.os }}-sccache-${{ github.job }}-${{ hashFiles('**/Cargo.toml') }}- ${{ runner.os }}-sccache-${{ github.job }}- ${{ runner.os }}-sccache- @@ -154,9 +160,6 @@ jobs: os: [ ubuntu-latest ] include: - os: ubuntu-latest - sccache-path: /home/runner/.cache/sccache - env: - SCCACHE_DIR: ${{ matrix.sccache-path }} steps: - uses: actions/checkout@v2 @@ -167,69 +170,6 @@ jobs: toolchain: stable override: true - - name: Get current date - run: echo "CURRENT_DATE=$(date +'%Y-%m-%d')" >> $GITHUB_ENV - - - name: Cache cargo - uses: actions/cache@v2.1.4 - with: - # https://doc.rust-lang.org/cargo/guide/cargo-home.html#caching-the-cargo-home-in-ci - path: | - ~/.cargo/bin/ - ~/.cargo/registry/index/ - ~/.cargo/registry/cache/ - ~/.cargo/git/db/ - # Add date to the cache to keep it up to date - key: ${{ matrix.os }}-cargo-${{ github.job }}-${{ hashFiles('**/Cargo.toml') }}-${{ env.CURRENT_DATE }} - # Restore from outdated cache for speed - restore-keys: | - ${{ matrix.os }}-cargo-${{ github.job }}-${{ hashFiles('**/Cargo.toml') }}- - ${{ matrix.os }}-cargo-${{ github.job }}- - ${{ matrix.os }}-cargo- - - - name: Cache libjose build target - uses: actions/cache@v2.1.4 - with: - path: libjose/target - # Add date to the cache to keep it up to date - key: ${{ matrix.os }}-libjose-target-${{ github.job }}-${{ hashFiles('**/Cargo.toml') }}-${{ env.CURRENT_DATE }} - # Restore from outdated cache for speed - restore-keys: | - ${{ matrix.os }}-libjose-target-${{ github.job }}-${{ hashFiles('**/Cargo.toml') }}- - ${{ matrix.os }}-libjose-target-${{ github.job }}- - ${{ matrix.os }}-libjose-target- - - - name: Cache sccache - uses: actions/cache@v2.1.6 - continue-on-error: false - with: - path: ${{ matrix.sccache-path }} - key: ${{ runner.os }}-sccache-${{ github.job }}-${{ hashFiles('**/Cargo.toml') }}-${{ env.CURRENT_DATE }} - restore-keys: | - ${{ runner.os }}-sccache-${{ github.job }}-${{ hashFiles('**/Cargo.toml') }}- - ${{ runner.os }}-sccache-${{ github.job }}- - ${{ runner.os }}-sccache- - - - name: Install sccache (ubuntu-latest) - if: matrix.os == 'ubuntu-latest' - run: | - SCCACHE_PREFIX="sccache-$SCCACHE_VERSION-x86_64-unknown-linux-musl" - SCCACHE_TAR="${SCCACHE_PREFIX}.tar.gz" - DOWNLOAD_LINK="${SCCACHE_DOWNLOAD_LINK}/${SCCACHE_VERSION}/${SCCACHE_TAR}" - curl -L "${DOWNLOAD_LINK}" --output ${SCCACHE_TAR} - echo "$(curl -L ${DOWNLOAD_LINK}.sha256) ${SCCACHE_TAR}" | shasum -a 256 --check --status - tar xzf ${SCCACHE_TAR} - BIN_DIR="$HOME/.local/bin" - mkdir -p ${BIN_DIR} - mv -f ${SCCACHE_PREFIX}/sccache ${BIN_DIR}/sccache - chmod a+x "${BIN_DIR}/sccache" - echo ${BIN_DIR} >> $GITHUB_PATH - - - name: Start sccache - run: | - sccache --start-server - sccache -s - - name: Build uses: actions-rs/cargo@v1 with: @@ -242,9 +182,6 @@ jobs: command: test args: --manifest-path ./libjose/Cargo.toml --release - - name: Stop sccache server - run: sccache --stop-server || true - build-and-test-wasm: runs-on: ubuntu-latest strategy: @@ -256,6 +193,7 @@ jobs: sccache-path: /home/runner/.cache/sccache env: SCCACHE_DIR: ${{ matrix.sccache-path }} + RUSTC_WRAPPER: sccache steps: - uses: actions/checkout@v2 @@ -289,15 +227,22 @@ jobs: ${{ matrix.os }}-cargo-${{ github.job }}- ${{ matrix.os }}-cargo- + # Generate Cargo.lock files for build, sccache cache keys. + # Allows dependencies updated on crates.io between runs to trigger storing an updated cache, + # which hashing Cargo.toml files alone does not. + - name: Cargo update + uses: actions-rs/cargo@v1 + with: + command: update + - name: Cache wasm target uses: actions/cache@v2.1.4 with: path: bindings/wasm/target # Add date to the cache to keep it up to date - key: ${{ matrix.os }}-wasm-target-${{ github.job }}-${{ hashFiles('**/Cargo.toml') }}-${{ env.CURRENT_DATE }} + key: ${{ matrix.os }}-wasm-target-${{ github.job }}-${{ hashFiles('**/Cargo.lock') }} # Restore from outdated cache for speed restore-keys: | - ${{ matrix.os }}-wasm-target-${{ github.job }}-${{ hashFiles('**/Cargo.toml') }}- ${{ matrix.os }}-wasm-target-${{ github.job }}- ${{ matrix.os }}-wasm-target- @@ -306,9 +251,8 @@ jobs: continue-on-error: false with: path: ${{ matrix.sccache-path }} - key: ${{ runner.os }}-sccache-${{ github.job }}-${{ hashFiles('**/Cargo.toml') }}-${{ env.CURRENT_DATE }} + key: ${{ runner.os }}-sccache-${{ github.job }}-${{ hashFiles('**/Cargo.lock') }} restore-keys: | - ${{ runner.os }}-sccache-${{ github.job }}-${{ hashFiles('**/Cargo.toml') }}- ${{ runner.os }}-sccache-${{ github.job }}- ${{ runner.os }}-sccache-