-
Notifications
You must be signed in to change notification settings - Fork 4
157 lines (143 loc) · 4.23 KB
/
continuous-integration.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
149
150
151
152
153
154
155
156
157
name: Continuous Integration
on:
push:
branches: [staging, master]
pull_request:
merge_group:
workflow_call:
inputs:
sha:
description: The commit SHA to run the workflow on
required: false
type: string
secrets:
codecov_token:
description: Codecov token
required: true
jobs:
build:
name: Build
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
with:
ref: ${{ inputs.sha }}
- name: Build test image
uses: guidojw/actions/build-docker-image@ec8c080252c6b8903a4431211b78c543609f5f89 # v1.4.6
with:
file: Dockerfile
build-args: |
BUNDLE_INSTALL_EXCLUDE=development
name: app
lint:
name: Lint
runs-on: ubuntu-latest
needs: build
services:
db:
image: postgres:14.7
env:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgres
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
ports:
- 5432:5432
steps:
- name: Checkout code
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
with:
ref: ${{ inputs.sha }}
- name: Add problem matchers
run: |
echo '::add-matcher::.github/problem-matchers/actionlint.json'
echo '::add-matcher::.github/problem-matchers/rubocop.json'
- name: Download actionlint
run: |
bash <(curl https://raw.githubusercontent.com/rhysd/actionlint/main/scripts/download-actionlint.bash) 1.6.26
- name: Load test image
uses: guidojw/actions/load-docker-image@ec8c080252c6b8903a4431211b78c543609f5f89 # v1.4.6
with:
name: app
- name: Lint
run: |
EXIT_STATUS=0
./actionlint \
-ignore 'property "gh_app_private_key" is not defined' \
-ignore 'SC2153:' \
-ignore 'property "sha" is not defined in object type {}' || \
EXIT_STATUS=$?
docker run \
-e POSTGRES_USER=postgres \
-e POSTGRES_PASSWORD=postgres \
-e POSTGRES_HOST=localhost \
--network=host \
app bin/ci.sh lint || \
EXIT_STATUS=$?
exit $EXIT_STATUS
test:
name: Test
runs-on: ubuntu-latest
needs: build
env:
CAMO_KEY: camo_key_123
services:
camo:
image: rx14/camo.cr:latest
env:
PORT: 9090
db:
image: postgres:14.7
env:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgres
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
ports:
- 5432:5432
steps:
- name: Checkout code
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
with:
ref: ${{ inputs.sha }}
- name: Add problem matchers
run: |
echo '::add-matcher::.github/problem-matchers/rspec.json'
- name: Load test image
uses: guidojw/actions/load-docker-image@ec8c080252c6b8903a4431211b78c543609f5f89 # v1.4.6
with:
name: app
- name: Test
env:
CAMO_HOST: localhost:9090
run: |
mkdir coverage
docker run \
-e CAMO_KEY \
-e CAMO_HOST \
-e POSTGRES_USER=postgres \
-e POSTGRES_PASSWORD=postgres \
-e POSTGRES_HOST=localhost \
--network=host \
-v "$(pwd)"'/coverage:/app/coverage' \
app bin/ci.sh spec
- name: Upload coverage report to Codecov
if: ${{ !cancelled() }}
uses: codecov/codecov-action@b9fd7d16f6d7d1b5d2bec1a2887e65ceed900238 # v4.6.0
with:
fail_ci_if_error: true
token: ${{ secrets.CODECOV_TOKEN }}
- name: Upload coverage report artifact
if: ${{ !cancelled() }}
uses: actions/upload-artifact@ff15f0306b3f739f7b6fd43fb5d26cd321bd4de5 # v3.2.1
with:
name: coverage
path: coverage/
if-no-files-found: error