162 lines (135 loc) · 3.98 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
name: CI
on:
push:
pull_request:
schedule:
- cron: "0 0 * * *"
env:
RUST_BACKTRACE: 1
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@master
- id: install
uses: actions-rs/toolchain@v1
with:
toolchain: stable
override: true
- name: restore build & cargo cache
uses: Swatinem/rust-cache@v1
- name: Build
run: cargo build --workspace --locked
- name: compile test binaries
run: |
cargo test --no-run
mkdir ./test-binaries/
find ./target \
-name "docs_rs*" \
-executable -type f \
-exec cp {} ./test-binaries/ \;
- uses: actions/upload-artifact@v2
name: set up test binaries to cache
with:
name: test-binaries-${{ github.sha }}
path: ./test-binaries/
retention-days: 1
test:
runs-on: ubuntu-latest
needs: build
steps:
- uses: actions/checkout@master
- name: get test binaries from cache
uses: actions/download-artifact@v2
with:
name: test-binaries-${{ github.sha }}
path: ./test-binaries/
- name: Launch postgres and min.io
run: |
cp .env.sample .env
. .env
mkdir -p ${DOCSRS_PREFIX}/public-html
docker-compose up -d db s3
# Give the database enough time to start up
sleep 5
# Make sure the database is actually working
psql "${DOCSRS_DATABASE_URL}"
- name: run tests
shell: bash
run: |
for f in ./test-binaries/*; do
echo "running $f"
chmod +x $f # GH action artifacts don't handle permissions
$f || exit 1
done
- name: Run GUI tests
run: ./dockerfiles/run-gui-tests.sh
- name: Clean up the database
run: docker-compose down --volumes
steps:
- uses: actions/checkout@master
build_tests:
runs-on: ubuntu-latest
needs: build
steps:
- uses: actions/checkout@master
- name: get test binaries from cache
uses: actions/download-artifact@v2
with:
name: test-binaries-${{ github.sha }}
path: ./test-binaries/
- name: Launch postgres and min.io
run: |
cp .env.sample .env
. .env
mkdir -p ${DOCSRS_PREFIX}/public-html
docker-compose up -d db s3
# Give the database enough time to start up
sleep 5
# Make sure the database is actually working
psql "${DOCSRS_DATABASE_URL}"
- name: slow tests
env:
DOCSRS_INCLUDE_DEFAULT_TARGETS: true
DOCSRS_DOCKER_IMAGE: ghcr.io/rust-lang/crates-build-env/linux-micro
run: |
for f in ./test-binaries/*; do
echo "running $f"
chmod +x $f # GH action artifacts don't handle permissions
# run build-tests. Limited to one thread since we don't support parallel builds.
$f --ignored --test-threads=1 || exit 1
done
- name: Clean up the database
run: docker-compose down --volumes
fmt:
name: Rustfmt
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@master
- id: install
uses: actions-rs/toolchain@v1
with:
toolchain: stable
override: true
components: rustfmt
- uses: actions-rs/cargo@v1
with:
command: fmt
args: -- --check
clippy:
name: Clippy
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@master
- id: install
uses: actions-rs/toolchain@v1
with:
toolchain: stable
override: true
components: clippy
- name: restore build & cargo cache
uses: Swatinem/rust-cache@v1
- uses: actions-rs/cargo@v1
with:
command: clippy
args: --all-features --all-targets --workspace --locked -- -D warnings