-
Notifications
You must be signed in to change notification settings - Fork 74
81 lines (78 loc) · 2.53 KB
/
ci.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
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 }}