forked from WGBH-MLA/ams
-
Notifications
You must be signed in to change notification settings - Fork 0
231 lines (226 loc) · 8.22 KB
/
build-test-lint.yaml
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
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
name: "Ruby on Rails CI"
run-name: Build of ${{ github.ref_name }} by @${{ github.actor }}
on:
pull_request:
branches:
- develop
- main
workflow_dispatch:
inputs:
debug_enabled:
type: boolean
description: 'Run the build with tmate debugging enabled (https://github.com/marketplace/actions/debugging-with-tmate)'
required: false
default: false
env:
REGISTRY: ghcr.io
RAILS_ENV: test
jobs:
build-rails-6-1:
runs-on: ubuntu-latest
steps:
- name: Set env
run: >-
echo "TAG=${HEAD_TAG::8}" >> ${GITHUB_ENV};
echo ${HEAD_TAG::8}
env:
HEAD_TAG: ${{ github.event.pull_request.head.sha || github.sha }}
SE_NODE_SESSION_TIMEOUT: 999999
shell: bash
- name: Downcase repo
run: echo "REPO_LOWER=${REPO,,}" >> $GITHUB_ENV
env:
REPO: '${{ github.repository }}'
- name: Checkout code
uses: actions/checkout@v3
- name: Set up QEMU
uses: docker/setup-qemu-action@v2
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Github Container Login
uses: docker/login-action@f054a8b539a109f9f41c372932f1ae047eff08c9
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Pull from cache to speed up build
run: >-
touch .env.development;
TAG=latest docker compose pull web || true
- name: Setup tmate session
uses: mxschmitt/action-tmate@v3
if: ${{ github.event_name == 'workflow_dispatch' && inputs.debug_enabled }}
with:
limit-access-to-actor: true
- name: Build and push
uses: docker/build-push-action@v3
with:
context: .
# platforms: linux/amd64,linux/arm64
platforms: linux/amd64
target: ams-base
build-args: |
SETTINGS__BULKRAX__ENABLED=true
EXTRA_APK_PACKAGES=less vim bash openjdk11-jre ffmpeg rsync yarn
cache-from: |
${{ env.REGISTRY }}/${{ env.REPO_LOWER }}:${TAG}
push: true
tags: |
${{ env.REGISTRY }}/${{ env.REPO_LOWER }}:${{ env.TAG }}
- name: Build and push worker
uses: docker/build-push-action@v3
with:
context: .
platforms: linux/amd64
# platforms: linux/amd64,linux/arm64
target: ams-worker
build-args: |
SETTINGS__BULKRAX__ENABLED=true
EXTRA_APK_PACKAGES=less vim bash openjdk11-jre ffmpeg rsync yarn
cache-from: |
${{ env.REGISTRY }}/${{ env.REPO_LOWER }}:${TAG}
push: true
tags: |
${{ env.REGISTRY }}/${{ env.REPO_LOWER }}/worker:${{ env.TAG }}
# lint:
# needs: build
# runs-on: ubuntu-latest
# steps:
# - name: Set env
# run: >-
# echo "TAG=${HEAD_TAG::8}" >> ${GITHUB_ENV};
# echo ${HEAD_TAG::8}
# env:
# HEAD_TAG: ${{ github.event.pull_request.head.sha || github.sha }}
# shell: bash
# - name: Checkout code
# uses: actions/checkout@v3
# - name: Github Container Login
# uses: docker/login-action@f054a8b539a109f9f41c372932f1ae047eff08c9
# with:
# registry: ${{ env.REGISTRY }}
# username: ${{ github.actor }}
# password: ${{ secrets.GITHUB_TOKEN }}
# - name: Pull from cache to speed up build
# run: >-
# touch .env.development;
# docker compose pull web;
# docker compose pull worker
# - name: Run Rubocop
# run: docker compose run web bundle exec rubocop --parallel --format progress --format junit --out rubocop.xml --display-only-failed
# - name: Publish Test Report
# uses: mikepenz/action-junit-report@v3
# if: always() # always run even if the previous step fails
# with:
# report_paths: 'rubocop*.xml'
test:
needs: build-rails-6-1
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
# Set N number of parallel jobs you want to run tests on.
# Use higher number if you have slow tests to split them on more parallel jobs.
# Remember to update ci_node_index below to 0..N-1
ci_node_total: [3]
# set N-1 indexes for parallel jobs
# When you run 2 parallel jobs then first job will have index 0, the second job will have index 1 etc
ci_node_index: [0, 1, 2]
env:
ALLOW_ANONYMOUS_LOGIN: "yes"
CONFDIR: "/app/samvera/hyrax-webapp/solr/config"
DB_CLEANER_ALLOW_REMOTE_DB_URL: "true"
SE_NODE_SESSION_TIMEOUT: 999999
TB_RSPEC_FORMATTER: progress
TB_RSPEC_OPTIONS: --format RspecJunitFormatter --out rspec.xml
steps:
- name: Set env
run: >-
echo "TAG=${HEAD_TAG::8}" >> ${GITHUB_ENV};
echo ${HEAD_TAG::8}
env:
HEAD_TAG: ${{ github.event.pull_request.head.sha || github.sha }}
shell: bash
- name: Checkout code
uses: actions/checkout@v3
- name: Github Container Login
uses: docker/login-action@f054a8b539a109f9f41c372932f1ae047eff08c9
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Pull from cache to speed up build
run: >-
touch .env.development;
docker compose pull web;
docker compose pull worker
- name: Setup tmate session
uses: mxschmitt/action-tmate@v3
if: ${{ github.event_name == 'workflow_dispatch' && inputs.debug_enabled }}
with:
limit-access-to-actor: true
- name: Start containers
run: docker compose up -d web
- name: Setup solr
run: >-
docker compose exec -T web bash -c
"solrcloud-upload-configset.sh /app/samvera/hyrax-webapp/solr/config &&
SOLR_COLLECTION_NAME=hydra-test solrcloud-assign-configset.sh &&
solrcloud-assign-configset.sh"
- name: Setup db
run: >-
docker compose exec -T web bash -c
"RAILS_ENV=test bundle exec rake db:environment:set db:schema:load db:migrate db:seed"
- name: Run Specs
id: run-specs
env:
# Specifies how many jobs you would like to run in parallel,
# used for partitioning
CI_NODE_TOTAL: ${{ matrix.ci_node_total }}
# Use the index from matrix as an environment variable
CI_NODE_INDEX: ${{ matrix.ci_node_index }}
continue-on-error: true
run: >-
docker compose exec -T web bash -c
"gem install semaphore_test_boosters &&
rspec_booster --job $CI_NODE_INDEX/$CI_NODE_TOTAL &&
ls -l $PWD"
- name: Publish Test Report
uses: mikepenz/action-junit-report@v3
if: success() || failure()
with:
report_paths: '**/rspec*.xml'
fail_on_failure: true
require_passed_tests: true
detailed_summary: true
# lint:
# needs: build
# runs-on: ubuntu-latest
# steps:
# - name: Set env
# run: >-
# echo "TAG=${HEAD_TAG::8}" >> ${GITHUB_ENV};
# echo ${HEAD_TAG::8}
# env:
# HEAD_TAG: ${{ github.event.pull_request.head.sha || github.sha }}
# shell: bash
# - name: Checkout code
# uses: actions/checkout@v3
# - name: Github Container Login
# uses: docker/login-action@f054a8b539a109f9f41c372932f1ae047eff08c9
# with:
# registry: ${{ env.REGISTRY }}
# username: ${{ github.actor }}
# password: ${{ secrets.GITHUB_TOKEN }}
# - name: Pull from cache to speed up build
# run: >-
# touch .env.development;
# docker compose pull web;
# docker compose pull worker
# - name: Run Rubocop
# run: docker compose run web bundle exec rubocop --parallel --format progress --format junit --out rubocop.xml --display-only-failed
# - name: Publish Test Report
# uses: mikepenz/action-junit-report@v3
# if: always() # always run even if the previous step fails
# with:
# report_paths: 'rubocop*.xml'