-
-
Notifications
You must be signed in to change notification settings - Fork 58
173 lines (165 loc) · 5.47 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
163
164
165
166
167
168
169
170
171
172
173
name: CI # Continuous Integration
on:
push:
branches:
- main
pull_request:
jobs:
test:
name: Test Suite (${{ matrix.os-name }})
runs-on: ${{ matrix.os }}
env:
CARGO_TARGET_I586_UNKNOWN_LINUX_MUSL_RUSTFLAGS: -C target-feature=+sse2
strategy:
matrix:
include:
- os: macos-latest
os-name: mac
features: default
- os: ubuntu-latest
os-name: ubuntu
features: default
- os: windows-latest
os-name: windows
features: default
- os: ubuntu-latest
os-name: android
target: aarch64-linux-android
features: termux --no-default-features
- os: ubuntu-latest
os-name: ish
target: i686-unknown-linux-musl
features: default
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@nightly
with:
targets: ${{ matrix.target }}
- uses: Swatinem/rust-cache@v2
- name: Run tests (cross)
if: ${{ matrix.target != null }}
uses: houseabsolute/actions-rust-cross@v0
with:
command: test
target: ${{ matrix.target }}
args: "--features ${{ matrix.features }} --workspace"
cross-version: 7b79041c9278769eca57fae10c74741f5aa5c14b
- name: Run tests (default)
if: ${{ matrix.target == null }}
run: cargo test --features ${{ matrix.features }} --workspace
docker:
name: Test Docker
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Set up Docker CLI
uses: docker/setup-buildx-action@v3
- name: Build Docker image
uses: docker/build-push-action@v5
with:
push: false
context: .
cache-from: type=gha
cache-to: type=gha,mode=max
tags: rainfrog_test
outputs: type=docker
- name: init db for docker test
run: |
make db-up
sleep 5 # wait for db container
- name: docker run postgres
run: |
docker run -dit --name rainfrog_test_postgres \
--add-host host.docker.internal:host-gateway \
-e db_driver="postgres" \
-e username="root" \
-e password="password" \
-e hostname="host.docker.internal" \
-e db_port="5499" \
-e db_name="rainfrog" rainfrog_test
sleep 5 # wait for container
- name: check postgres container status
run: |
container_status=$(docker ps -f name=rainfrog_test_postgres --format "{{.Status}}")
if [[ "$container_status" == "Up"* ]]; then
echo "container started"
else
echo "container did not start"
echo "logs: "
docker logs -t rainfrog_test_postgres
exit 1
fi
- name: docker run mysql
run: |
docker run -dit --name rainfrog_test_mysql \
--add-host host.docker.internal:host-gateway \
-e db_driver="mysql" \
-e username="root" \
-e password="password" \
-e hostname="host.docker.internal" \
-e db_port="3317" \
-e db_name="rainfrog" rainfrog_test
sleep 5 # wait for container
- name: check mysql container status
run: |
container_status=$(docker ps -f name=rainfrog_test_mysql --format "{{.Status}}")
if [[ "$container_status" == "Up"* ]]; then
echo "container started"
else
echo "container did not start"
echo "logs: "
docker logs -t rainfrog_test_mysql
exit 1
fi
- name: docker run sqlite
run: |
docker run -dit --name rainfrog_test_sqlite \
--add-host host.docker.internal:host-gateway \
-v /home/runner/work/rainfrog/rainfrog/dev/rainfrog.sqlite3:/rainfrog.sqlite3 \
rainfrog_test \
rainfrog --url sqlite:///rainfrog.sqlite3
sleep 5 # wait for container
- name: check sqlite container status
run: |
container_status=$(docker ps -f name=rainfrog_test_sqlite --format "{{.Status}}")
if [[ "$container_status" == "Up"* ]]; then
echo "container started"
else
echo "container did not start"
echo "logs: "
docker logs -t rainfrog_test_sqlite
exit 1
fi
rustfmt:
name: Rustfmt
runs-on: ubuntu-latest
env:
CARGO_TARGET_I586_UNKNOWN_LINUX_MUSL_RUSTFLAGS: -C target-feature=+sse2
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@nightly
with:
components: rustfmt
- uses: Swatinem/rust-cache@v2
- name: Check formatting
run: cargo fmt --all --check
clippy:
name: Clippy
runs-on: ubuntu-latest
env:
CARGO_TARGET_I586_UNKNOWN_LINUX_MUSL_RUSTFLAGS: -C target-feature=+sse2
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@nightly
with:
components: clippy
- uses: Swatinem/rust-cache@v2
- name: Clippy check
run: cargo clippy --all-targets --all-features --workspace -- -D warnings