This repository has been archived by the owner on Apr 5, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
106 lines (102 loc) · 3.09 KB
/
ci_ruby.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
name: CI Ruby
on:
push:
branches: [ 'main', 'develop' ]
pull_request:
branches: [ 'main', 'develop' ]
permissions:
actions: read
checks: write
contents: read
pull-requests: write
statuses: read
jobs:
test:
runs-on: ubuntu-latest
env:
CI: true
strategy:
matrix:
ruby-version: ['2.7', '3.0', '3.1']
include:
- ruby-version: '3.1'
coverage: true
steps:
- name: Configure Git
run: |
git config --global user.email "[email protected]"
git config --global user.name "Your Name"
- name: Checkout code
uses: actions/checkout@v3
- name: Install Ruby and gems
uses: ruby/setup-ruby@v1
with:
ruby-version: ${{ matrix.ruby-version }}
bundler-cache: true # runs 'bundle install' and caches installed gems automatically
- name: Run the setup script
run: ./bin/setup
- name: Run unit tests
env:
COVERAGE: ${{ matrix.coverage }}
run: bundle exec rake test:unit
- name: Run integration tests
run: bundle exec rake test:integration
- name: Code Coverage report
if: ${{ matrix.coverage }}
uses: 5monkeys/cobertura-action@master
with:
path: coverage/coverage.xml
minimum_coverage: 85
repo_token: ${{ secrets.GITHUB_TOKEN }}
fail_below_threshold: true
show_missing: true
link_missing_lines: true
- name: Prepare data for a Code Coverage badge
if: ${{ matrix.coverage }}
run: |
echo "COVERAGE=$(./bin/code_coverage)" >> $GITHUB_ENV
REF=${{ github.ref }}
echo "github.ref: $REF"
IFS='/' read -ra PATHS <<< "$REF"
BRANCH_NAME="${PATHS[1]}_${PATHS[2]}"
echo $BRANCH_NAME
echo "BRANCH=${BRANCH_NAME}" >> $GITHUB_ENV
- name: Create the Coverage Badge
if: ${{ matrix.coverage }}
uses: schneegans/[email protected]
with:
auth: ${{ secrets.GIST_SECRET }}
gistID: 6a095c79278b074d79feaa4f8ceeb2a8
filename: amber_component__${{ env.BRANCH }}.json
style: flat
label: Code Coverage
message: ${{ env.COVERAGE }}%
logoColor: EB222F
namedLogo: ruby
valColorRange: ${{ env.COVERAGE }}
maxColorRange: 100
minColorRange: 0
- name: Archive code coverage artifacts
if: ${{ matrix.coverage }}
uses: actions/upload-artifact@v3
with:
name: code_coverage
path: coverage
lint:
runs-on: ubuntu-latest
env:
CI: true
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Install Ruby and gems
uses: ruby/setup-ruby@v1
with:
bundler-cache: true
- name: Run the setup script
run: ./bin/setup
# Add or replace any other lints here
- name: Security audit dependencies
run: bundle exec bundle audit --update
- name: Lint Ruby files
run: bundle exec rubocop --parallel