-
Notifications
You must be signed in to change notification settings - Fork 0
70 lines (55 loc) · 1.78 KB
/
Copy pathrust-tests-workflow.yml
File metadata and controls
70 lines (55 loc) · 1.78 KB
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
name: Rust Tests
on:
workflow_call:
env:
CARGO_TERM_COLOR: always
RUST_BACKTRACE: 1
jobs:
tests:
name: Format, Clippy, Tests
runs-on: ubuntu-latest
container:
image: ghcr.io/bitshock-src/switchgear/ci-rust:1.0.0
options: -v /var/run/docker.sock:/var/run/docker.sock
volumes:
- /var/run/docker.sock:/var/run/docker.sock
steps:
- uses: actions/checkout@v4
- name: Check formatting
run: cargo fmt -- --check
- name: Start Docker Compose services
run: |
cd testing
nohup /bin/sh -c 'docker compose --env-file ./testing.env up -d --build --wait; touch ./compose-ready' > compose.log 2>&1 &
cd ..
- name: Rust cache
uses: Swatinem/rust-cache@v2
- name: Run clippy
run: cargo clippy -- -D warnings
- name: Compile tests
run: |
cargo test --no-run
- name: Wait for integration tests services
run: |
cd testing
MAX_WAIT=300
ELAPSED=0
while [ ! -f ./compose-ready ] && [ $ELAPSED -lt $MAX_WAIT ]; do
docker compose ps --format "table {{.Service}}\t{{.Status}}"
sleep 1
ELAPSED=$((ELAPSED + 1))
done
if [ ! -f ./compose-ready ]; then
echo "Docker compose did not complete in ${MAX_WAIT}s"
cat ./compose.log || true
exit 1
fi
. ./testing.env && docker network connect $SERVICES_NETWORK_NAME $(hostname)
cd ..
- name: Run tests
run: |
cp testing/testing.env ./testing.env
cargo test
- name: Stop Docker Compose services
if: always()
run: docker compose --env-file testing/testing.env -f testing/docker-compose.yml down -v