-
Notifications
You must be signed in to change notification settings - Fork 124
145 lines (140 loc) · 4.58 KB
/
build-test-lint.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
name: 'Build Test Lint'
run-name: Build Test Lint of ${{ github.ref_name }} by @${{ github.actor }}
on:
push:
branches:
- main
pull_request:
branches:
- 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
DOCKER_BUILDKIT: 1
COMPOSE_DOCKER_CLI_BUILD: 1
jobs:
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: ruby/setup-ruby@v1
with:
ruby-version: '3.2'
bundler-cache: true
cache-version: 1
- name: Rubocop
run: bundle install && bundle exec rubocop --parallel --format progress --format junit --out rubocop.xml --display-only-failed
- name: Archive rubocop reports
uses: actions/upload-artifact@v4
if: always()
with:
name: rubocop-reports
path: 'rubocop*.xml'
build:
needs: lint
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
ci_test_app: [dassie,koppie]
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Build and export
uses: docker/build-push-action@v5
with:
build-args: |
APP_PATH=.${{ matrix.ci_test_app }}
cache-from: type=gha
cache-to: type=gha, mode=max
context: .
target: hyrax-engine-dev
tags: samvera/${{ matrix.ci_test_app }}:latest,samvera/${{ matrix.ci_test_app }}:${{ github.sha }}
outputs: type=docker,dest=/tmp/${{ matrix.ci_test_app }}-${{ github.sha }}.tar
- name: Upload built image artifact
uses: actions/upload-artifact@v4
with:
name: ${{ matrix.ci_test_app }}-image
path: /tmp/${{ matrix.ci_test_app }}-${{ github.sha }}.tar
test:
needs: build
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
ci_test_app: [dassie,koppie]
ci_node_total: [8]
ci_node_index: [0,1,2,3,4,5,6,7]
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup tmate debug session
uses: mxschmitt/action-tmate@v3
if: ${{ github.event_name == 'workflow_dispatch' && inputs.debug_enabled }}
with:
limit-access-to-actor: true
detached: true
- name: Download built image artifact
uses: actions/download-artifact@v4
with:
name: ${{ matrix.ci_test_app }}-image
path: /tmp
- name: Start containers
run: |
docker load --input /tmp/${{ matrix.ci_test_app }}-${{ github.sha }}.tar
docker image ls -a
docker compose -f docker-compose-${{ matrix.ci_test_app }}.yml up -d --quiet-pull --pull missing --no-build
- name: RSpec
env:
CI_NODE_TOTAL: ${{ matrix.ci_node_total }}
CI_NODE_INDEX: ${{ matrix.ci_node_index }}
run: >-
docker compose -f docker-compose-${{ matrix.ci_test_app }}.yml exec -T -w /app/samvera/hyrax-engine web sh -c
"bundle install && yarn install && rspec_booster --job ${{ matrix.ci_node_index }}/${{ matrix.ci_node_total }}"
- name: Capture Container Logs
if: always()
uses: jwalton/gh-docker-logs@v2
with:
images: 'seleniarm/standalone-chromium'
- name: Move Test Files
if: always()
env:
CI_TEST_APP: ${{ matrix.ci_test_app }}
CI_NODE_TOTAL: ${{ matrix.ci_node_total }}
CI_NODE_INDEX: ${{ matrix.ci_node_index }}
run: >-
mv rspec.xml rspec-${CI_TEST_APP}-${CI_NODE_INDEX}.xml
- name: Archive spec reports
uses: actions/upload-artifact@v4
if: always()
with:
name: spec-reports-${{ matrix.ci_test_app }}-${{ matrix.ci_node_index }}
path: '**/rspec*.xml'
report:
needs: test
runs-on: ubuntu-latest
permissions:
checks: write
# only needed unless run with comment_mode: off
pull-requests: write
if: always()
steps:
- name: Download all workflow run artifacts
uses: actions/download-artifact@v4
with:
path: artifacts
pattern: "*report*"
- name: Publish Test Report
uses: EnricoMi/publish-unit-test-result-action@v2
with:
files: "artifacts/**/*.xml"
action_fail_on_inconclusive: true
fail_on: "test failures"