-
Notifications
You must be signed in to change notification settings - Fork 10
174 lines (152 loc) · 6 KB
/
conformance-run.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
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
name: Conformance Testing
on:
workflow_dispatch:
schedule:
# Every day at midnight
- cron: '0 0 * * *'
jobs:
# conformance-run works through a matrix of actors and runs the conformance
# test suite for each of them. Results are stored in a `reports` artifact for
# later compilation and publishing.
conformance-run:
name: Run Conformance Suite
runs-on: ubuntu-latest
strategy:
# Job must not stop iterating through matrix on failure
fail-fast: false
matrix:
include:
- name: "Mavennet"
actor: "MAVENNET_STAGING"
- name: "mesur.io"
actor: "MESUR_IO_PRODUCTION"
- name: "GS1US"
actor: "GS1US"
- name: 'BCGov'
actor: 'BCGOV'
steps:
# Check out repo, set up node, and install dependencies.
# @see https://github.com/actions/setup-node#usage
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: 16.15.1
cache: 'npm'
- run: npm ci
- name: Run Tests
env:
organization_did_web: ${{secrets[format('{0}_ORGANIZATION_DID_WEB', matrix.actor)]}}
client_id: ${{secrets[format('{0}_CLIENT_ID', matrix.actor)]}}
client_secret: ${{secrets[format('{0}_CLIENT_SECRET', matrix.actor)]}}
token_audience: ${{secrets[format('{0}_TOKEN_AUDIENCE', matrix.actor)]}}
token_endpoint: ${{secrets[format('{0}_TOKEN_ENDPOINT', matrix.actor)]}}
api_base_url: ${{secrets[format('{0}_API_BASE_URL', matrix.actor)]}}
run: |
npx newman run ./tests/conformance_suite.postman_collection.json \
--env-var ORGANIZATION_DID_WEB=$organization_did_web \
--env-var CLIENT_ID=$client_id \
--env-var CLIENT_SECRET=$client_secret \
--env-var TOKEN_AUDIENCE=$token_audience \
--env-var TOKEN_ENDPOINT=$token_endpoint \
--env-var API_BASE_URL=$api_base_url \
--reporters cli,htmlextra,json \
--reporter-htmlextra-skipSensitiveData \
--reporter-htmlextra-export "newman/${{format('{0}-{1}-{2}.html', github.run_id, github.job, matrix.name)}}" \
--reporter-json-export "newman/${{format('{0}-{1}-{2}.json', github.run_id, github.job, matrix.name)}}"
# Write sanitized Newman output to `./docs/reports`.
- name: Sanitize Report Output
if: always() # Run even when postman tests fail
run: npm run report:sanitize
# Sanitized reports are needed by subsequent jobs
- uses: actions/upload-artifact@v3
if: always() # Run even when postman tests fail
with:
name: reports
path: docs/reports/
# conformance-compile compiles the sanitized raw report output into an
# interactive HTML conformance report suitable for publishing.
conformance-compile:
name: Compile Reports
runs-on: ubuntu-latest
# Run even when postman tests fail
if: always()
# Wait for jobs which generate reporting input.
needs:
- conformance-run
steps:
# Check out repo, setup node, and install dependencies.
# @see https://github.com/actions/setup-node#usage
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: 16.15.1
cache: 'npm'
- run: npm ci
# Download 'reports' artifact
- uses: actions/download-artifact@v3
with:
name: reports
path: docs/reports/
# Build report index
- name: Build JSON Index
run: npm run report:index -- --folder conformance
# Set up Python 3.10
- name: Set up Python 3.10
uses: actions/setup-python@v4
with:
python-version: "3.10"
cache: pip
- run: pip install -r ./reporting/requirements.txt
# Compile interactive report
- name: Build Conformance Report
working-directory: ./reporting
run: ./reporter.py --mode ci --conformance
# Compiled report must be added to artifact
- uses: actions/upload-artifact@v3
with:
name: reports
path: docs/reports/
# conformance-publish publishes sanitized raw and interactive HTML reports to
# the `reports/conformance` directory in GitHub pages. This job is restricted
# to commits on the `main` branch to prevent feature branches from overwriting
# production reports.
conformance-publish:
name: Publish Report
runs-on: ubuntu-latest
# Publishing must only happen when triggered on the 'main' branch to prevent
# tests on other branches from polluting the published reports. Note that
# `always()`` is a special flag that is REQUIRED in order to get this job to
# run if jobs listed in the `needs:` section fail.
if: github.ref == 'refs/heads/main' && always()
# Report must be compiled before publishing
needs:
- conformance-compile
steps:
# Check out repo
- uses: actions/checkout@v3
# Download 'reports' artifact
- uses: actions/download-artifact@v3
with:
name: reports
path: docs/reports/
# Publish report subfolder to GitHub Pages
- name: Publish Conformance Report
uses: peaceiris/actions-gh-pages@v3
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: ./docs/reports
destination_dir: reports/conformance
# Prepare an archive folder name and update the index.json appropriately
- name: Prepare Conformance Archive
id: archive
run: |
FOLDER=conformance-$(date +'%s')
sed -i "s#reports/conformance/#reports/$FOLDER/#" ./docs/reports/index.json
echo "::set-output name=folder::$FOLDER"
# Publish report archive subfolder to GitHub Pages
- name: Publish Conformance Archive
uses: peaceiris/actions-gh-pages@v3
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: ./docs/reports
destination_dir: reports/${{ steps.archive.outputs.folder }}