1+ # Notes on Caching:
2+ #
3+ # Caches are keyed by OS, rustc version, job and Cargo.toml hash.
4+ # We additionally cache the `Cargo.lock` file, as that is not being committed
5+ # directly to git.
6+
17name : CI
28
39on :
1117 lints :
1218 name : Lints
1319 runs-on : ubuntu-latest
20+ env :
21+ cache-name : lints
1422 steps :
1523 - name : Checkout sources
1624 uses : actions/checkout@v2
3038 ~/.cargo/registry
3139 ~/.cargo/git
3240 target
33- key : ${{ runner.os }}-${{ steps.toolchain.outputs.rustc_hash }}-lints-${{ hashFiles('**/Cargo.toml') }}
41+ Cargo.lock
42+ key : ${{ runner.os }}-${{ steps.toolchain.outputs.rustc_hash }}-${{ env.cache-name }}-${{ hashFiles('**/Cargo.toml') }}
3443 restore-keys : |
35- ${{ runner.os }}-${{ steps.toolchain.outputs.rustc_hash }}-lints -
44+ ${{ runner.os }}-${{ steps.toolchain.outputs.rustc_hash }}-${{ env.cache-name }} -
3645
3746 - name : Run cargo fmt
3847 uses : actions-rs/cargo@v1
5665 name : checkall using ${{ matrix.rust }} on ${{ matrix.os }}
5766 runs-on : ${{ matrix.os }}
5867
68+ env :
69+ cache-name : check
5970 steps :
6071 - name : Checkout sources
6172 uses : actions/checkout@v2
@@ -68,15 +79,23 @@ jobs:
6879 toolchain : ${{ matrix.rust }}
6980 override : true
7081
82+ # workaround for: https://github.com/actions/cache/issues/403
83+ - name : Install GNU tar (macOS)
84+ if : runner.os == 'macOS'
85+ run : |
86+ brew install gnu-tar
87+ echo "::add-path::/usr/local/opt/gnu-tar/libexec/gnubin"
88+
7189 - uses : actions/cache@v2
7290 with :
7391 path : |
7492 ~/.cargo/registry
7593 ~/.cargo/git
7694 target
77- key : ${{ runner.os }}-${{ steps.toolchain.outputs.rustc_hash }}-check-${{ hashFiles('**/Cargo.toml') }}
95+ Cargo.lock
96+ key : ${{ runner.os }}-${{ steps.toolchain.outputs.rustc_hash }}-${{ env.cache-name }}-${{ hashFiles('**/Cargo.toml') }}
7897 restore-keys : |
79- ${{ runner.os }}-${{ steps.toolchain.outputs.rustc_hash }}-check -
98+ ${{ runner.os }}-${{ steps.toolchain.outputs.rustc_hash }}-${{ env.cache-name }} -
8099
81100 - run : make checkall
82101
90109 name : testall using ${{ matrix.rust }} on ${{ matrix.os }}
91110 runs-on : ${{ matrix.os }}
92111
112+ env :
113+ cache-name : test
93114 steps :
94115 - name : Checkout sources
95116 uses : actions/checkout@v2
@@ -102,15 +123,23 @@ jobs:
102123 toolchain : ${{ matrix.rust }}
103124 override : true
104125
126+ # workaround for: https://github.com/actions/cache/issues/403
127+ - name : Install GNU tar (macOS)
128+ if : runner.os == 'macOS'
129+ run : |
130+ brew install gnu-tar
131+ echo "::add-path::/usr/local/opt/gnu-tar/libexec/gnubin"
132+
105133 - uses : actions/cache@v2
106134 with :
107135 path : |
108136 ~/.cargo/registry
109137 ~/.cargo/git
110138 target
111- key : ${{ runner.os }}-${{ steps.toolchain.outputs.rustc_hash }}-test-${{ hashFiles('**/Cargo.toml') }}
139+ Cargo.lock
140+ key : ${{ runner.os }}-${{ steps.toolchain.outputs.rustc_hash }}-${{ env.cache-name }}-${{ hashFiles('**/Cargo.toml') }}
112141 restore-keys : |
113- ${{ runner.os }}-${{ steps.toolchain.outputs.rustc_hash }}-test -
142+ ${{ runner.os }}-${{ steps.toolchain.outputs.rustc_hash }}-${{ env.cache-name }} -
114143
115144 - name : Run cargo test
116145 uses : actions-rs/cargo@v1
@@ -128,11 +157,14 @@ jobs:
128157 name : checkfast/testfast using ${{ matrix.rust }} on ${{ matrix.os }}
129158 runs-on : ${{ matrix.os }}
130159
160+ env :
161+ cache-name : fast-MSRV
131162 steps :
132163 - name : Checkout sources
133164 uses : actions/checkout@v2
134165
135166 - name : Install rust toolchain
167+ id : toolchain
136168 uses : actions-rs/toolchain@v1
137169 with :
138170 profile : minimal
@@ -145,7 +177,10 @@ jobs:
145177 ~/.cargo/registry
146178 ~/.cargo/git
147179 target
148- key : ${{ runner.os }}-fast-msrv-${{ hashFiles('**/Cargo.toml') }}
180+ Cargo.lock
181+ key : ${{ runner.os }}-${{ steps.toolchain.outputs.rustc_hash }}-${{ env.cache-name }}-${{ hashFiles('**/Cargo.toml') }}
182+ restore-keys : |
183+ ${{ runner.os }}-${{ steps.toolchain.outputs.rustc_hash }}-${{ env.cache-name }}
149184
150185 - run : make checkfast
151186
0 commit comments