Skip to content

Commit 4aa467f

Browse files
authored
Merge pull request #47 from jjs-dev/separate-test-build
Build tests in the separate job
2 parents 9a66b65 + 8f3b04f commit 4aa467f

File tree

2 files changed

+43
-29
lines changed

2 files changed

+43
-29
lines changed

.github/workflows/rust.yml

Lines changed: 39 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ name: Rust
22

33
on:
44
push:
5-
branches:
5+
branches:
66
- master
77
- staging
88
- trying
@@ -20,7 +20,7 @@ jobs:
2020
toolchain: stable
2121
components: rustfmt
2222
- name: Check formatting
23-
run: |
23+
run: |
2424
rm -rf .cargo
2525
cargo fmt --all -- --check
2626
clippy:
@@ -35,26 +35,51 @@ jobs:
3535
- name: Run clippy
3636
run: |
3737
cargo clippy --workspace -- -Dclippy::all -Dwarnings
38-
tests-linux:
38+
tests-linux-build:
39+
runs-on: 'ubuntu-20.04'
40+
steps:
41+
- uses: actions/checkout@v2
42+
- uses: actions-rs/toolchain@v1.0.6
43+
with:
44+
# nightly is used for cargo --out-dir option.
45+
toolchain: nightly
46+
override: true
47+
- name: Install targets
48+
run: |
49+
rustup target add x86_64-unknown-linux-musl
50+
- name: Build tests (musl)
51+
run: |
52+
mkdir -p ./tests/x86_64-unknown-linux-musl
53+
cargo build -p minion-tests -Zunstable-options --out-dir=./tests/x86_64-unknown-linux-musl --target=x86_64-unknown-linux-musl
54+
timeout-minutes: 5
55+
- uses: actions/upload-artifact@v2
56+
with:
57+
path: ./tests
58+
name: tests-linux
59+
retention-days: 2
60+
tests-linux-run:
3961
strategy:
4062
matrix:
41-
os:
42-
- 'ubuntu-20.04'
43-
- 'macos-latest'
63+
os:
64+
- "ubuntu-20.04"
65+
- "macos-latest"
4466
rust-target:
45-
- 'x86_64-unknown-linux-musl'
67+
- "x86_64-unknown-linux-musl"
4668
cgroups:
47-
- 'cgroup-v1'
48-
- 'cgroup-v2'
69+
- "cgroup-v1"
70+
- "cgroup-v2"
4971
runs-on: ${{ matrix.os }}
72+
needs:
73+
- tests-linux-build
5074
steps:
5175
- uses: actions/checkout@v2
52-
- uses: actions-rs/toolchain@v1.0.6
53-
with:
54-
toolchain: stable
55-
override: true
76+
- uses: actions/download-artifact@v1
77+
with:
78+
path: ./tests
79+
name: tests-linux
5680
- name: Test
57-
run: bash ci/linux.sh
81+
run: |
82+
bash ci/linux.sh
5883
timeout-minutes: 10
5984
env:
6085
CI_TARGET: ${{ matrix.rust-target }}
@@ -85,4 +110,3 @@ jobs:
85110
cargo check --workspace
86111
env:
87112
RUSTFLAGS: -Wunused-crate-dependencies --cfg minion_nightly
88-

ci/linux.sh

Lines changed: 4 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -29,17 +29,15 @@ Vagrant.configure("2") do |config|
2929
config.vm.box = "fedora/32-cloud-base"
3030
3131
config.vm.provider "virtualbox" do |vb|
32-
vb.memory = "900"
32+
vb.memory = "700"
3333
end
3434
end
3535
EOF
3636
top -l 1
3737
cat Vagrantfile
3838
sudo vagrant up
3939
echo "::group::Installing packages"
40-
sudo vagrant ssh --command "sudo dnf install -y gcc gcc-c++ strace zip"
41-
echo "::group::Installing rust"
42-
sudo vagrant ssh --command "curl https://sh.rustup.rs -sSf | sh -s -- -y --profile minimal --default-toolchain stable"
40+
sudo vagrant ssh --command "sudo dnf install -y strace zip"
4341
echo "::group::Entering VM"
4442
sudo vagrant ssh --command "bash -c 'cd /vagrant && CI_OS=$CI_OS CI_CGROUPS=$CI_CGROUPS CI_TARGET=$CI_TARGET CI_VM=1 bash ci/linux.sh'"
4543
echo "Host: pulling logs from VM"
@@ -52,24 +50,16 @@ EOF
5250
exit 0
5351
fi
5452

55-
rustup target add $CI_TARGET
56-
5753
if [[ $CI_CGROUPS == "cgroup-v2" ]]; then
5854
echo "::group::Some cgroup hacks"
5955
sudo mkdir /sys/fs/cgroup/minion
6056
echo "+cpu +memory +pids" | sudo tee /sys/fs/cgroup/cgroup.subtree_control
6157
echo "+cpu +memory +pids" | sudo tee /sys/fs/cgroup/minion/cgroup.subtree_control
6258
fi
6359

64-
echo "::group::Compiling tests"
65-
echo '[build]
66-
rustflags=["--cfg", "minion_ci"]' > .cargo/config
67-
68-
export RUSTC_BOOTSTRAP=1
69-
cargo build -p minion-tests -Zunstable-options --out-dir=./out --target=$CI_TARGET
70-
7160
echo "::group::Running tests"
72-
sudo --preserve-env ./out/minion-tests --trace
61+
chmod +x ./tests/$CI_TARGET/minion-tests
62+
sudo --preserve-env ./tests/$CI_TARGET/minion-tests --trace
7363
echo "::group::Finalize"
7464
echo "Current directory after running tests"
7565
ls .

0 commit comments

Comments
 (0)