forked from mozilla/addons-server
-
Notifications
You must be signed in to change notification settings - Fork 1
133 lines (116 loc) · 3.56 KB
/
_test_main.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
name: Test Docker Image (test_main only)
run-name: |
ref: ${{ github.ref_name }} |
version: ${{ inputs.version }} |
digest: ${{ inputs.digest }} |
splits: ${{ inputs.splits }} |
on:
workflow_call:
inputs:
version:
description: The version of the image to run
type: string
required: false
digest:
description: The build digest of the image to run. Overrides version.
type: string
required: false
splits:
description: How many splits for test_main
type: number
required: false
default: 14
workflow_dispatch:
inputs:
version:
description: The version of the image to run
type: string
required: true
digest:
description: The build digest of the image to run. Overrides version.
type: string
required: false
splits:
description: How many splits for test_main
type: number
required: false
default: 14
concurrency:
group: test_main-${{ github.workflow }}-${{ github.event_name}}-${{ github.ref}}-${{ toJson(inputs) }}
cancel-in-progress: true
env:
log_artifact: test_main_logs
log_file: report.json
jobs:
test_config:
runs-on: ubuntu-latest
outputs:
matrix: ${{ steps.result.outputs.matrix }}
splits: ${{ steps.result.outputs.splits }}
steps:
- uses: actions/checkout@v4
- name: Calculate splits
id: result
shell: bash
run: |
splits=${{ inputs.splits }}
echo "splits: $splits"
echo "splits=$splits" >> $GITHUB_OUTPUT
# Construct the matrix input for test_main using the groups count
# the matrix.group should be an array of numbers from 1 to $splits
matrix=[$(seq -s, 1 $splits)]
echo "matrix: $matrix"
echo "matrix=$matrix" >> $GITHUB_OUTPUT
test_main:
runs-on: ubuntu-latest
needs: [test_config]
strategy:
fail-fast: false
matrix:
group: ${{fromJson(needs.test_config.outputs.matrix)}}
steps:
- uses: actions/checkout@v4
- name: Test (test_matrix)
uses: ./.github/actions/run-docker
with:
services: ''
digest: ${{ inputs.digest }}
version: ${{ inputs.version }}
mount: development
deps: development
run: |
split="--splits ${{ needs.test_config.outputs.splits }}"
group="--group ${{ matrix.group }}"
report="--report-log ${{ env.log_file}}"
make test_main ARGS="${split} ${group} ${report}"
- name: Upload logs
uses: actions/upload-artifact@v4
with:
path: ${{ env.log_file }}
name: ${{ env.log_artifact }}-${{ matrix.group }}
retention-days: 1
overwrite: true
test_log:
runs-on: ubuntu-latest
if: always()
needs: [test_config, test_main]
steps:
- uses: actions/checkout@v4
- uses: actions/download-artifact@v4
with:
pattern: ${{ env.log_artifact }}*
- name: Cat logs
shell: bash
run: |
for dir in $(ls -d ${{ env.log_artifact }}* | sort -V); do
job=$(basename "$dir")
file="${dir}/${{ env.log_file }}"
if [ -f "$file" ]; then
cat "$file" | jq \
-r \
--arg job "$job" \
'select(has("when") and .when == "teardown") | "[\($job)] \(.outcome) \(.nodeid)"'
else
echo "$file: No such file or directory"
fi
done