Skip to content

Commit

Permalink
Merge pull request #2649 from etungsten/cache-develop
Browse files Browse the repository at this point in the history
actions-workflow: add caching to develop and PR build workflows
  • Loading branch information
etungsten authored Dec 12, 2022
2 parents d20ea8e + 101780d commit a1771aa
Show file tree
Hide file tree
Showing 3 changed files with 92 additions and 3 deletions.
31 changes: 31 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -121,9 +121,40 @@ jobs:
fetch-upstream: "true"
fail-fast: false
steps:
- run: |
echo "OS_ARCH=`uname -m`" >> $GITHUB_ENV
- uses: actions/checkout@v3
# Cache `cargo-make`, `cargo-cache`, `cargo-sweep`
- uses: actions/cache@v3
with:
path: |
~/.cargo
key: ${{ hashFiles('.github/workflows/cache.yml') }}-${{ runner.os }}-${{ env.OS_ARCH }}
# Cache first-party rust code crate dependencies
- uses: actions/cache@v3
with:
path: |
.cargo
key: ${{ hashFiles('.github/workflows/cache.yml') }}-${{ runner.os }}-${{ env.OS_ARCH }}-${{ hashFiles('sources/Cargo.lock') }}-${{ hashFiles('.github/workflows/build.yml') }}
restore-keys: |
${{ hashFiles('.github/workflows/cache.yml') }}-${{ runner.os }}-${{ env.OS_ARCH }}-${{ hashFiles('sources/Cargo.lock') }}
# Cache 'tools/' dependencies and build artifacts
- uses: actions/cache@v3
with:
path: |
tools/bin
tools/.crates.toml
tools/.crates2.json
tools/target
key: ${{ hashFiles('.github/workflows/cache.yml') }}-${{ runner.os }}-${{ env.OS_ARCH }}-${{ hashFiles('tools/Cargo.lock') }}-${{ hashFiles('.github/workflows/build.yml') }}
restore-keys: |
${{ hashFiles('.github/workflows/cache.yml') }}-${{ runner.os }}-${{ env.OS_ARCH }}-${{ hashFiles('tools/Cargo.lock') }}
- run: rustup default 1.64.0 && rustup component add rustfmt && rustup component add clippy
- run: cargo install --version 0.36.0 cargo-make
- run: cargo install --version 0.6.2 cargo-sweep
- run: |
cargo sweep -i -r tools/
cargo sweep -t 7 -r tools/
- if: contains(matrix.variant, 'nvidia')
run: |
cat <<-EOF > Licenses.toml
Expand Down
58 changes: 58 additions & 0 deletions .github/workflows/cache.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
# This workflow caches crate dependencies and build artifacts for tools (except 'test-tools' since we don't use them in build workflows).
# The cache is only usable by workflows started from pull requests against the develop branch.
name: CacheDepsAndTools
on:
push:
branches: [develop]
paths:
- '.github/**'
- 'sources/Cargo.lock'
- 'tools/buildsys/**'
- 'tools/pubsys*/**'
- '!tools/pubsys/policies/**'
- '!tools/pubsys/**.example'
- '!tools/pubsys/**.template'
- 'tools/Cargo.lock'
jobs:
cache:
runs-on:
group: bottlerocket
labels: bottlerocket_ubuntu-latest_16-core
continue-on-error: true
steps:
- run: |
echo "OS_ARCH=`uname -m`" >> $GITHUB_ENV
- uses: actions/checkout@v3
# Cache `cargo-make`, `cargo-cache`, `cargo-sweep`
- uses: actions/cache@v3
with:
path: |
~/.cargo
key: ${{ hashFiles('.github/workflows/cache.yml') }}-${{ runner.os }}-${{ env.OS_ARCH }}
# Cache first-party code dependencies
- uses: actions/cache@v3
with:
path: |
.cargo
key: ${{ hashFiles('.github/workflows/cache.yml') }}-${{ runner.os }}-${{ env.OS_ARCH }}-${{ hashFiles('sources/Cargo.lock') }}
# Cache 'tools/' dependencies and build artifacts
- uses: actions/cache@v3
with:
path: |
tools/bin
tools/.crates.toml
tools/.crates2.json
tools/target
key: ${{ hashFiles('.github/workflows/cache.yml') }}-${{ runner.os }}-${{ env.OS_ARCH }}-${{ hashFiles('tools/Cargo.lock') }}
- run: rustup default 1.64.0
- run: cargo install --locked --version 0.36.0 cargo-make
- run: cargo install --locked --version 0.8.3 --no-default-features --features ci-autoclean cargo-cache
- run: cargo install --locked --version 0.6.2 cargo-sweep
- run: |
cargo sweep -i -r tools/
cargo sweep -t 7 -r tools/
- run: cargo make publish-setup-tools
- run: cargo make publish-tools
- run: cargo make build-tools
# This cleans the cargo cache in ~/.cargo
- run: cargo-cache
6 changes: 3 additions & 3 deletions Makefile.toml
Original file line number Diff line number Diff line change
Expand Up @@ -484,7 +484,7 @@ done'''
]

[tasks.build-tools]
dependencies = ["fetch"]
dependencies = ["setup", "fetch-sources"]
script = [
'''
cargo install \
Expand Down Expand Up @@ -616,7 +616,7 @@ docker run --rm \

# Builds a package including its build-time and runtime dependency packages.
[tasks.build-package]
dependencies = ["check-cargo-version", "build-tools", "publish-setup", "fetch-licenses"]
dependencies = ["check-cargo-version", "fetch-sdk", "build-tools", "publish-setup", "fetch-licenses"]
script_runner = "bash"
script = [
'''
Expand Down Expand Up @@ -649,7 +649,7 @@ cargo build \
]

[tasks.build-variant]
dependencies = ["build-tools", "publish-setup"]
dependencies = ["fetch-sdk", "build-tools", "publish-setup"]
script = [
'''
export PATH="${BUILDSYS_TOOLS_DIR}/bin:${PATH}"
Expand Down

0 comments on commit a1771aa

Please sign in to comment.