Skip to content

feat: modview

feat: modview #14667

Workflow file for this run

name: CI
on:
push:
branches: [main]
pull_request:
types: [opened, synchronize]
merge_group:
types: [checks_requested]
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: ${{ github.ref != 'refs/heads/main' && github.ref != 'refs/heads/prod' }}
env:
TURBO_TELEMETRY_DISABLED: 1
pnpm_config_color: always
INTERNAL: ${{ github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == github.repository }}
jobs:
build:
name: Lint and Test
runs-on: ${{ (github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == github.repository) && 'namespace-profile-modrinth-turbo' || 'ubuntu-latest' }}
env:
# Color the output of Node tools run by Turborepo tasks in GitHub Actions logs
FORCE_COLOR: 3
# Make cargo nextest successfully ignore projects without tests
NEXTEST_NO_TESTS: pass
# Fail on warnings in CI
# (but don't do this in the root `Cargo.toml`,
# since we don't want warnings to become errors
# while developing)
RUSTFLAGS: -Dwarnings
# Redis config for tests
REDIS_TOPOLOGY: cluster
REDIS_CONNECTION_TYPE: multiplexed
REDIS_URL: redis://127.0.0.1:7000,redis://127.0.0.1:7001,redis://127.0.0.1:7002,redis://127.0.0.1:7003,redis://127.0.0.1:7004,redis://127.0.0.1:7005
# Avoid stack overflows in tests
RUST_MIN_STACK: 134217728
steps:
- name: Check out code
if: env.INTERNAL != 'true'
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
fetch-depth: 0
filter: blob:none
- name: Check out code (Namespace)
if: env.INTERNAL == 'true'
uses: namespacelabs/nscloud-checkout-action@66f2dc6f6c42a8ac6c4e53473c4840006822831e # v9.0.1
with:
fetch-depth: 2
# Fork PRs start services later, only if the labrinth tests need them. The internal check
# lives in the command because `wait` steps cannot be skipped with `if`.
- name: Start services
id: services
background: true
run: |
if [ "$INTERNAL" = 'true' ]; then
docker compose --profile clustered-redis up --wait
fi
- name: Setup Node
uses: actions/setup-node@820762786026740c76f36085b0efc47a31fe5020 # v7.0.0
with:
node-version-file: .nvmrc
- name: Enable Corepack
run: corepack enable
- name: Set up caches
if: env.INTERNAL == 'true'
uses: namespacelabs/nscloud-cache-action@1124a6f3ce44e5cf84cc22111530961f4d2a15f9 # v1.7.0
with:
cache: |
rust
pnpm
apt
- name: Set up Turborepo caching
if: env.INTERNAL == 'true'
uses: namespace-actions/setup-turbocache@a94b84c111f2cc781a4a83c4d07a99f2c63e33d6 # v0.0.3
- name: Install apt dependencies
run: |
sudo apt-get update
sudo apt-get install -y cmake libcurl4-openssl-dev libwebkit2gtk-4.1-dev libayatana-appindicator3-dev librsvg2-dev
- name: Setup Rust toolchain
uses: actions-rust-lang/setup-rust-toolchain@166cdcfd11aee3cb47222f9ddb555ce30ddb9659 # v1.17.0
with:
rustflags: ''
components: clippy, rustfmt
cache: false
- name: Setup mold
uses: rui314/setup-mold@9c9c13bf4c3f1adef0cc596abc155580bcb04444 # v1 / Mold 2.41.0
- name: Setup binstall
uses: cargo-bins/cargo-binstall@ead08b90bd7b2e6d81963fb9cf0b7239f66d5db4 # v1.21.0
- name: Setup nextest
run: cargo binstall --no-confirm --secure --locked cargo-nextest@0.9.133
# cargo-binstall does not have pre-built binaries for sqlx-cli, so we fall
# back to a cached cargo install
- name: Setup cargo-sqlx
uses: taiki-e/cache-cargo-install-action@417450f3c33ee20393705369577571770643d4c7 # v3.0.7
with:
tool: sqlx-cli@0.8.6
locked: false
no-default-features: true
features: rustls,postgres
- name: Install dependencies
run: pnpm install
- name: Set app environment
working-directory: packages/app-lib
run: cp .env.staging .env
# labrinth integration tests require a lot of disk space, so in the standard GitHub Actions
# runners we must remove useless development tools from the base image, which frees up ~20 GiB.
# The following command can be used to debug what is taking up space:
# sudo du -xh --max-depth=4 / | sort -rh | curl -X POST --data-urlencode content@/dev/fd/0 https://api.mclo.gs/1/log
- name: Free disk space for labrinth tests
if: env.INTERNAL != 'true'
run: sudo rm -rf /usr/local/lib/android /usr/local/.ghcup /opt/hostedtoolcache/CodeQL /usr/share/swift
# Runners without the Namespace remote cache (fork PRs) restore the local Turborepo
# cache saved by the latest main build. Pull requests can read caches from the default
# branch, but whatever they save stays scoped to their own ref.
- name: Restore Turborepo cache from main
if: env.INTERNAL != 'true'
uses: actions/cache/restore@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
with:
path: .turbo/cache
key: turbo-ci-${{ runner.os }}-${{ runner.arch }}-${{ github.sha }}
restore-keys: turbo-ci-${{ runner.os }}-${{ runner.arch }}-
# Fork PRs only lint and test packages affected since the base branch, as the merge queue
# still runs everything. Turborepo does not attribute the root files below to any crate,
# so changing one of them falls back to a full run.
#
# Services are only started when the labrinth tests will actually run, which is
# neither when they are unaffected nor when they are a cache hit.
- name: Check if labrinth tests need to run
id: check-labrinth
if: env.INTERNAL != 'true'
env:
TURBO_SCM_BASE: origin/${{ github.base_ref }}
run: |
CI_ARGS=''
if git diff --quiet "$TURBO_SCM_BASE...HEAD" -- Cargo.toml rust-toolchain.toml .cargo docker-compose.yml .github/workflows/turbo-ci.yml; then
CI_ARGS='--affected'
fi
echo "CI_ARGS=$CI_ARGS" >> "$GITHUB_ENV"
LABRINTH_TEST_STATUS=$(pnpm turbo run test --filter=labrinth $CI_ARGS --dry-run=json | jq -r '.tasks[] | select(.taskId == "labrinth#test") | .cache.status')
echo "Labrinth test cache status: ${LABRINTH_TEST_STATUS:-not affected}"
if [ -n "$LABRINTH_TEST_STATUS" ] && [ "$LABRINTH_TEST_STATUS" != 'HIT' ]; then
echo "needs_services=true" >> "$GITHUB_OUTPUT"
else
echo "needs_services=false" >> "$GITHUB_OUTPUT"
fi
- name: Start services (fork)
if: steps.check-labrinth.outputs.needs_services == 'true'
run: docker compose --profile clustered-redis up --wait
- name: Wait for services
wait: [services]
- name: Setup labrinth environment and database
if: env.INTERNAL == 'true' || steps.check-labrinth.outputs.needs_services == 'true'
working-directory: apps/labrinth
run: |
cp .env.local .env
sqlx database setup
# `pnpm run ci` excludes the `modrinth-rust` Cargo workspace package so Rust lint and
# tests run and cache per crate. Otherwise any Rust change would invalidate the single
# workspace-wide task and rerun the labrinth tests, which need the services above.
- name: Lint and test
env:
TURBO_SCM_BASE: origin/${{ github.base_ref }}
run: pnpm run ci $CI_ARGS
- name: Check Rust formatting
run: cargo fmt --all --check
- name: Verify intl:extract has been run
run: |
pnpm turbo run intl:extract --force
pnpm scripts i18n-icu-contract prune-local --check
git diff --exit-code --color */*/src/locales/*/index.json
# Remote cache hits are also written to the local cache, so this holds every task from the run
- name: Save Turborepo cache for fork builds
if: ${{ !cancelled() && github.event_name == 'push' && github.ref == 'refs/heads/main' }}
uses: actions/cache/save@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
with:
path: .turbo/cache
key: turbo-ci-${{ runner.os }}-${{ runner.arch }}-${{ github.sha }}