test #25
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# This workflow loosely replicates the logic in .woodpecker.yml | |
name: Run Lemmy tests | |
on: | |
push: | |
branches: | |
- lw-0.* | |
- lw-test | |
env: | |
POSTGRES_USER: lemmy | |
POSTGRES_PASSWORD: password | |
DATABASE_URL: postgres://lemmy:password@database:5432/lemmy | |
CI_RUST_VERSION: "1.75" | |
CARGO_HOME: .cargo_home | |
jobs: | |
test: | |
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: Cargo home cache | |
uses: actions/cache@v4 | |
with: | |
path: ${{ env.CARGO_HOME }} | |
key: rust-${{ env.CI_RUST_VERSION }}-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" | |
cargo +nightly install cargo-machete | |
cargo +nightly machete --skip-target-dir | |
mv -v "$CARGO_HOME" "$ORIG_CARGO_HOME" && rmdir target | |
- name: Ignored files | |
uses: docker://alpine:3 | |
with: | |
args: ./.github/scripts/ignored-files.sh | |
build: | |
needs: | |
- test | |
runs-on: ubuntu-latest | |
services: | |
database: | |
image: postgres:15.2-alpine | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
with: | |
submodules: recursive | |
show-progress: "false" | |
- name: Cargo home cache | |
uses: actions/cache@v4 | |
with: | |
path: ${{ env.CARGO_HOME }} | |
key: rust-${{ env.CI_RUST_VERSION }}-cargo-home | |
- name: Set rust version to ${{ env.CI_RUST_VERSION }} | |
run: rustup default "$CI_RUST_VERSION" | |
- 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 | |
with: | |
entrypoint: /bin/sh | |
args: ./.github/scripts/check-diesel-schema.sh | |
- name: check_diesel_migration_revertable | |
uses: docker://willsquire/diesel-cli | |
with: | |
entrypoint: /bin/sh | |
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 | |
run: cargo test --workspace --no-fail-fast | |
- name: Run federation tests | |
uses: docker://node:20-bookworm-slim | |
env: | |
DO_WRITE_HOSTS_FILE: "1" | |
with: | |
args: ./.github/scripts/run-federation-tests.sh |