-
-
Notifications
You must be signed in to change notification settings - Fork 196
148 lines (121 loc) · 3.79 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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
name: CI
on:
push:
branches: [master, develop]
pull_request:
types:
- opened
- synchronize
concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
cancel-in-progress: true
permissions:
contents: read
jobs:
check:
runs-on: ubuntu-latest
outputs:
skip_rspec: ${{ steps.skip.outputs.skip_rspec }}
env:
GH_TOKEN: ${{ github.token }}
steps:
- name: Check for [skip rspec]
id: skip
run: |
if [ "${{ github.event_name }}" = "pull_request" ]; then
PR_DESCRIPTION=$(gh pr view https://github.com/${{ github.repository }}/pull/${{ github.event.pull_request.number }} --json body -q '.body')
if echo "$PR_DESCRIPTION" | grep -q "\[skip rspec\]"; then
echo "Skip RSpec found in PR description. Passing the action."
echo "skip_rspec=true" >> $GITHUB_OUTPUT
exit
fi
fi
echo "skip_rspec=false" >> $GITHUB_OUTPUT
rspec:
name: Ruby ${{ matrix.ruby }} / PostgreSQL ${{ matrix.postgres }}
runs-on: ubuntu-latest
needs: check
if: needs.check.outputs.skip_rspec == 'false'
permissions:
checks: write # for coverallsapp/github-action to create new checks
strategy:
fail-fast: false
matrix:
include:
- { ruby: '3.1', postgres: 13.5 }
- { ruby: '3.2', postgres: 13.5 }
services:
postgres:
image: fixmystreet/postgres:${{ matrix.postgres }}
env:
POSTGRES_PASSWORD: postgres
ports:
- '5432:5432'
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
env:
DATABASE_URL: postgres://postgres:postgres@localhost:5432/alaveteli_test
RAILS_ENV: test
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
submodules: true
fetch-depth: 0
- name: Install packages
env:
DEBIAN_FRONTEND: noninteractive
run: |
sudo apt-get -y update
sudo apt-get -y install exim4-daemon-light
sudo apt-get -y install `cut -d " " -f 1 config/packages | egrep -v "(^#|wkhtml|bundler|^ruby|^rake)"`
- name: Install Ruby ${{ matrix.ruby }}
uses: ruby/setup-ruby@v1
with:
ruby-version: ${{ matrix.ruby }}
bundler-cache: true
- name: Setup database
run: |
psql postgres://postgres:postgres@localhost:5432 <<-EOSQL
CREATE DATABASE template_utf8 TEMPLATE template0 ENCODING "UTF-8";
UPDATE pg_database SET datistemplate=true WHERE datname='template_utf8';
CREATE DATABASE alaveteli_test TEMPLATE template_utf8;
EOSQL
- name: Configure application and storage
run: |
cp config/general.yml-example config/general.yml
cp config/storage.yml-example config/storage.yml
- name: Install theme
run: |
bundle exec rake themes:install
- name: Migrate database
run: |
bundle exec rails db:migrate
- name: Run core tests
run: |
bundle exec rspec --format Fivemat
- name: Run nested gems tests
run: |
bundle exec rspec gems/*/spec --format Fivemat
- name: Coveralls Parallel
uses: coverallsapp/github-action@master
continue-on-error: true
with:
github-token: ${{ secrets.github_token }}
flag-name: run-${{ matrix.ruby }}-${{ matrix.gemfile || 'Gemfile' }}
parallel: true
coveralls:
name: Coveralls
runs-on: ubuntu-latest
needs: rspec
permissions:
checks: write
steps:
- name: Coveralls Finished
uses: coverallsapp/github-action@master
with:
github-token: ${{ secrets.github_token }}
parallel-finished: true