Prevent thread crash when receiving activities reaching unimplemented… #38
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.* | |
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 |