Skip to content
This repository was archived by the owner on Oct 23, 2022. It is now read-only.

Commit 08f840b

Browse files
Merge #471
471: ci: cache improvements r=koivunej a=Mirko-von-Leipzig This PR improves the CI caching, roughly halving the time required when caches are hit (no dependency or toolchain changes). Overview of changes: - Use [rust-cache action](https://github.com/Swatinem/rust-cache). This forms the bulk of the time improvement as Rust dependencies are now cached. - Improve npm caching for conformance tests. This trims 2-3 minutes of build time. - Improve job and step naming. - Add a manual trigger for the workflow. - Remove core dump for macos, no longer required. Further details can be found in the commits. I've been running into sporadic conformance test failures on windows ([link to run](https://github.com/Mirko-von-Leipzig/rust-ipfs/actions/runs/1135372291)): ``` 1) .pubsub.subscribe multiple connected nodes should send/receive 100 messages: FetchError: request to http://127.0.0.1:50533/api/v0/pubsub/pub?arg=pubsub-tests-C-aIrZS_7OSQMNSVOMszV failed, reason: read ECONNRESET at ClientRequest.<anonymous> (node_modules\node-fetch\lib\index.js:1455:11) at Socket.socketErrorListener (_http_client.js:475:9) at emitErrorNT (internal/streams/destroy.js:106:8) at emitErrorCloseNT (internal/streams/destroy.js:74:3) at processTicksAndRejections (internal/process/task_queues.js:82:21) ``` Co-authored-by: Mirko von Leipzig <mirko.vonleipzig@gmail.com>
2 parents b37811f + df11329 commit 08f840b

File tree

1 file changed

+73
-79
lines changed

1 file changed

+73
-79
lines changed

.github/workflows/ci.yml

Lines changed: 73 additions & 79 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
on:
2+
workflow_dispatch:
23
push:
34
branches:
45
- trying
@@ -21,14 +22,17 @@ jobs:
2122

2223
platform:
2324
- target: x86_64-unknown-linux-gnu
25+
name: ubuntu
2426
host: ubuntu-latest
2527
cross: false
2628

2729
- target: x86_64-apple-darwin
30+
name: macos
2831
host: macos-latest
2932
cross: false
3033

3134
- target: x86_64-pc-windows-msvc
35+
name: windows
3236
host: windows-latest
3337
cross: false
3438

@@ -37,18 +41,22 @@ jobs:
3741
# was metered.
3842
#
3943
# - target: armv7-linux-androideabi
44+
# name: android (armv7)
4045
# host: ubuntu-latest
4146
# cross: true
4247
#
4348
# - target: aarch64-linux-android
49+
# name: android (aarch64)
4450
# host: ubuntu-latest
4551
# cross: true
4652
#
4753
# - target: x86_64-apple-ios
54+
# name: ios (x86_64)
4855
# host: macos-latest
4956
# cross: true
5057
#
5158
# - target: aarch64-apple-ios
59+
# name: ios (aarch64)
5260
# host: macos-latest
5361
# cross: true
5462

@@ -62,142 +70,128 @@ jobs:
6270
DEBUG: ipfsd-ctl:* # enables all debug output from javascript 'debug' lib used by js-ipfsd-ctl
6371

6472
runs-on: ${{ matrix.platform.host }}
73+
name: ${{ matrix.platform.name }}
6574
steps:
6675
- name: Checkout sources
6776
uses: actions/checkout@v2
6877

69-
- name: Cache cargo folder
70-
uses: actions/cache@v2
71-
with:
72-
path: |
73-
~/.cargo/registry
74-
~/.cargo/git
75-
key: ${{ matrix.platform.target }}-dot-cargo-parts-${{ hashFiles('Cargo.lock') }}
76-
77-
- name: Get npm cache directory
78-
id: npm-cache
79-
if: matrix.platform.cross == false
80-
run: |
81-
echo "::set-output name=dir::$(npm config get cache)"
82-
83-
- name: Cache npm (non-cross targets)
84-
uses: actions/cache@v2
85-
if: matrix.platform.cross == false
86-
with:
87-
path: ${{ steps.npm-cache.outputs.dir }}
88-
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json', '**/setup.sh', '**/*.patch') }}
89-
restore-keys: |
90-
${{ runner.os }}-node-
91-
92-
- name: Install dependencies ubuntu
78+
- name: Install dependencies (linux)
9379
if: matrix.platform.host == 'ubuntu-latest'
9480
run: sudo apt-get install llvm-dev libssl-dev pkg-config
9581

96-
- name: Install dependencies macos
82+
- name: Install dependencies (macos)
9783
if: matrix.platform.host == 'macos-latest'
9884
run: brew install llvm openssl
9985

100-
- name: Download go-ipfs on Linux
101-
if: matrix.platform.host == 'ubuntu-latest'
102-
run: |
103-
curl -L https://github.com/ipfs/go-ipfs/releases/download/v0.7.0/go-ipfs_v0.7.0_linux-amd64.tar.gz --output go_ipfs.tar.gz
104-
tar -xf go_ipfs.tar.gz
105-
106-
- name: Install dependencies windows (openssl)
86+
- name: Install and cache vcpkg (windows)
10787
uses: lukka/run-vcpkg@v7.4
10888
id: windows-runvcpkg
10989
if: matrix.platform.host == 'windows-latest'
11090
with:
11191
vcpkgDirectory: '${{ runner.workspace }}/vcpkg'
11292
vcpkgTriplet: 'x64-windows'
113-
vcpkgArguments: 'openssl'
11493
vcpkgGitCommitId: '261c458af6e3eed5d099144aff95d2b5035f656b' # unknown for openssl-sys v0.9.65
94+
setupOnly: true # required for caching
95+
96+
- name: Install depedencies (windows)
97+
if: matrix.platform.host == 'windows-latest'
98+
run: "$VCPKG_ROOT/vcpkg install openssl:x64-windows"
99+
shell: bash
100+
env:
101+
VCPKGRS_DYNAMIC: 1
115102

116103
- name: Install rust toolchain
117104
uses: hecrj/setup-rust-action@v1.3.4
118105
with:
119106
rust-version: ${{ matrix.toolchain.rust }}
120107
targets: ${{ matrix.platform.target }}
121108

122-
- name: Install cargo-ndk
123-
if: contains(matrix.platform.target, 'android')
124-
run: cargo install --version '<2.0.0' cargo-ndk
109+
- name: Rust cache
110+
uses: Swatinem/rust-cache@v1
111+
with:
112+
# So that cross-compiles don't share a cache.
113+
key: ${{ matrix.platform.target }}
125114

126-
- name: Build (others)
115+
- name: Cargo build
127116
if: matrix.platform.cross == false
128117
run: cargo build --workspace --all-targets
129118

130-
- name: Run interop DHT tests with go-ipfs
131-
if: matrix.platform.host == 'ubuntu-latest' && matrix.platform.cross == false
132-
run: cargo test --features=test_go_interop dht
133-
134-
- name: Setup conformance tests (non-cross targets)
135-
if: matrix.platform.cross == false
136-
run: ./setup.sh
137-
shell: bash
138-
working-directory: ./conformance
139-
140-
- name: Build (android)
119+
- name: Cargo build (cross compile, android)
141120
if: contains(matrix.platform.target, 'android')
142-
run: cargo ndk --android-platform 29 --target ${{ matrix.platform.target }} build --workspace --exclude ipfs-http
121+
run: |
122+
cargo install --version '<2.0.0' cargo-ndk
123+
cargo ndk --android-platform 29 --target ${{ matrix.platform.target }} build --workspace --exclude ipfs-http
143124
# exclude http on android because openssl
144125

145-
- name: Build other cross compilations
126+
- name: Cargo build (cross compile, non-android)
146127
if: contains(matrix.platform.target, 'android') == false && matrix.platform.cross == true
147128
run: cargo build --workspace --exclude ipfs-http --target ${{ matrix.platform.target }}
148129
# exclude http on other cross compilation targets because openssl
149130

150-
- name: Rust tests (macos)
151-
if: matrix.platform.cross == false && matrix.platform.host == 'macos-latest'
152-
run: |
153-
ulimit -c unlimited
154-
sudo touch /cores/test || { ls -ld /cores; exit 1; }
155-
sudo rm /cores/test
156-
retval=0
157-
sudo cargo test --workspace || retval=$?
158-
sudo chmod -R a+rwx /cores
159-
exit $retval
160-
161-
- name: Rust tests (other non-cross targets)
162-
if: matrix.platform.cross == false && matrix.platform.host != 'macos-latest'
131+
- name: Cargo test
132+
if: matrix.platform.cross == false
163133
run: cargo test --workspace
164134

165-
- name: Conformance testing (non-cross targets)
135+
- name: Interop DHT tests with go-ipfs (linux)
136+
if: matrix.platform.host == 'ubuntu-latest' && matrix.platform.cross == false
137+
run: |
138+
curl -L https://github.com/ipfs/go-ipfs/releases/download/v0.7.0/go-ipfs_v0.7.0_linux-amd64.tar.gz --output go_ipfs.tar.gz
139+
tar -xf go_ipfs.tar.gz
140+
cargo test --features=test_go_interop dht
141+
142+
- name: "Conformance tests: cache config"
143+
id: conformance-cache-config
144+
if: matrix.platform.cross == false
145+
run: |
146+
echo "::set-output name=dir::$(npm config get cache)"
147+
echo "::set-output name=ver::$(npm -v)"
148+
149+
- name: "Conformance tests: cache"
150+
id: conformance-cache
151+
if: matrix.platform.cross == false
152+
uses: actions/cache@v2
153+
with:
154+
path: |
155+
${{ steps.conformance-cache-config.outputs.dir }}
156+
./conformance/node_modules
157+
key: ${{ runner.os }}-conformance-${{ steps.conformance-cache-config.outputs.ver }} ${{ hashFiles('**/package-lock.json', '**/setup.sh', '**/*.patch') }}
158+
159+
- name: "Conformance tests: setup"
160+
if: steps.conformance-cache.outputs.cache-hit != 'true' && matrix.platform.cross == false
161+
run: ./setup.sh
162+
shell: bash
163+
working-directory: ./conformance
164+
165+
- name: "Conformance tests: run"
166166
if: matrix.platform.cross == false
167167
run: IPFS_RUST_EXEC=../target/debug/ipfs-http npm test
168168
shell: bash
169169
working-directory: ./conformance
170170

171-
- name: Upload crashes (macos)
172-
uses: actions/upload-artifact@v2
173-
if: ${{ always() }}
174-
with:
175-
name: macos.crashes
176-
path: /cores
177-
if-no-files-found: ignore
171+
# Work around for this issue: https://github.com/Swatinem/rust-cache/issues/26
172+
- name: Fix cache permissions (macos)
173+
if: matrix.platform.cross == false && matrix.platform.host == 'macos-latest'
174+
run: sudo chown -R $(whoami):$(id -ng) ./target
178175

179176
lint-rust:
180177
runs-on: ubuntu-latest
181178
steps:
182179
- name: Checkout sources
183180
uses: actions/checkout@v2
184181

185-
- name: Cache cargo folder
186-
uses: actions/cache@v2
187-
with:
188-
path: ~/.cargo
189-
key: lint-cargo-${{ hashFiles('Cargo.lock') }}
190-
191182
- name: Install rust toolchain
192183
uses: hecrj/setup-rust-action@v1.3.4
193184
with:
194185
rust-version: stable
195186
components: clippy, rustfmt
196187

197-
- name: cargo fmt
188+
- name: Rust cache
189+
uses: Swatinem/rust-cache@v1
190+
191+
- name: Cargo fmt
198192
run: cargo fmt --all -- --check
199193

200-
- name: cargo clippy
194+
- name: Cargo clippy
201195
run: cargo clippy --all-targets --workspace -- -D warnings
202196

203197
# adapted from https://github.com/taiki-e/pin-project/blob/5878410863f5f25e21f7cba97b035501749850f9/.github/workflows/ci.yml#L136-L167

0 commit comments

Comments
 (0)