341: Enable caching for Github Actions r=korken89 a=AfoHT

Using [GHA caching](https://docs.github.com/en/actions/configuring-and-managing-workflows/caching-dependencies-to-speed-up-workflows) to store key parts of the testing environment.

One example is downloading `arm-none-eabi-gcc` (which takes roughly 1 minute) for each checkexamples.

The rustup setup is roughly 200MB and restores nicely.

Rust examples can be found [here](https://github.com/actions/cache/blob/master/examples.md#rust---cargo)

**Something to discuss:**

Several notable projects remove some problematic files in order to keep cache size reasonable

[rust-analyzer](9a7db8fa00/.travis.yml (L2-L4))

[cargo duscussion](https://github.com/rust-lang/cargo/issues/5885)

[tantivity-search](https://github.com/tantivy-search/tantivy/pull/531/files)

[clap-rs](https://github.com/clap-rs/clap/pull/1658/files#diff-354f30a63fb0907d4ad57269548329e3R5-R16)


Co-authored-by: Henrik Tjäder <henrik@tjaders.com>
This commit is contained in:
bors[bot] 2020-08-25 17:27:02 +00:00 committed by GitHub
commit 846aa5062f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -14,7 +14,7 @@ jobs:
# Run cargo fmt --check, includes macros/ # Run cargo fmt --check, includes macros/
style: style:
name: style name: style
runs-on: ubuntu-latest runs-on: ubuntu-20.04
steps: steps:
- name: Checkout - name: Checkout
uses: actions/checkout@v1 uses: actions/checkout@v1
@ -36,7 +36,7 @@ jobs:
# Compilation check # Compilation check
check: check:
name: check name: check
runs-on: ubuntu-latest runs-on: ubuntu-20.04
strategy: strategy:
matrix: matrix:
target: target:
@ -50,6 +50,36 @@ jobs:
- name: Checkout - name: Checkout
uses: actions/checkout@v2 uses: actions/checkout@v2
- name: Cache cargo dependencies
uses: actions/cache@v2
with:
path: |
- ~/.cargo/bin/
- ~/.cargo/registry/index/
- ~/.cargo/registry/cache/
- ~/.cargo/git/db/
key: ${{ runner.OS }}-cargo-${{ hashFiles('**/Cargo.lock') }}
restore-keys: |
${{ runner.OS }}-cargo-${{ hashFiles('**/Cargo.lock') }}
${{ runner.OS }}-cargo-
- name: Cache build output dependencies
uses: actions/cache@v2
with:
path: target
key: ${{ runner.OS }}-build-${{ hashFiles('**/Cargo.lock') }}
restore-keys: |
${{ runner.OS }}-build-${{ hashFiles('**/Cargo.lock') }}
${{ runner.OS }}-build-
- name: Cache Rust toolchain
uses: actions/cache@v2
with:
path: /usr/share/rust/
key: ${{ runner.OS }}-rust-${{ env.rustc_hash }}
restore-keys: |
${{ runner.OS }}-rust-${{ env.rustc_hash }}
- name: Install Rust ${{ matrix.toolchain }} with target (${{ matrix.target }}) - name: Install Rust ${{ matrix.toolchain }} with target (${{ matrix.target }})
uses: actions-rs/toolchain@v1 uses: actions-rs/toolchain@v1
with: with:
@ -71,7 +101,7 @@ jobs:
# Verify all examples # Verify all examples
checkexamples: checkexamples:
name: checkexamples name: checkexamples
runs-on: ubuntu-latest runs-on: ubuntu-20.04
strategy: strategy:
matrix: matrix:
target: target:
@ -83,12 +113,43 @@ jobs:
- name: Checkout - name: Checkout
uses: actions/checkout@v2 uses: actions/checkout@v2
- name: Cache cargo dependencies
uses: actions/cache@v2
with:
path: |
- ~/.cargo/bin/
- ~/.cargo/registry/index/
- ~/.cargo/registry/cache/
- ~/.cargo/git/db/
key: ${{ runner.OS }}-cargo-${{ hashFiles('**/Cargo.lock') }}
restore-keys: |
${{ runner.OS }}-cargo-${{ hashFiles('**/Cargo.lock') }}
${{ runner.OS }}-cargo-
- name: Cache build output dependencies
uses: actions/cache@v2
with:
path: target
key: ${{ runner.OS }}-build-${{ hashFiles('**/Cargo.lock') }}
restore-keys: |
${{ runner.OS }}-build-${{ hashFiles('**/Cargo.lock') }}
${{ runner.OS }}-build-
- name: Cache Rust toolchain
uses: actions/cache@v2
with:
path: /usr/share/rust/
key: ${{ runner.OS }}-rust-${{ env.rustc_hash }}
restore-keys: |
${{ runner.OS }}-rust-${{ env.rustc_hash }}
- name: Install Rust ${{ matrix.toolchain }} with target (${{ matrix.target }}) - name: Install Rust ${{ matrix.toolchain }} with target (${{ matrix.target }})
uses: actions-rs/toolchain@v1 uses: actions-rs/toolchain@v1
with: with:
toolchain: ${{ matrix.toolchain }} toolchain: ${{ matrix.toolchain }}
target: ${{ matrix.target }} target: ${{ matrix.target }}
override: true override: true
components: llvm-tools-preview
- uses: actions-rs/cargo@v1 - uses: actions-rs/cargo@v1
with: with:
use-cross: false use-cross: false
@ -102,22 +163,24 @@ jobs:
command: check command: check
args: -p homogeneous --examples --target=${{ matrix.target }} args: -p homogeneous --examples --target=${{ matrix.target }}
# Use precompiled binutils
- name: cargo install cargo-binutils
uses: actions-rs/install@v0.1
with:
crate: cargo-binutils
version: latest
use-tool-cache: true
- name: Install QEMU - name: Install QEMU
run: | run: |
mkdir qemu sudo apt update
curl -L https://github.com/japaric/qemu-bin/raw/master/14.04/qemu-system-arm-2.12.0 > qemu/qemu-system-arm sudo apt install -y qemu-system-arm
chmod +x qemu/qemu-system-arm
- name: Setup arm-none-eabi-gcc
uses: fiam/arm-none-eabi-gcc@v1
with:
release: '9-2019-q4' # The arm-none-eabi-gcc release to use.
- name: Run-pass tests - name: Run-pass tests
run: | run: |
# Add QEMU to the path # Print the path
echo $PATH echo $PATH
PATH=$(pwd)/qemu:$PATH
arm_example() { arm_example() {
local COMMAND=$1 local COMMAND=$1
local EXAMPLE=$2 local EXAMPLE=$2
@ -145,7 +208,7 @@ jobs:
else else
cargo $COMMAND $CARGO_FLAGS cargo $COMMAND $CARGO_FLAGS
fi fi
arm-none-eabi-objcopy -O ihex target/${{ matrix.target }}/$BUILD_MODE/examples/$EXAMPLE ci/builds/${EXAMPLE}_${FEATURES_STR}${BUILD_MODE}_${BUILD_NUM}.hex cargo objcopy $CARGO_FLAGS -- -O ihex ci/builds/${EXAMPLE}_${FEATURES_STR}${BUILD_MODE}_${BUILD_NUM}.hex
} }
mkdir -p ci/builds mkdir -p ci/builds
@ -190,15 +253,13 @@ jobs:
$td/pool.run $td/pool.run
grep 'foo(0x2' $td/pool.run grep 'foo(0x2' $td/pool.run
grep 'bar(0x2' $td/pool.run grep 'bar(0x2' $td/pool.run
arm-none-eabi-objcopy -O ihex target/${{ matrix.target }}/debug/examples/$ex \ cargo objcopy --example $ex --target ${{ matrix.target }} --features __v7 -- -O ihex ci/builds/${ex}___v7_debug_1.hex
ci/builds/${ex}___v7_debug_1.hex
cargo run --example $ex --target ${{ matrix.target }} --features __v7 --release >\ cargo run --example $ex --target ${{ matrix.target }} --features __v7 --release >\
$td/pool.run $td/pool.run
grep 'foo(0x2' $td/pool.run grep 'foo(0x2' $td/pool.run
grep 'bar(0x2' $td/pool.run grep 'bar(0x2' $td/pool.run
arm-none-eabi-objcopy -O ihex target/${{ matrix.target }}/release/examples/$ex \ cargo objcopy --example $ex --target ${{ matrix.target }} --features __v7 --release -- -O ihex ci/builds/${ex}___v7_release_1.hex
ci/builds/${ex}___v7_release_1.hex
rm -rf $td rm -rf $td
@ -256,7 +317,7 @@ jobs:
# Check the correctness of macros/ crate # Check the correctness of macros/ crate
checkmacros: checkmacros:
name: checkmacros name: checkmacros
runs-on: ubuntu-latest runs-on: ubuntu-20.04
strategy: strategy:
matrix: matrix:
target: target:
@ -267,6 +328,37 @@ jobs:
steps: steps:
- name: Checkout - name: Checkout
uses: actions/checkout@v2 uses: actions/checkout@v2
- name: Cache cargo dependencies
uses: actions/cache@v2
with:
path: |
- ~/.cargo/bin/
- ~/.cargo/registry/index/
- ~/.cargo/registry/cache/
- ~/.cargo/git/db/
key: ${{ runner.OS }}-cargo-${{ hashFiles('**/Cargo.lock') }}
restore-keys: |
${{ runner.OS }}-cargo-${{ hashFiles('**/Cargo.lock') }}
${{ runner.OS }}-cargo-
- name: Cache build output dependencies
uses: actions/cache@v2
with:
path: target
key: ${{ runner.OS }}-build-${{ hashFiles('**/Cargo.lock') }}
restore-keys: |
${{ runner.OS }}-build-${{ hashFiles('**/Cargo.lock') }}
${{ runner.OS }}-build-
- name: Cache Rust toolchain
uses: actions/cache@v2
with:
path: /usr/share/rust/
key: ${{ runner.OS }}-rust-${{ env.rustc_hash }}
restore-keys: |
${{ runner.OS }}-rust-${{ env.rustc_hash }}
- name: Install Rust ${{ matrix.toolchain }} with target (${{ matrix.target }}) - name: Install Rust ${{ matrix.toolchain }} with target (${{ matrix.target }})
uses: actions-rs/toolchain@v1 uses: actions-rs/toolchain@v1
with: with:
@ -288,10 +380,39 @@ jobs:
# Run test suite for thumbv7m # Run test suite for thumbv7m
testv7: testv7:
name: testv7 name: testv7
runs-on: ubuntu-latest runs-on: ubuntu-20.04
steps: steps:
- name: Checkout - name: Checkout
uses: actions/checkout@v2 uses: actions/checkout@v2
- name: Cache cargo dependencies
uses: actions/cache@v2
with:
path: |
- ~/.cargo/bin/
- ~/.cargo/registry/index/
- ~/.cargo/registry/cache/
- ~/.cargo/git/db/
key: ${{ runner.OS }}-cargo-${{ hashFiles('**/Cargo.lock') }}
restore-keys: |
${{ runner.OS }}-cargo-
- name: Cache build output dependencies
uses: actions/cache@v2
with:
path: target
key: ${{ runner.OS }}-build-${{ hashFiles('**/Cargo.lock') }}
restore-keys: |
${{ runner.OS }}-build-
- name: Cache Rust toolchain
uses: actions/cache@v2
with:
path: /usr/share/rust/
key: ${{ runner.OS }}-rust-${{ env.rustc_hash }}
restore-keys: |
${{ runner.OS }}-rust-${{ env.rustc_hash }}
- name: Install Rust - name: Install Rust
uses: actions-rs/toolchain@v1 uses: actions-rs/toolchain@v1
with: with:
@ -311,10 +432,39 @@ jobs:
# Run test suite for thumbv6m # Run test suite for thumbv6m
testv6: testv6:
name: testv6 name: testv6
runs-on: ubuntu-latest runs-on: ubuntu-20.04
steps: steps:
- name: Checkout - name: Checkout
uses: actions/checkout@v2 uses: actions/checkout@v2
- name: Cache cargo dependencies
uses: actions/cache@v2
with:
path: |
- ~/.cargo/bin/
- ~/.cargo/registry/index/
- ~/.cargo/registry/cache/
- ~/.cargo/git/db/
key: ${{ runner.OS }}-cargo-${{ hashFiles('**/Cargo.lock') }}
restore-keys: |
${{ runner.OS }}-cargo-
- name: Cache build output dependencies
uses: actions/cache@v2
with:
path: target
key: ${{ runner.OS }}-build-${{ hashFiles('**/Cargo.lock') }}
restore-keys: |
${{ runner.OS }}-build-
- name: Cache Rust toolchain
uses: actions/cache@v2
with:
path: /usr/share/rust/
key: ${{ runner.OS }}-rust-${{ env.rustc_hash }}
restore-keys: |
${{ runner.OS }}-rust-${{ env.rustc_hash }}
- name: Install Rust - name: Install Rust
uses: actions-rs/toolchain@v1 uses: actions-rs/toolchain@v1
with: with:
@ -334,7 +484,7 @@ jobs:
# Verify all multicore examples # Verify all multicore examples
checkmulticore: checkmulticore:
name: checkmulticore name: checkmulticore
runs-on: ubuntu-latest runs-on: ubuntu-20.04
strategy: strategy:
matrix: matrix:
target: target:
@ -385,12 +535,48 @@ jobs:
# Build documentation, check links # Build documentation, check links
docs: docs:
name: docs name: docs
runs-on: ubuntu-latest runs-on: ubuntu-20.04
steps: steps:
- name: Checkout - name: Checkout
uses: actions/checkout@v2 uses: actions/checkout@v2
- name: Cache cargo dependencies
uses: actions/cache@v2
with:
path: |
- ~/.cargo/bin/
- ~/.cargo/registry/index/
- ~/.cargo/registry/cache/
- ~/.cargo/git/db/
key: ${{ runner.OS }}-cargo-${{ hashFiles('**/Cargo.lock') }}
restore-keys: |
${{ runner.OS }}-cargo-
- name: Cache build output dependencies
uses: actions/cache@v2
with:
path: target
key: ${{ runner.OS }}-build-${{ hashFiles('**/Cargo.lock') }}
restore-keys: |
${{ runner.OS }}-build-
- name: Cache Rust toolchain
uses: actions/cache@v2
with:
path: /usr/share/rust/
key: ${{ runner.OS }}-rust-${{ env.rustc_hash }}
restore-keys: |
${{ runner.OS }}-rust-${{ env.rustc_hash }}
- name: Cache pip installed linkchecker
uses: actions/cache@v2
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip
restore-keys: |
${{ runner.os }}-pip-
- name: Set up Python 3.x - name: Set up Python 3.x
uses: actions/setup-python@v2 uses: actions/setup-python@v2
with: with:
@ -422,7 +608,7 @@ jobs:
# Build the books # Build the books
mdbook: mdbook:
name: mdbook name: mdbook
runs-on: ubuntu-latest runs-on: ubuntu-20.04
steps: steps:
- name: Checkout - name: Checkout
uses: actions/checkout@v2 uses: actions/checkout@v2
@ -467,7 +653,7 @@ jobs:
# Only runs when pushing to master branch # Only runs when pushing to master branch
deploy: deploy:
name: deploy name: deploy
runs-on: ubuntu-latest runs-on: ubuntu-20.04
needs: needs:
- style - style
- check - check
@ -582,7 +768,7 @@ jobs:
- checkmulticore - checkmulticore
- docs - docs
- mdbook - mdbook
runs-on: ubuntu-latest runs-on: ubuntu-20.04
steps: steps:
- name: Mark the job as a success - name: Mark the job as a success
run: exit 0 run: exit 0
@ -599,7 +785,7 @@ jobs:
- checkmulticore - checkmulticore
- docs - docs
- mdbook - mdbook
runs-on: ubuntu-latest runs-on: ubuntu-20.04
steps: steps:
- name: Mark the job as a failure - name: Mark the job as a failure
run: exit 1 run: exit 1