-
Notifications
You must be signed in to change notification settings - Fork 0
96 lines (83 loc) · 2.71 KB
/
coverage.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
name: Code test coverage badge
on:
push:
branches:
- master
permissions:
contents: read
pages: write
id-token: write
jobs:
coverage:
name: Test suite for coverage
outputs:
coverage: ${{ steps.coverage.outputs.coverage }}
percentage_coverage: ${{ steps.coverage.outputs.percentage_coverage }}
runs-on: ubuntu-latest
services:
postgres:
image: postgres:14.7
env:
POSTGRES_PASSWORD: postgres
ports:
- "5432:5432"
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
env:
RAILS_ENV: test
POSTGRES_USERNAME: postgres
POSTGRES_PASSWORD: postgres
SCHEMA: structure.sql
PERFORMANCE_TESTS_DISABLED: 1
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Setup Ruby
uses: ruby/setup-ruby@v1
with:
bundler-cache: true
- name: Run RSpec
run: bundle exec rspec -fd
- name: Save code coverage
id: coverage
run: |
COVERAGE="$( cat ./coverage/.last_run.json | grep "line" | grep -oE "[0-9]+\.[0-9]+" )"
echo "coverage=${COVERAGE}" >> $GITHUB_OUTPUT
echo "percentage_coverage=${COVERAGE}%" >> $GITHUB_OUTPUT
badge:
name: Generate badge image and deply to GitHub Pages
needs: coverage
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Create directory for badge
run: |
mkdir ./badge
- name: Generate the badge SVG image
uses: emibcn/[email protected]
with:
label: 'Coverage'
status: ${{ needs.coverage.outputs.percentage_coverage }}
color: ${{
needs.coverage.outputs.coverage > 90 && 'green' ||
needs.coverage.outputs.coverage > 80 && 'yellow,green' ||
needs.coverage.outputs.coverage > 70 && 'yellow' ||
needs.coverage.outputs.coverage > 60 && 'orange,yellow' ||
needs.coverage.outputs.coverage > 50 && 'orange' ||
needs.coverage.outputs.coverage > 40 && 'red,orange' ||
needs.coverage.outputs.coverage > 30 && 'red,red,orange' ||
needs.coverage.outputs.coverage > 20 && 'red,red,red,orange' ||
'red' }}
path: ./badge/test-coverage.svg
- name: Setup Pages
uses: actions/configure-pages@v1
- name: Upload artifact
uses: actions/upload-pages-artifact@v1
with:
path: ./badge
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@main