-
-
Notifications
You must be signed in to change notification settings - Fork 3
132 lines (107 loc) · 3.86 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
name: CI
on: [push, pull_request]
jobs:
code_quality:
name: Code quality
runs-on: ubuntu-22.04
steps:
- name: Checkout source code
uses: actions/checkout@v3
- name: Install rust toolchain
uses: dtolnay/rust-toolchain@stable
with:
components: clippy, rustfmt
- uses: Swatinem/rust-cache@v2
- name: Install latest just release
uses: taiki-e/install-action@just
- name: Install latest dprint release
uses: taiki-e/install-action@dprint
- name: Check MSRV
run: |
cargo_msrv=$(sed -n 's/rust-version = "\(.*\)"/\1/p' Cargo.toml)
clippy_msrv=$(sed -n 's/msrv = "\(.*\)"/\1/p' clippy.toml)
if [ "$cargo_msrv" != "$clippy_msrv" ]; then
echo "MSRV do not match"
exit 1
else
echo "MSRV do match"
fi
- name: Ensure `fmt` has been run
run: just fmt-check
- name: Run clippy
env:
SQLX_OFFLINE: true
run: just lint
msrv:
name: Minimum supported rust version
runs-on: ubuntu-22.04
steps:
- name: Checkout source code
uses: actions/checkout@v3
- name: Install rust toolchain (v${{ env.MIN_SUPPORTED_RUST_VERSION }})
uses: dtolnay/rust-toolchain@master
with:
toolchain: ${{ env.MIN_SUPPORTED_RUST_VERSION }}
- uses: Swatinem/rust-cache@v2
- name: Install latest nextest release
uses: taiki-e/install-action@nextest
- name: Install latest just release
uses: taiki-e/install-action@just
- name: Prepare the environment variables
run: |
cp .example.env .env
- name: Prepare the database
env:
PGPASSWORD: secret
run: |
docker-compose --file ./tests/docker-compose.yml run --detach -p 5432:5432 --name postgres_db postgres_db
# Wait until the DB is up
docker exec postgres_db bash -c "until pg_isready; do sleep 1; done"
# Check DB version
docker exec postgres_db psql -h localhost -p 5432 -U durin --version
- name: Run tests
env:
DATABASE_URL: postgres://durin:SpeakFriendAndEnter@localhost:5432/tin
run: just test
build:
name: Build for ${{ matrix.build }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
include:
- { build: linux-gnu, os: ubuntu-22.04, target: x86_64-unknown-linux-gnu }
# `sfackler/rust-openssl` needs more effort to compile to musl
# - { build: linux-musl, os: ubuntu-22.04, target: x86_64-unknown-linux-musl }
- { build: win-gnu, os: windows-2022, target: x86_64-pc-windows-gnu }
- { build: win-msvc, os: windows-2022, target: x86_64-pc-windows-msvc }
- { build: win32-msvc, os: windows-2022, target: i686-pc-windows-msvc }
- { build: macos, os: macos-12 , target: x86_64-apple-darwin }
steps:
- name: Checkout source code
uses: actions/checkout@v3
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@stable
with:
target: ${{ matrix.target }}
- name: Show version information
shell: bash
run: |
gcc --version || true
rustup -V
rustup toolchain list
rustup default
cargo -V
rustc -V
- name: Install musl-tools
if: matrix.target == 'x86_64-unknown-linux-musl'
run: |
sudo apt-get update
sudo apt-get install -y --no-install-recommends \
--allow-unauthenticated musl-tools
- name: Rust cache
uses: Swatinem/rust-cache@v2
with:
key: ${{ matrix.os }}-${{ matrix.target }}
- name: Build
run: cargo build --release --locked --target ${{ matrix.target }}