mirror of
https://github.com/discourse/discourse.git
synced 2026-08-05 15:18:34 +08:00
The `gems` job ran on GitHub-hosted runners while the rest use our self-hosted ones. It now runs in the discourse_test:release container (like `tests`), which already has Ruby — ruby/setup-ruby can't install it on the bare self-hosted runners. Also enables jemalloc in the `tests` job, to match tests.yml.
141 lines
4.7 KiB
YAML
Vendored
141 lines
4.7 KiB
YAML
Vendored
name: Migration Tests
|
|
|
|
on:
|
|
pull_request:
|
|
paths:
|
|
- ".github/workflows/migration-tests.yml"
|
|
- "migrations/**"
|
|
push:
|
|
branches:
|
|
- main
|
|
- stable
|
|
paths:
|
|
- ".github/workflows/migration-tests.yml"
|
|
- "migrations/**"
|
|
|
|
concurrency:
|
|
group: migration-tests-${{ format('{0}-{1}', github.head_ref || github.run_number, github.job) }}
|
|
cancel-in-progress: true
|
|
|
|
permissions:
|
|
contents: read
|
|
|
|
jobs:
|
|
gems:
|
|
if: github.event_name == 'pull_request' || github.repository != 'discourse/discourse-private-mirror'
|
|
name: Gems
|
|
runs-on: ${{ (github.repository_owner == 'discourse' && 'cdck-linux-8-core') || 'ubuntu-latest' }}
|
|
container: discourse/discourse_test:release
|
|
timeout-minutes: 15
|
|
|
|
steps:
|
|
- name: Set working directory owner
|
|
run: chown root:root .
|
|
|
|
- uses: actions/checkout@v7
|
|
with:
|
|
fetch-depth: 1
|
|
|
|
- name: RSpec (isolated, no Rails)
|
|
# Each gem uses its own Gemfile (not the app's), so Rails is not on the
|
|
# load path. This proves the gems work standalone.
|
|
run: |
|
|
for gem in core tooling converters importer; do
|
|
echo "== migrations-$gem =="
|
|
(cd "migrations/$gem" && bundle install --jobs $(($(nproc) - 1)) && bundle exec rspec --tag ~rails)
|
|
done
|
|
|
|
- name: Converter coverage (no Rails)
|
|
run: |
|
|
# Reuse the image's prebuilt bundle so a Gemfile.lock change installs
|
|
# only the delta, not the whole root bundle.
|
|
ln -s /var/www/discourse/vendor/bundle vendor/bundle
|
|
bundle config set --local path vendor/bundle
|
|
bundle config set --local deployment true
|
|
bundle config set --local without development
|
|
bundle config set --local with migrations
|
|
bundle install --jobs $(($(nproc) - 1))
|
|
# Fails if the reference (Discourse) converter leaves an IntermediateDB
|
|
# column unwritten, or writes columns or models that don't exist in the
|
|
# schema. Runs without Rails or a source database.
|
|
migrations/bin/disco check coverage
|
|
|
|
tests:
|
|
if: github.event_name == 'pull_request' || github.repository != 'discourse/discourse-private-mirror'
|
|
name: Tests
|
|
runs-on: ${{ (github.repository_owner == 'discourse' && 'cdck-linux-8-core') || 'ubuntu-latest' }}
|
|
container: discourse/discourse_test:release
|
|
timeout-minutes: 20
|
|
|
|
env:
|
|
RAILS_ENV: test
|
|
PGUSER: discourse
|
|
PGPASSWORD: discourse
|
|
LOAD_PLUGINS: 1
|
|
|
|
steps:
|
|
- name: Enable jemalloc
|
|
run: echo /usr/lib/libjemalloc.so.1 > /etc/ld.so.preload
|
|
|
|
- name: Verify jemalloc is loaded into Ruby
|
|
run: |
|
|
ruby -e 'abort "jemalloc not loaded" unless File.read("/proc/self/maps").include?("libjemalloc")'
|
|
|
|
- name: Set working directory owner
|
|
run: chown root:root .
|
|
|
|
- uses: actions/checkout@v7
|
|
with:
|
|
fetch-depth: 1
|
|
|
|
- name: Setup Git
|
|
run: |
|
|
git config --global user.email "ci@ci.invalid"
|
|
git config --global user.name "Discourse CI"
|
|
|
|
- name: Start redis
|
|
run: |
|
|
redis-server /etc/redis/redis.conf &
|
|
|
|
- name: Start Postgres
|
|
run: |
|
|
chown -R postgres /var/run/postgresql
|
|
sudo -E -u postgres script/start_test_db.rb
|
|
sudo -u postgres psql -c "CREATE ROLE $PGUSER LOGIN SUPERUSER PASSWORD '$PGPASSWORD';"
|
|
|
|
- name: Symlink vendor/bundle from image
|
|
run: |
|
|
ln -s /var/www/discourse/vendor/bundle vendor/bundle
|
|
|
|
- name: Setup gems
|
|
run: |
|
|
bundle config --local path vendor/bundle
|
|
bundle config --local deployment true
|
|
bundle config --local without development
|
|
bundle config --local with migrations
|
|
bundle install --jobs $(($(nproc) - 1))
|
|
|
|
- name: pnpm install
|
|
run: pnpm install --frozen-lockfile
|
|
|
|
- name: Create and migrate database
|
|
run: |
|
|
bin/rake db:create
|
|
script/silence_successful_output bin/rake db:migrate
|
|
|
|
- name: Run all schema and converter checks (disco check)
|
|
run: |
|
|
# Runs every check in dependency order: pending migrations, schema
|
|
# config validity, config ↔ database drift, committed generated files
|
|
# vs regeneration (in a temp directory), and converter coverage.
|
|
# Prints the actionable differences and fix commands on failure.
|
|
migrations/bin/disco check
|
|
|
|
- name: RSpec (Rails integration)
|
|
env:
|
|
MIGRATIONS_RAILS: "1"
|
|
run: |
|
|
for gem in core tooling converters importer; do
|
|
echo "== migrations-$gem (Rails integration) =="
|
|
(cd "migrations/$gem" && BUNDLE_GEMFILE="$GITHUB_WORKSPACE/Gemfile" bundle exec rspec --tag rails)
|
|
done
|