123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466 |
- name: Ruby Testing
- on:
- merge_group:
- push:
- branches:
- - 'main'
- - 'stable-*'
- pull_request:
- env:
- BUNDLE_CLEAN: true
- BUNDLE_FROZEN: true
- concurrency:
- group: ${{ github.workflow }}-${{ github.ref }}
- cancel-in-progress: true
- jobs:
- build:
- runs-on: ubuntu-latest
- strategy:
- fail-fast: true
- matrix:
- mode:
- - production
- - test
- env:
- RAILS_ENV: ${{ matrix.mode }}
- BUNDLE_WITH: ${{ matrix.mode }}
- SECRET_KEY_BASE_DUMMY: 1
- steps:
- - uses: actions/checkout@v4
- - name: Set up Ruby environment
- uses: ./.github/actions/setup-ruby
- - name: Set up Javascript environment
- uses: ./.github/actions/setup-javascript
- with:
- onlyProduction: 'true'
- - name: Cache assets from compilation
- uses: actions/cache@v4
- with:
- path: |
- public/assets
- public/packs
- public/packs-test
- tmp/cache/webpacker
- key: ${{ matrix.mode }}-assets-${{ github.head_ref || github.ref_name }}-${{ github.sha }}
- restore-keys: |
- ${{ matrix.mode }}-assets-${{ github.head_ref || github.ref_name }}-${{ github.sha }}
- ${{ matrix.mode }}-assets-${{ github.head_ref || github.ref_name }}
- ${{ matrix.mode }}-assets-main
- ${{ matrix.mode }}-assets
- - name: Precompile assets
- run: |-
- bin/rails assets:precompile
- - name: Archive asset artifacts
- run: |
- tar --exclude={"*.br","*.gz"} -zcf artifacts.tar.gz public/assets public/packs*
- - uses: actions/upload-artifact@v4
- if: matrix.mode == 'test'
- with:
- path: |-
- ./artifacts.tar.gz
- name: ${{ github.sha }}
- retention-days: 0
- test:
- runs-on: ubuntu-latest
- needs:
- - build
- services:
- postgres:
- image: postgres:14-alpine
- env:
- POSTGRES_PASSWORD: postgres
- POSTGRES_USER: postgres
- options: >-
- --health-cmd pg_isready
- --health-interval 10ms
- --health-timeout 3s
- --health-retries 50
- ports:
- - 5432:5432
- redis:
- image: redis:7-alpine
- options: >-
- --health-cmd "redis-cli ping"
- --health-interval 10ms
- --health-timeout 3s
- --health-retries 50
- ports:
- - 6379:6379
- env:
- DB_HOST: localhost
- DB_USER: postgres
- DB_PASS: postgres
- DISABLE_SIMPLECOV: ${{ matrix.ruby-version != '.ruby-version' }}
- RAILS_ENV: test
- ALLOW_NOPAM: true
- PAM_ENABLED: true
- PAM_DEFAULT_SERVICE: pam_test
- PAM_CONTROLLED_SERVICE: pam_test_controlled
- OIDC_ENABLED: true
- OIDC_SCOPE: read
- SAML_ENABLED: true
- CAS_ENABLED: true
- BUNDLE_WITH: 'pam_authentication test'
- GITHUB_RSPEC: ${{ matrix.ruby-version == '.ruby-version' && github.event.pull_request && 'true' }}
- strategy:
- fail-fast: false
- matrix:
- ruby-version:
- - '3.2'
- - '.ruby-version'
- steps:
- - uses: actions/checkout@v4
- - uses: actions/download-artifact@v4
- with:
- path: './'
- name: ${{ github.sha }}
- - name: Expand archived asset artifacts
- run: |
- tar xvzf artifacts.tar.gz
- - name: Set up Ruby environment
- uses: ./.github/actions/setup-ruby
- with:
- ruby-version: ${{ matrix.ruby-version}}
- additional-system-dependencies: ffmpeg imagemagick libpam-dev
- - name: Load database schema
- run: |
- bin/rails db:setup
- bin/flatware fan bin/rails db:test:prepare
- - name: Cache RSpec persistence file
- uses: actions/cache@v4
- with:
- path: |
- tmp/rspec/examples.txt
- key: rspec-persistence-${{ github.head_ref || github.ref_name }}-${{ github.sha }}
- restore-keys: |
- rspec-persistence-${{ github.head_ref || github.ref_name }}-${{ github.sha }}-${{ matrix.ruby-version }}
- rspec-persistence-${{ github.head_ref || github.ref_name }}-${{ github.sha }}
- rspec-persistence-${{ github.head_ref || github.ref_name }}
- rspec-persistence-main
- rspec-persistence
- - run: bin/flatware rspec -r ./spec/flatware_helper.rb
- - name: Upload coverage reports to Codecov
- if: matrix.ruby-version == '.ruby-version'
- uses: codecov/codecov-action@v4
- with:
- files: coverage/lcov/*.lcov
- env:
- CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
- test-libvips:
- name: Libvips tests
- runs-on: ubuntu-24.04
- needs:
- - build
- services:
- postgres:
- image: postgres:14-alpine
- env:
- POSTGRES_PASSWORD: postgres
- POSTGRES_USER: postgres
- options: >-
- --health-cmd pg_isready
- --health-interval 10ms
- --health-timeout 3s
- --health-retries 50
- ports:
- - 5432:5432
- redis:
- image: redis:7-alpine
- options: >-
- --health-cmd "redis-cli ping"
- --health-interval 10ms
- --health-timeout 3s
- --health-retries 50
- ports:
- - 6379:6379
- env:
- DB_HOST: localhost
- DB_USER: postgres
- DB_PASS: postgres
- DISABLE_SIMPLECOV: ${{ matrix.ruby-version != '.ruby-version' }}
- RAILS_ENV: test
- ALLOW_NOPAM: true
- PAM_ENABLED: true
- PAM_DEFAULT_SERVICE: pam_test
- PAM_CONTROLLED_SERVICE: pam_test_controlled
- OIDC_ENABLED: true
- OIDC_SCOPE: read
- SAML_ENABLED: true
- CAS_ENABLED: true
- BUNDLE_WITH: 'pam_authentication test'
- GITHUB_RSPEC: ${{ matrix.ruby-version == '.ruby-version' && github.event.pull_request && 'true' }}
- MASTODON_USE_LIBVIPS: true
- strategy:
- fail-fast: false
- matrix:
- ruby-version:
- - '3.2'
- - '.ruby-version'
- steps:
- - uses: actions/checkout@v4
- - uses: actions/download-artifact@v4
- with:
- path: './'
- name: ${{ github.sha }}
- - name: Expand archived asset artifacts
- run: |
- tar xvzf artifacts.tar.gz
- - name: Set up Ruby environment
- uses: ./.github/actions/setup-ruby
- with:
- ruby-version: ${{ matrix.ruby-version}}
- additional-system-dependencies: ffmpeg libpam-dev
- - name: Load database schema
- run: './bin/rails db:create db:schema:load db:seed'
- - run: bin/rspec --tag attachment_processing
- - name: Upload coverage reports to Codecov
- if: matrix.ruby-version == '.ruby-version'
- uses: codecov/codecov-action@v4
- with:
- files: coverage/lcov/mastodon.lcov
- env:
- CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
- test-e2e:
- name: End to End testing
- runs-on: ubuntu-latest
- needs:
- - build
- services:
- postgres:
- image: postgres:14-alpine
- env:
- POSTGRES_PASSWORD: postgres
- POSTGRES_USER: postgres
- options: >-
- --health-cmd pg_isready
- --health-interval 10ms
- --health-timeout 3s
- --health-retries 50
- ports:
- - 5432:5432
- redis:
- image: redis:7-alpine
- options: >-
- --health-cmd "redis-cli ping"
- --health-interval 10ms
- --health-timeout 3s
- --health-retries 50
- ports:
- - 6379:6379
- env:
- DB_HOST: localhost
- DB_USER: postgres
- DB_PASS: postgres
- DISABLE_SIMPLECOV: true
- RAILS_ENV: test
- BUNDLE_WITH: test
- LOCAL_DOMAIN: localhost:3000
- LOCAL_HTTPS: false
- strategy:
- fail-fast: false
- matrix:
- ruby-version:
- - '3.2'
- - '.ruby-version'
- steps:
- - uses: actions/checkout@v4
- - uses: actions/download-artifact@v4
- with:
- path: './'
- name: ${{ github.sha }}
- - name: Expand archived asset artifacts
- run: |
- tar xvzf artifacts.tar.gz
- - name: Set up Ruby environment
- uses: ./.github/actions/setup-ruby
- with:
- ruby-version: ${{ matrix.ruby-version}}
- additional-system-dependencies: ffmpeg imagemagick
- - name: Set up Javascript environment
- uses: ./.github/actions/setup-javascript
- - name: Load database schema
- run: './bin/rails db:create db:schema:load db:seed'
- - run: bin/rspec spec/system --tag streaming --tag js
- - name: Archive logs
- uses: actions/upload-artifact@v4
- if: failure()
- with:
- name: e2e-logs-${{ matrix.ruby-version }}
- path: log/
- - name: Archive test screenshots
- uses: actions/upload-artifact@v4
- if: failure()
- with:
- name: e2e-screenshots
- path: tmp/capybara/
- test-search:
- name: Elastic Search integration testing
- runs-on: ubuntu-latest
- needs:
- - build
- services:
- postgres:
- image: postgres:14-alpine
- env:
- POSTGRES_PASSWORD: postgres
- POSTGRES_USER: postgres
- options: >-
- --health-cmd pg_isready
- --health-interval 10ms
- --health-timeout 3s
- --health-retries 50
- ports:
- - 5432:5432
- redis:
- image: redis:7-alpine
- options: >-
- --health-cmd "redis-cli ping"
- --health-interval 10ms
- --health-timeout 3s
- --health-retries 50
- ports:
- - 6379:6379
- elasticsearch:
- image: ${{ contains(matrix.search-image, 'elasticsearch') && matrix.search-image || '' }}
- env:
- discovery.type: single-node
- xpack.security.enabled: false
- options: >-
- --health-cmd "curl http://localhost:9200/_cluster/health"
- --health-interval 2s
- --health-timeout 3s
- --health-retries 50
- ports:
- - 9200:9200
- opensearch:
- image: ${{ contains(matrix.search-image, 'opensearch') && matrix.search-image || '' }}
- env:
- discovery.type: single-node
- DISABLE_INSTALL_DEMO_CONFIG: true
- DISABLE_SECURITY_PLUGIN: true
- options: >-
- --health-cmd "curl http://localhost:9200/_cluster/health"
- --health-interval 2s
- --health-timeout 3s
- --health-retries 50
- ports:
- - 9200:9200
- env:
- DB_HOST: localhost
- DB_USER: postgres
- DB_PASS: postgres
- DISABLE_SIMPLECOV: true
- RAILS_ENV: test
- BUNDLE_WITH: test
- ES_ENABLED: true
- ES_HOST: localhost
- ES_PORT: 9200
- strategy:
- fail-fast: false
- matrix:
- ruby-version:
- - '3.2'
- - '.ruby-version'
- search-image:
- - docker.elastic.co/elasticsearch/elasticsearch:7.17.13
- include:
- - ruby-version: '.ruby-version'
- search-image: docker.elastic.co/elasticsearch/elasticsearch:8.10.2
- - ruby-version: '.ruby-version'
- search-image: opensearchproject/opensearch:2
- steps:
- - uses: actions/checkout@v4
- - uses: actions/download-artifact@v4
- with:
- path: './'
- name: ${{ github.sha }}
- - name: Set up Ruby environment
- uses: ./.github/actions/setup-ruby
- with:
- ruby-version: ${{ matrix.ruby-version}}
- additional-system-dependencies: ffmpeg imagemagick
- - name: Set up Javascript environment
- uses: ./.github/actions/setup-javascript
- - name: Load database schema
- run: './bin/rails db:create db:schema:load db:seed'
- - run: bin/rspec --tag search
- - name: Archive logs
- uses: actions/upload-artifact@v4
- if: failure()
- with:
- name: test-search-logs-${{ matrix.ruby-version }}
- path: log/
- - name: Archive test screenshots
- uses: actions/upload-artifact@v4
- if: failure()
- with:
- name: test-search-screenshots
- path: tmp/capybara/
|