forked from rs-ipfs/rust-ipfs
-
Notifications
You must be signed in to change notification settings - Fork 8
217 lines (186 loc) · 6.96 KB
/
ci.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
on:
workflow_dispatch:
push:
branches:
- trying
- staging
pull_request:
branches: '*'
schedule:
# added while removing the Cargo.lock to help combat dependency drift caused by too lenient Cargo.toml ranges
- cron: '0 3 * * 1' # every monday at 03:00
name: Rust IPFS
jobs:
ci-matrix:
strategy:
fail-fast: false
matrix:
toolchain:
- rust: stable
platform:
- target: x86_64-unknown-linux-gnu
name: ubuntu
host: ubuntu-latest
cross: false
- target: x86_64-apple-darwin
name: macos
host: macos-latest
cross: false
- target: x86_64-pc-windows-msvc
name: windows
host: windows-2019
cross: false
# Mobile platforms disabled until we get a good estimate of them being
# needed. Previous discussion to enable them was before github CI usage
# was metered.
#
# - target: armv7-linux-androideabi
# name: android (armv7)
# host: ubuntu-latest
# cross: true
#
# - target: aarch64-linux-android
# name: android (aarch64)
# host: ubuntu-latest
# cross: true
#
# - target: x86_64-apple-ios
# name: ios (x86_64)
# host: macos-latest
# cross: true
#
# - target: aarch64-apple-ios
# name: ios (aarch64)
# host: macos-latest
# cross: true
env:
RUST_BACKTRACE: 1
CARGO_INCREMENTAL: 0
LLVM_CONFIG_PATH: /usr/local/opt/llvm/bin/llvm-config
NDK_HOME: /usr/local/lib/android/sdk/ndk-bundle
GO_IPFS_PATH: /home/runner/work/rust-ipfs/rust-ipfs/go-ipfs/ipfs
VCPKGRS_DYNAMIC: 1
DEBUG: ipfsd-ctl:* # enables all debug output from javascript 'debug' lib used by js-ipfsd-ctl
runs-on: ${{ matrix.platform.host }}
name: ${{ matrix.platform.name }}
steps:
- name: Checkout sources
uses: actions/checkout@v2
- name: Install dependencies (linux)
if: matrix.platform.host == 'ubuntu-latest'
run: sudo apt-get install llvm-dev libssl-dev pkg-config
- name: Install dependencies (macos)
if: matrix.platform.host == 'macos-latest'
run: brew install llvm openssl
- name: Install and cache vcpkg (windows)
uses: lukka/[email protected]
id: windows-runvcpkg
if: matrix.platform.host == 'windows-2019'
with:
vcpkgDirectory: '${{ runner.workspace }}/vcpkg'
vcpkgTriplet: 'x64-windows'
vcpkgGitCommitId: '261c458af6e3eed5d099144aff95d2b5035f656b' # unknown for openssl-sys v0.9.65
setupOnly: true # required for caching
- name: Install depedencies (windows)
if: matrix.platform.host == 'windows-2019'
run: "$VCPKG_ROOT/vcpkg install openssl:x64-windows"
shell: bash
env:
VCPKGRS_DYNAMIC: 1
- name: Install rust toolchain
uses: hecrj/[email protected]
with:
rust-version: ${{ matrix.toolchain.rust }}
targets: ${{ matrix.platform.target }}
- name: Rust cache
uses: Swatinem/rust-cache@v1
with:
# So that cross-compiles don't share a cache.
key: ${{ matrix.platform.target }}
- name: Cargo build
if: matrix.platform.cross == false
run: cargo build --workspace --all-targets
- name: Cargo build (cross compile, android)
if: contains(matrix.platform.target, 'android')
run: |
cargo install --version '<2.0.0' cargo-ndk
cargo ndk --android-platform 29 --target ${{ matrix.platform.target }} build --workspace --exclude ipfs-http
# exclude http on android because openssl
- name: Cargo build (cross compile, non-android)
if: contains(matrix.platform.target, 'android') == false && matrix.platform.cross == true
run: cargo build --workspace --exclude ipfs-http --target ${{ matrix.platform.target }}
# exclude http on other cross compilation targets because openssl
- name: Cargo test
if: matrix.platform.cross == false
run: cargo test --workspace
- name: Interop DHT tests with go-ipfs (linux)
if: matrix.platform.host == 'ubuntu-latest' && matrix.platform.cross == false
run: |
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
tar -xf go_ipfs.tar.gz
cargo test --features=test_go_interop dht
- name: "Conformance tests: cache config"
id: conformance-cache-config
if: matrix.platform.cross == false
run: |
echo "::set-output name=dir::$(npm config get cache)"
echo "::set-output name=ver::$(npm -v)"
- name: "Conformance tests: setup nodejs 14"
uses: actions/setup-node@v2
with:
node-version: '14'
- name: "Conformance tests: cache"
id: conformance-cache
if: matrix.platform.cross == false
uses: actions/cache@v2
with:
path: |
${{ steps.conformance-cache-config.outputs.dir }}
./conformance/node_modules
key: ${{ runner.os }}-conformance-${{ steps.conformance-cache-config.outputs.ver }} ${{ hashFiles('**/package-lock.json', '**/setup.sh', '**/*.patch') }}
- name: "Conformance tests: setup"
if: steps.conformance-cache.outputs.cache-hit != 'true' && matrix.platform.cross == false
run: ./setup.sh
shell: bash
working-directory: ./conformance
- name: "Conformance tests: run"
if: matrix.platform.cross == false
run: IPFS_RUST_EXEC=../target/debug/ipfs-http npm test
shell: bash
working-directory: ./conformance
# Work around for this issue: https://github.com/Swatinem/rust-cache/issues/26
- name: Fix cache permissions (macos)
if: matrix.platform.cross == false && matrix.platform.host == 'macos-latest'
run: sudo chown -R $(whoami):$(id -ng) ./target
lint-rust:
runs-on: ubuntu-latest
steps:
- name: Checkout sources
uses: actions/checkout@v2
- name: Install rust toolchain
uses: hecrj/[email protected]
with:
rust-version: stable
components: clippy, rustfmt
- name: Rust cache
uses: Swatinem/rust-cache@v1
- name: Cargo fmt
run: cargo fmt --all -- --check
- name: Cargo clippy
run: cargo clippy --all-targets --workspace -- -D warnings
# adapted from https://github.com/taiki-e/pin-project/blob/5878410863f5f25e21f7cba97b035501749850f9/.github/workflows/ci.yml#L136-L167
# further enchanced following solutions to
# https://github.com/bors-ng/bors-ng/issues/1115 -- bors now considers the
# skipped task a failure, or overrides the status for a task with a same name
# with the one which came later.
ci-success:
# this is read by bors
name: ci
if: github.event_name == 'push' && success()
needs:
- ci-matrix
- lint-rust
runs-on: ubuntu-latest
steps:
- name: Mark the job as a success
run: exit 0