Skip to content

Commit 5bed132

Browse files
sypharJoshua Nelson
authored and
Joshua Nelson
committed
CI: split build-tests into separate job
1 parent 7f5ebcf commit 5bed132

File tree

1 file changed

+69
-8
lines changed

1 file changed

+69
-8
lines changed

.github/workflows/ci.yml

+69-8
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,8 @@ env:
1010
RUST_BACKTRACE: 1
1111

1212
jobs:
13-
test:
14-
name: Test
13+
build:
1514
runs-on: ubuntu-latest
16-
1715
steps:
1816
- uses: actions/checkout@master
1917
- id: install
@@ -25,6 +23,36 @@ jobs:
2523
- name: restore build & cargo cache
2624
uses: Swatinem/rust-cache@v1
2725

26+
- name: Build
27+
run: cargo build --workspace --locked
28+
29+
- name: compile test binaries
30+
run: |
31+
cargo test --no-run
32+
mkdir ./test-binaries/
33+
find ./target \
34+
-name "docs_rs*" \
35+
-executable -type f \
36+
-exec cp {} ./test-binaries/ \;
37+
38+
- name: set up test binaries to cache
39+
uses: actions/cache@v2
40+
with:
41+
path: "./test-binaries"
42+
key: test-binaries-${{ github.sha }}
43+
44+
test:
45+
runs-on: ubuntu-latest
46+
needs: build
47+
steps:
48+
- uses: actions/checkout@master
49+
50+
- name: get test binaries from cache
51+
uses: actions/cache@v2
52+
with:
53+
path: "./test-binaries"
54+
key: test-binaries-${{ github.sha }}
55+
2856
- name: Launch postgres and min.io
2957
run: |
3058
cp .env.sample .env
@@ -36,17 +64,50 @@ jobs:
3664
# Make sure the database is actually working
3765
psql "${CRATESFYI_DATABASE_URL}"
3866
39-
- name: Build
40-
run: cargo build --workspace --locked
67+
- name: run tests
68+
shell: bash
69+
run: |
70+
for f in ./test-binaries/*; do
71+
echo "running $f"
72+
$f || exit 1
73+
done
4174
42-
- name: fast tests
43-
run: cargo test --workspace --locked
75+
- name: Clean up the database
76+
run: docker-compose down --volumes
77+
78+
build_tests:
79+
runs-on: ubuntu-latest
80+
needs: build
81+
82+
steps:
83+
- uses: actions/checkout@master
84+
85+
- name: get test binaries from cache
86+
uses: actions/cache@v2
87+
with:
88+
path: "./test-binaries"
89+
key: test-binaries-${{ github.sha }}
90+
91+
- name: Launch postgres and min.io
92+
run: |
93+
cp .env.sample .env
94+
. .env
95+
mkdir -p ${CRATESFYI_PREFIX}/public-html
96+
docker-compose up -d db s3
97+
# Give the database enough time to start up
98+
sleep 5
99+
# Make sure the database is actually working
100+
psql "${CRATESFYI_DATABASE_URL}"
44101
45102
- name: slow tests
46103
env:
47104
DOCSRS_INCLUDE_DEFAULT_TARGETS: true
48105
DOCSRS_DOCKER_IMAGE: ghcr.io/rust-lang/crates-build-env/linux-micro
49-
run: cargo test --workspace --locked -- --ignored
106+
run: |
107+
for f in ./test-binaries/*; do
108+
echo "running $f"
109+
$f --ignored || exit 1
110+
done
50111
51112
- name: Clean up the database
52113
run: docker-compose down --volumes

0 commit comments

Comments
 (0)