forked from LemmyNet/lemmy
-
Notifications
You must be signed in to change notification settings - Fork 0
176 lines (151 loc) · 5.75 KB
/
test.yaml
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
174
175
176
# This workflow loosely replicates the logic in .woodpecker.yml
name: Run Lemmy tests
on:
push:
branches:
- lw-0.*
- lw-test
env:
CI_RUST_VERSION: "1.75"
CARGO_HOME: .cargo_home
CARGO_HOME_NIGHTLY: .cargo_home_nightly
POSTGRES_USER: lemmy
POSTGRES_PASSWORD: password
HOST_DATABASE_URL: postgres://lemmy:password@127.0.0.1:5432/lemmy
CONTAINER_DATABASE_URL: postgres://lemmy:password@database:5432/lemmy
jobs:
test:
services:
database:
image: postgres:15.2-alpine
env:
POSTGRES_USER: lemmy
POSTGRES_PASSWORD: password
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
ports:
- 5432:5432
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
submodules: recursive
show-progress: "false"
- name: Prettier
uses: docker://tmknom/prettier:3.0.0
with:
# args is rather janky for this, as it doesn't deal well with quotes
# and multiple lines, so it's easier to just put more complex
# commands in a custom script.
args: ./.github/scripts/prettier.sh
- name: TOML fmt
uses: docker://tamasfe/taplo:0.8.1
with:
args: format --check
- name: SQL fmt
uses: docker://backplane/pgformatter:latest
with:
args: ./scripts/sql_format_check.sh
- name: Get date for cache key
id: get-date
run: |
echo "date=$(/bin/date -u "+%Y%m%d")" >> $GITHUB_OUTPUT
- name: Cargo home cache for Rust ${{ env.CI_RUST_VERSION }}
uses: actions/cache@v4
with:
path: ${{ env.CARGO_HOME }}
key: rust-cargo-home-${{ env.CI_RUST_VERSION }}-${{ hashFiles('**/Cargo.toml', '**/Cargo.lock') }}
restore-keys: |
rust-cargo-home-${{ env.CI_RUST_VERSION }}-
rust-cargo-home-
- name: Cargo home cache for Rust nightly
uses: actions/cache@v4
with:
path: ${{ env.CARGO_HOME_NIGHTLY }}
key: rust-cargo-home-nightly-${{ hashFiles('**/Cargo.toml', '**/Cargo.lock') }}
restore-keys: |
rust-cargo-home-nightly-
rust-cargo-home-
# https://github.com/rust-lang/rustup/issues/2886
- name: Disable rustup self update
run: rustup set auto-self-update disable
- name: Set Rust version to ${{ env.CI_RUST_VERSION }}
run: rustup default "$CI_RUST_VERSION"
- name: Install Rust nightly toolchain
run: rustup toolchain install nightly
- name: Cargo fmt
run: |
rustup component add --toolchain nightly rustfmt
cargo +nightly fmt -- --check
# Unlike Lemmy's woodpecker, we have persistent CARGO_HOME. This causes
# some issues with machete, but it doesn't have a way to exclude
# arbitrary paths, so we cheat by temporarily moving it into the
# target dir.
# https://github.com/bnjbvr/cargo-machete/issues/49
- name: Cargo machete
env:
CARGO_HOME: target/${{ env.CARGO_HOME }}
ORIG_CARGO_HOME: ${{ env.CARGO_HOME }}
run: |
test -d "$ORIG_CARGO_HOME" && mkdir target && mv -v "$ORIG_CARGO_HOME" "$CARGO_HOME" && mv -v "$CARGO_HOME_NIGHTLY" "target/$CARGO_HOME_NIGHTLY"
cargo +nightly install cargo-machete
cargo +nightly machete --skip-target-dir
mv -v "$CARGO_HOME" "$ORIG_CARGO_HOME" && mv -v "target/$CARGO_HOME_NIGHTLY" "$CARGO_HOME_NIGHTLY" && rmdir target
- name: Ignored files
uses: docker://alpine:3
with:
args: ./.github/scripts/ignored-files.sh
- name: check_api_common_default_features
run: cargo check --package lemmy_api_common
- name: lemmy_api_common_doesnt_depend_on_diesel
run: |
! cargo tree -p lemmy_api_common --no-default-features -i diesel
- name: lemmy_api_common_works_with_wasm
run: |
rustup target add wasm32-unknown-unknown
cargo check --target wasm32-unknown-unknown -p lemmy_api_common
- name: check_defaults_hjson_updated
env:
LEMMY_CONFIG_LOCATION: ./config/config.hjson
run: |
./scripts/update_config_defaults.sh config/defaults_current.hjson
diff config/defaults.hjson config/defaults_current.hjson
- name: Check diesel schema
uses: docker://willsquire/diesel-cli
env:
DATABASE_URL: ${{ env.CONTAINER_DATABASE_URL }}
with:
entrypoint: /bin/bash
args: ./.github/scripts/check-diesel-schema.sh
- name: Check diesel migration revertable
uses: docker://willsquire/diesel-cli
env:
DATABASE_URL: ${{ env.CONTAINER_DATABASE_URL }}
with:
entrypoint: /bin/bash
args: ./.github/scripts/check-diesel-migration-revertable.sh
- name: Cargo fmt
run: |
rustup component add clippy
cargo clippy --workspace --tests --all-targets --features console -- -D warnings
- name: Cargo build
run: |
cargo build
mv target/debug/lemmy_server target/lemmy_server
- name: Cargo test
env:
RUST_BACKTRACE: "1"
LEMMY_CONFIG_LOCATION: ../../config/config.hjson
LEMMY_DATABASE_URL: ${{ env.HOST_DATABASE_URL }}
run: cargo test --workspace --no-fail-fast
- name: Run federation tests
uses: docker://node:20-bookworm-slim
env:
DO_WRITE_HOSTS_FILE: "1"
LEMMY_DATABASE_URL: postgres://${{ env.POSTGRES_USER }}:${{ env.POSTGRES_PASSWORD }}@database:5432
with:
args: ./.github/scripts/run-federation-tests.sh