diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index abc48281..794e1633 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -19,13 +19,18 @@ jobs: - uses: actions-rs/toolchain@v1 with: toolchain: stable - - uses: Swatinem/rust-cache@v1 + - uses: actions/cache@v3 with: - # Add a key to prevent rust cache collision with rust.yml workflows - key: 'release' + path: | + ~/.cargo/bin/ + ~/.cargo/registry/index/ + ~/.cargo/registry/cache/ + ~/.cargo/git/db/ + target/ + key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock', '**/rust-toolchain') }} - name: Build agents (release) - run: cargo build --release + run: cargo build --release --locked --workspace --all-features --verbose - name: Docker metadata id: meta diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index 783cbf86..7dd67376 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -17,53 +17,197 @@ env: jobs: build: runs-on: ubuntu-22.04 + env: + RUSTC_WRAPPER: sccache + SCCACHE_CACHE_SIZE: 2G + SCCACHE_DIR: /home/runner/.cargo/bin/sccache steps: - uses: actions/checkout@v2 - uses: actions-rs/toolchain@v1 with: toolchain: stable - - uses: Swatinem/rust-cache@v1 - + - name: install sccache + env: + LINK: https://github.com/mozilla/sccache/releases/download + SCCACHE_VERSION: v0.3.3 + run: | + SCCACHE_FILE=sccache-$SCCACHE_VERSION-x86_64-unknown-linux-musl + mkdir -p $HOME/.local/bin + curl -L "$LINK/$SCCACHE_VERSION/$SCCACHE_FILE.tar.gz" | tar xz + mv -f $SCCACHE_FILE/sccache $HOME/.local/bin/sccache + echo "$HOME/.local/bin" >> $GITHUB_PATH + - name: Cache cargo registry + uses: actions/cache@v3 + continue-on-error: false + with: + path: | + ~/.cargo/registry + ~/.cargo/git + key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock', '**/rust-environment') }} + restore-keys: | + ${{ runner.os }}-cargo- + - name: Save sccache + uses: actions/cache@v3 + continue-on-error: false + with: + path: /home/runner/.cargo/bin/sccache + key: ${{ runner.os }}-sccache-${{ hashFiles('**/Cargo.lock', '**/rust-environment') }} + restore-keys: | + ${{ runner.os }}-sccache- + - name: Start sccache server + run: sccache --start-server - name: Build agents - run: cargo build --locked --workspace --all-features --verbose - + run: cargo check --locked --workspace --all-features --verbose + - name: Print sccache stats + run: sccache --show-stats + - name: Stop sccache server + run: sccache --stop-server || true test: runs-on: ubuntu-22.04 + env: + RUSTC_WRAPPER: sccache + SCCACHE_CACHE_SIZE: 2G + SCCACHE_DIR: /home/runner/.cargo/bin/sccache steps: - uses: actions/checkout@v2 - uses: actions-rs/toolchain@v1 with: toolchain: stable - - uses: Swatinem/rust-cache@v1 - + - name: install sccache + env: + LINK: https://github.com/mozilla/sccache/releases/download + SCCACHE_VERSION: v0.3.3 + run: | + SCCACHE_FILE=sccache-$SCCACHE_VERSION-x86_64-unknown-linux-musl + mkdir -p $HOME/.local/bin + curl -L "$LINK/$SCCACHE_VERSION/$SCCACHE_FILE.tar.gz" | tar xz + mv -f $SCCACHE_FILE/sccache $HOME/.local/bin/sccache + echo "$HOME/.local/bin" >> $GITHUB_PATH + - name: Cache cargo registry + uses: actions/cache@v3 + continue-on-error: false + with: + path: | + ~/.cargo/registry + ~/.cargo/git + key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock', '**/rust-environment') }} + restore-keys: | + ${{ runner.os }}-cargo- + - name: Save sccache + uses: actions/cache@v3 + continue-on-error: false + with: + path: /home/runner/.cargo/bin/sccache + key: ${{ runner.os }}-sccache-${{ hashFiles('**/Cargo.lock', '**/rust-environment') }} + restore-keys: | + ${{ runner.os }}-sccache- + - name: Start sccache server + run: sccache --start-server - name: Run tests run: cargo test --locked --workspace --all-features --verbose + - name: Print sccache stats + run: sccache --show-stats + - name: Stop sccache server + run: sccache --stop-server || true lint: runs-on: ubuntu-22.04 + env: + RUSTC_WRAPPER: sccache + SCCACHE_CACHE_SIZE: 2G + SCCACHE_DIR: /home/runner/.cargo/bin/sccache steps: - uses: actions/checkout@v2 - uses: actions-rs/toolchain@v1 with: toolchain: stable - - uses: Swatinem/rust-cache@v1 + - name: install sccache + env: + LINK: https://github.com/mozilla/sccache/releases/download + SCCACHE_VERSION: v0.3.3 + run: | + SCCACHE_FILE=sccache-$SCCACHE_VERSION-x86_64-unknown-linux-musl + mkdir -p $HOME/.local/bin + curl -L "$LINK/$SCCACHE_VERSION/$SCCACHE_FILE.tar.gz" | tar xz + mv -f $SCCACHE_FILE/sccache $HOME/.local/bin/sccache + echo "$HOME/.local/bin" >> $GITHUB_PATH + - name: Cache cargo registry + uses: actions/cache@v3 + continue-on-error: false + with: + path: | + ~/.cargo/registry + ~/.cargo/git + key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock', '**/rust-environment') }} + restore-keys: | + ${{ runner.os }}-cargo- + - name: Save sccache + uses: actions/cache@v3 + continue-on-error: false + with: + path: /home/runner/.cargo/bin/sccache + key: ${{ runner.os }}-sccache-${{ hashFiles('**/Cargo.lock', '**/rust-environment') }} + restore-keys: | + ${{ runner.os }}-sccache- + - name: Start sccache server + run: sccache --start-server - name: Rustfmt run: cargo fmt --all -- --check - - name: Clippy run: cargo clippy --workspace --all-features -- -D warnings + - name: Print sccache stats + run: sccache --show-stats + - name: Stop sccache server + run: sccache --stop-server || true wasm-build: runs-on: ubuntu-22.04 + env: + RUSTC_WRAPPER: sccache + SCCACHE_CACHE_SIZE: 2G + SCCACHE_DIR: /home/runner/.cargo/bin/sccache steps: - uses: actions/checkout@v2 - uses: actions-rs/toolchain@v1 with: toolchain: stable - - uses: Swatinem/rust-cache@v1 + - name: install sccache + env: + LINK: https://github.com/mozilla/sccache/releases/download + SCCACHE_VERSION: v0.3.3 + run: | + SCCACHE_FILE=sccache-$SCCACHE_VERSION-x86_64-unknown-linux-musl + mkdir -p $HOME/.local/bin + curl -L "$LINK/$SCCACHE_VERSION/$SCCACHE_FILE.tar.gz" | tar xz + mv -f $SCCACHE_FILE/sccache $HOME/.local/bin/sccache + echo "$HOME/.local/bin" >> $GITHUB_PATH + - name: Cache cargo registry + uses: actions/cache@v3 + continue-on-error: false + with: + path: | + ~/.cargo/registry + ~/.cargo/git + key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock', '**/rust-environment') }} + restore-keys: | + ${{ runner.os }}-cargo- + - name: Save sccache + uses: actions/cache@v3 + continue-on-error: false + with: + path: /home/runner/.cargo/bin/sccache + key: ${{ runner.os }}-sccache-${{ hashFiles('**/Cargo.lock', '**/rust-environment') }} + restore-keys: | + ${{ runner.os }}-sccache- + - name: Start sccache server + run: sccache --start-server - uses: jetli/wasm-pack-action@v0.3.0 - name: wasm-configuration run: cd configuration && bash package_it.sh - name: wasm-accumulator run: cd accumulator && bash package_it.sh + - name: Print sccache stats + run: sccache --show-stats + - name: Stop sccache server + run: sccache --stop-server || true