Skip to content

Commit 9864ed8

Browse files
author
Joonas Koivunen
authored
Merge pull request #732 from Mirko-von-Leipzig/ci_speedup
CI speedup
2 parents 3904304 + bc4c812 commit 9864ed8

File tree

2 files changed

+178
-31
lines changed

2 files changed

+178
-31
lines changed

.github/workflows/ci.yml

Lines changed: 145 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -2,19 +2,16 @@ name: CI
22

33
# limit ci building to pushes to master not to get twice the notification email
44
# from github.
5-
#
6-
# if you want to test your branch on your fork, just replace the 'branches'
7-
# filter below for 'push' with the one for 'pull_request' temporarily and drop
8-
# the commit when creating the PR.
95
on:
6+
workflow_dispatch:
107
push:
118
branches:
129
- 'master'
1310
pull_request:
1411
branches: '*'
1512

1613
jobs:
17-
build:
14+
interledger:
1815
env:
1916
RUST_LOG: "interledger=trace"
2017
RUST_BACKTRACE: "full"
@@ -35,6 +32,9 @@ jobs:
3532
rust-version: stable
3633
components: clippy, rustfmt
3734

35+
- name: Cache
36+
uses: Swatinem/rust-cache@v1
37+
3838
- name: Build
3939
run: cargo build --all-features --all-targets
4040

@@ -54,45 +54,164 @@ jobs:
5454
- name: Test
5555
run: timeout 15m cargo test --all --all-features
5656

57-
- name: Test with subset of features (interledger-packet)
58-
run: |
59-
timeout 15m cargo test -p interledger-packet
60-
timeout 15m cargo test -p interledger-packet --features strict
61-
timeout 15m cargo test -p interledger-packet --features roundtrip-only
57+
interledger-packet:
58+
env:
59+
RUST_LOG: "interledger=trace"
60+
RUST_BACKTRACE: "full"
6261

63-
- name: Test with subset of features (interledger-btp)
64-
run: |
65-
timeout 15m cargo test -p interledger-btp
66-
timeout 15m cargo test -p interledger-btp --features strict
62+
runs-on: ubuntu-latest
6763

68-
- name: Test with subset of features (interledger-stream)
69-
run: |
70-
timeout 15m cargo test -p interledger-stream
71-
timeout 15m cargo test -p interledger-stream --features strict
72-
timeout 15m cargo test -p interledger-stream --features roundtrip-only
64+
steps:
65+
- name: Checkout sources
66+
uses: actions/checkout@v2
67+
68+
- name: Install rust toolchain
69+
uses: hecrj/setup-rust-action@v1.3.4
70+
with:
71+
rust-version: stable
72+
73+
- name: Cache
74+
uses: Swatinem/rust-cache@v1
75+
76+
- name: Test
77+
run: timeout 15m cargo test -p interledger-packet
78+
- name: Test --features strict
79+
run: timeout 15m cargo test -p interledger-packet --features strict
80+
- name: Test --features roundtrip-only
81+
run: timeout 15m cargo test -p interledger-packet --features roundtrip-only
82+
83+
interledger-stream:
84+
env:
85+
RUST_LOG: "interledger=trace"
86+
RUST_BACKTRACE: "full"
87+
88+
runs-on: ubuntu-latest
89+
90+
steps:
91+
- name: Checkout sources
92+
uses: actions/checkout@v2
93+
94+
- name: Install rust toolchain
95+
uses: hecrj/setup-rust-action@v1.3.4
96+
with:
97+
rust-version: stable
98+
99+
- name: Cache
100+
uses: Swatinem/rust-cache@v1
101+
102+
- name: Test
103+
run: timeout 15m cargo test -p interledger-stream
104+
- name: Test --features strict
105+
run: timeout 15m cargo test -p interledger-stream --features strict
106+
- name: Test --features roundtrip-only
107+
run: timeout 15m cargo test -p interledger-stream --features roundtrip-only
108+
109+
interledger-btp:
110+
env:
111+
RUST_LOG: "interledger=trace"
112+
RUST_BACKTRACE: "full"
113+
114+
runs-on: ubuntu-latest
115+
116+
steps:
117+
- name: Checkout sources
118+
uses: actions/checkout@v2
119+
120+
- name: Install rust toolchain
121+
uses: hecrj/setup-rust-action@v1.3.4
122+
with:
123+
rust-version: stable
124+
125+
- name: Cache
126+
uses: Swatinem/rust-cache@v1
127+
128+
- name: Test
129+
run: timeout 15m cargo test -p interledger-btp
130+
- name: Test --features strict
131+
run: timeout 15m cargo test -p interledger-btp --features strict
132+
133+
build:
134+
# Repo requires a `build` job to succeed in order to merge into master.
135+
# A step and runs-on is required for a job to be valid.
136+
needs: [interledger, interledger-packet, interledger-stream, interledger-btp]
137+
runs-on: ubuntu-latest
138+
steps:
139+
- name: Success
140+
run: echo "Success"
141+
142+
settlement-engines:
143+
# This job builds the ethereum-settlement-engine required by `test-md`.
144+
# A separate job to enable dependency caching.
145+
runs-on: ubuntu-latest
146+
147+
steps:
148+
- name: Checkout sources
149+
uses: actions/checkout@v2
150+
with:
151+
repository: interledger-rs/settlement-engines
152+
ref: master
153+
154+
- name: Install rust toolchain
155+
uses: hecrj/setup-rust-action@v1.3.4
156+
with:
157+
rust-version: stable
158+
159+
- name: Cache
160+
uses: Swatinem/rust-cache@v1
161+
162+
- name: Build
163+
run: cargo build --bin ilp-settlement-ethereum
164+
165+
- name: Upload settlement-engine artifact
166+
uses: actions/upload-artifact@v2
167+
with:
168+
name: settlement-engine
169+
path: target/debug/ilp-settlement-ethereum
73170

74171
test-md:
172+
env:
173+
RUST_LOG: "interledger=trace"
174+
RUST_BACKTRACE: "full"
175+
176+
needs: settlement-engines
177+
75178
runs-on: ubuntu-latest
179+
76180
steps:
77181
- name: Checkout sources
78182
uses: actions/checkout@v2
79183

80-
- name: Install node
81-
uses: actions/setup-node@v2
184+
- name: Install rust toolchain
185+
uses: hecrj/setup-rust-action@v1.3.4
82186
with:
83-
node-version: 'v12.18.4'
187+
rust-version: stable
188+
189+
- name: Cache
190+
uses: Swatinem/rust-cache@v1
191+
192+
- name: Build binaries
193+
run: |
194+
mkdir -p ~/.interledger/bin
195+
cargo build --bin ilp-node --bin ilp-cli
196+
mv target/debug/ilp-node ~/.interledger/bin
197+
mv target/debug/ilp-cli ~/.interledger/bin
198+
199+
- name: Download settlement engine artifact
200+
uses: actions/download-artifact@v2
201+
with:
202+
name: settlement-engine
203+
path: ~/.interledger/bin
84204

85205
- name: Install dependencies
86206
run: |
87207
sudo apt-get update
88208
sudo apt-get install -y redis-server redis-tools libssl-dev
89209
90-
# install components (ganache-cli ilp-settlement-xrp conventional-changelog-cli)
91-
npm install -g ganache-cli ilp-settlement-xrp conventional-changelog-cli
210+
# install components (ganache-cli ilp-settlement-xrp)
211+
npm install -g ganache-cli ilp-settlement-xrp
92212
93213
- name: Test
94-
run: |
95-
scripts/run-md-test.sh '^.*$' 1
214+
run: scripts/run-md-test.sh '^.*$' 2
96215

97216
- name: 'Store artifacts'
98217
if: ${{ failure() }}

scripts/run-md-test.sh

Lines changed: 33 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,36 @@
11
#!/bin/bash
2+
#
3+
# Runs the examples listed in the READMEs from `examples/*/README.md`.
4+
#
5+
# Requires additional runtime dependencies as listed in those READMEs.
6+
#
7+
# The code snippets and comments are parsed by `parse-md.sh` and can
8+
# essentially be split into two sections:
9+
# 1: binary aquisition
10+
# 2: test execution
11+
#
12+
# (1) is controlled by the `SOURCE_MODE` parameter in the READMEs and
13+
# is set by the second flag passed to this script ($2).
14+
#
15+
# Has two parameters:
16+
# $1 = test name filter
17+
# $2 = source mode flag
18+
# 1: build binaries from source
19+
# 2: use existing binaries (or download binaries if they don't exist)
20+
# *: download binaries (replaces existing binaries)
21+
222

23+
# $1: source mode flag
24+
# 2: don't clear binaries
25+
# *: clear binaries
326
function clear_environment() {
427
clear_logs
528
free_ports
629
clear_redis_file
7-
clear_binaries
30+
31+
if [ ! $1 -eq 2 ]; then
32+
clear_binaries
33+
fi
834
}
935

1036
function clear_logs() {
@@ -39,7 +65,7 @@ function clear_binaries() {
3965
}
4066

4167
# $1 = target directory
42-
# $2 = source mode in [01]
68+
# $2 = source mode
4369
# $3 = test name filter
4470
#
4571
# test_example examples/eth-settlement 0
@@ -52,11 +78,13 @@ function test_example() {
5278
pushd $target_directory > /dev/null
5379
if [ $source_mode -eq 1 ]; then
5480
printf "\e[33;1mTesting \"${target_name}\" on source mode. [%d/%d]\e[m\n" "$((TESTING_INDEX + 1))" "${TESTS_TOTAL}"
55-
clear_environment; TEST_MODE=1 SOURCE_MODE=1 $RUN_MD .
81+
clear_environment $2;
82+
TEST_MODE=1 SOURCE_MODE=1 $RUN_MD .
5683
result=$?
5784
else
5885
printf "\e[33;1mTesting \"${target_name}\" on binary mode. [%d/%d]\e[m\n" "$((TESTING_INDEX + 1))" "${TESTS_TOTAL}"
59-
clear_environment; TEST_MODE=1 $RUN_MD .
86+
clear_environment $2;
87+
TEST_MODE=1 $RUN_MD .
6088
result=$?
6189
fi
6290
mkdir -p ${LOG_DIR}/${target_name}
@@ -88,7 +116,7 @@ function add_example_tests() {
88116
}
89117

90118
# $1 = test name filter
91-
# $2 = source mode filter
119+
# $2 = source mode flag
92120

93121
BASE_DIR=$(cd $(dirname $0); pwd)
94122
RUN_MD=$BASE_DIR/run-md.sh

0 commit comments

Comments
 (0)