Merge pull request #1122 from Shopify/preserve-user-input #3399
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
name: CI | |
on: | |
push: | |
pull_request: | |
schedule: | |
- cron: "42 23 * * 0" # Run CI on Sundays at 23:42 UTC | |
permissions: | |
contents: read # actions/checkout | |
issues: write # Create issue | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
name: Ruby ${{ matrix.ruby }} / ${{ matrix.gemfile }} / ${{ matrix.database }} | |
timeout-minutes: 5 | |
strategy: | |
fail-fast: false | |
matrix: | |
gemfile: | |
- gemfiles/rails_6_1.gemfile | |
- gemfiles/rails_7_0.gemfile | |
- gemfiles/rails_7_1.gemfile | |
- Gemfile # current minor release | |
- gemfiles/rails_main.gemfile | |
ruby: ["3.1", "3.2", "3.3"] | |
database: [sqlite] | |
include: | |
- gemfile: "gemfiles/postgresql.gemfile" | |
ruby: 3.3 | |
database: postgres | |
exclude: | |
- gemfile: "gemfiles/rails_main.gemfile" | |
ruby: 3.1 | |
env: | |
BUNDLE_GEMFILE: ${{ matrix.gemfile }} | |
DB: ${{ matrix.database }} | |
steps: | |
- name: Check out code | |
uses: actions/checkout@v4 | |
- name: Set up Ruby ${{ matrix.ruby }} | |
uses: ruby/setup-ruby@v1 | |
with: | |
ruby-version: ${{ matrix.ruby }} | |
bundler-cache: true | |
cache-version: 1 | |
- name: Rails version | |
if: ${{ matrix.gemfile == 'gemfiles/rails_main.gemfile' }} | |
run: bundle info rails | head -1 | |
- name: Start Postgres | |
if: ${{ matrix.database == 'postgres' }} | |
run: | | |
sudo sed -i s/scram-sha-256/trust/g /etc/postgresql/*/main/pg_hba.conf | |
sudo systemctl start postgresql.service | |
echo "DATABASE_URL=postgresql://postgres:@localhost:5432/maintenance_tasks_test" >> $GITHUB_ENV | |
- name: Set up database | |
run: RAILS_ENV=test bundle exec rails db:setup | |
- name: Ruby Tests | |
run: bundle exec rails test | |
- name: System Tests | |
run: bundle exec rails test:system | |
- name: RuboCop | |
run: bundle exec rubocop | |
- name: Archive system test artifacts | |
uses: actions/upload-artifact@v4 | |
if: failure() | |
with: | |
name: screenshots-${{ strategy.job-index }} | |
path: test/dummy/tmp/screenshots | |
if-no-files-found: ignore | |
- name: Create issue | |
if: failure() && github.event.schedule | |
run: | | |
if [ "$(gh issue list --state=open --author='github-actions[bot]' | wc -l)" = 0 ]; then | |
gh issue create --repo "$GITHUB_REPOSITORY" \ | |
--title "Weekly CI run failed" \ | |
--body "${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}" | |
fi | |
env: | |
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} |