-
Notifications
You must be signed in to change notification settings - Fork 2
144 lines (124 loc) · 4.11 KB
/
pull_request.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
# Copyright 2023-2024, Pablo Fernandez
#
# This file is part of Repeater World.
#
# Repeater World is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General
# Public License as published by the Free Software Foundation, either version 3 of the License.
#
# Repeater World is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied
# warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
# details.
#
# You should have received a copy of the GNU Affero General Public License along with Repeater World. If not, see
# <https://www.gnu.org/licenses/>.
name: Code Coverage Comparison
on: pull_request
jobs:
test-head:
name: Test Head Branch
runs-on: ubuntu-latest
timeout-minutes: 20
services:
postgres:
image: postgis/postgis:15-3.3
ports:
- "5001:5432"
env:
POSTGRES_USER: repeater_world
POSTGRES_PASSWORD: te6ahng1phi1uizaeGhahMof1
POSTGRES_DB: repeater_world_test
env:
RAILS_ENV: test
steps:
- name: Checkout Code
uses: actions/checkout@v4
- name: Install Ruby and Gems
uses: ruby/setup-ruby@v1
with:
bundler-cache: true
- name: Set Up Database Schema
run: bin/rails db:migrate
- name: Precompile assets
run: bundle exec rake assets:precompile
- name: Run Tests
run: bundle exec rspec
- name: Upload Coverage
if: always()
uses: actions/upload-artifact@v4
with:
name: head-result
path: coverage/.resultset.json
if-no-files-found: error
include-hidden-files: true
test-base:
name: Test Base Branch
runs-on: ubuntu-latest
timeout-minutes: 20
services:
postgres:
image: postgis/postgis:15-3.3
ports:
- "5001:5432"
env:
POSTGRES_USER: repeater_world
POSTGRES_PASSWORD: te6ahng1phi1uizaeGhahMof1
POSTGRES_DB: repeater_world_test
env:
RAILS_ENV: test
steps:
- name: Checkout Code
uses: actions/checkout@v4
with:
## Here we do not checkout the current branch, but we checkout the base branch.
ref: ${{ github.base_ref }}
- id: base-ref-commit
run: echo "revision=`git rev-parse HEAD`" >> $GITHUB_ENV
- name: simplecov resultset cache
id: simplecov-resultset
uses: actions/cache@v4
with:
path: coverage/.resultset.json
key: simplecov-resultset-${{ env.revision }}
- name: Install Ruby and Gems
uses: ruby/setup-ruby@v1
if: steps.simplecov-resultset.outputs.cache-hit != 'true'
with:
bundler-cache: true
- name: Set Up Database Schema
if: steps.simplecov-resultset.outputs.cache-hit != 'true'
run: bin/rails db:migrate
- name: Precompile assets
if: steps.simplecov-resultset.outputs.cache-hit != 'true'
run: bundle exec rake assets:precompile
- name: Run Tests
if: steps.simplecov-resultset.outputs.cache-hit != 'true'
run: bundle exec rspec
- name: Upload Coverage
if: always()
uses: actions/upload-artifact@v4
with:
name: base-result
path: coverage/.resultset.json
if-no-files-found: error
include-hidden-files: true
compare-coverage:
name: Compare Coverage
runs-on: ubuntu-latest
needs: [test-head, test-base]
steps:
- name: Download Base Coverage
uses: actions/download-artifact@v4
with:
name: base-result
path: ./base-result/
- name: Download Current Coverage
uses: actions/download-artifact@v4
with:
name: head-result
path: ./head-result/
- run: find .
- uses: pupeno/[email protected]
with:
base-resultset-path: ./base-result/.resultset.json
head-resultset-path: ./head-result/.resultset.json
token: ${{ secrets.GITHUB_TOKEN }}