This repository has been archived by the owner on Dec 12, 2024. It is now read-only.
generated from TBD54566975/tbd-project-template
-
Notifications
You must be signed in to change notification settings - Fork 25
190 lines (170 loc) · 6.9 KB
/
test-implementations.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
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
name: Test Spec Implementation Repos
# Parse the CI output status and make a markdown summary
# TODO:
# - make the pipeline ignore failures so devs dont ignore the CI checks
# - add a step to add a comment summary with the failures in the PR, so PRs can act accordingly
# - add a step to automate issue creation for each failure (or update existing one)
on:
push:
branches:
- main
pull_request:
branches:
- main
schedule:
- cron: "0 5 * * *"
jobs:
test:
strategy:
fail-fast: false
matrix:
include:
- repo: tbdex-js
ci_file: integrity-check.yml
spec_path: tbdex
job_step: test-with-node;Run tests
- repo: tbdex-swift
ci_file: ci.yml
spec_path: Tests/tbDEXTestVectors/tbdex-spec
job_step: build-and-test;Run tests
- repo: tbdex-kt
ci_file: ci.yml
spec_path: tbdex
job_step: build-test-deploy-snapshot-ubuntu;Build, Test
- repo: tbdex-rs
ci_file: ci.yml
spec_path: tbdex
job_step: build-test-deploy-snapshot-ubuntu;Build, Test
outputs:
tbdex-js: ${{ steps.output.outputs.tbdex-js }}
tbdex-swift: ${{ steps.output.outputs.tbdex-swift }}
tbdex-kt: ${{ steps.output.outputs.tbdex-kt }}
tbdex-rs: ${{ steps.output.outputs.tbdex-rs }}
runs-on: ubuntu-latest
steps:
- name: Generate an access token to write to downstream repo
uses: actions/create-github-app-token@2986852ad836768dfea7781f31828eb3e17990fa # v1.6.2
id: app-token
with:
app-id: ${{ secrets.CICD_ROBOT_GITHUB_APP_ID }}
private-key: ${{ secrets.CICD_ROBOT_GITHUB_APP_PRIVATE_KEY }}
owner: TBD54566975
repositories: ${{ matrix.repo }}
- name: Checkout spec repository
uses: actions/checkout@v4
with:
token: ${{ steps.app-token.outputs.token }}
repository: TBD54566975/${{ matrix.repo }}
ref: main
submodules: true
# persist-credentials: false
- name: Setup Spec values
id: spec-vals
run: |
SHA="${{ github.event_name == 'pull_request' && github.event.pull_request.head.sha || github.sha }}"
echo "SPEC_SHORT_SHA=${SHA:0:7}" >> $GITHUB_OUTPUT
echo "SPEC_SHA=$SHA" >> $GITHUB_OUTPUT
echo "SPEC_REF=tbd-ci-cd-robot/spec-tests" >> $GITHUB_OUTPUT
- name: Update spec submodule in ${{ matrix.repo }}
env:
SPEC_SHORT_SHA: ${{ steps.spec-vals.outputs.SPEC_SHORT_SHA }}
SPEC_SHA: ${{ steps.spec-vals.outputs.SPEC_SHA }}
SPEC_REF: ${{ steps.spec-vals.outputs.SPEC_REF }}
run: |
REPO_ROOT=$(pwd)
cd ${{ matrix.spec_path }}
git fetch origin ${{ env.SPEC_SHA }}
git checkout ${{ env.SPEC_SHA }}
cd $REPO_ROOT
git checkout -b ${{ env.SPEC_REF }}
git add .
git config user.name "tbd-ci-cd-robot[bot]"
git config user.email "${{ secrets.CICD_ROBOT_GITHUB_APP_ID }}+tbd-ci-cd-robot[bot]@users.noreply.github.com"
git commit -m "Update tbdex spec to ${{ env.SPEC_SHORT_SHA }}"
git push origin ${{ env.SPEC_REF }} -f
- name: Trigger and wait for ${{ matrix.repo }} CI pipeline
uses: convictional/[email protected]
id: trigger-ci
with:
owner: TBD54566975
repo: ${{ matrix.repo }}
github_token: ${{ steps.app-token.outputs.token }}
workflow_file_name: ${{ matrix.ci_file }}
ref: ${{ steps.spec-vals.outputs.SPEC_REF }}
wait_interval: 10
propagate_failure: false
# client_payload: '{}'
# trigger_workflow: true
# wait_workflow: true
# Read CI status
- name: Read CI Job Status
uses: actions/github-script@v6
id: read-ci-status
env:
RUN_ID: ${{ steps.trigger-ci.outputs.workflow_id }}
with:
github-token: ${{ steps.app-token.outputs.token }}
script: |
const {data: run} = await github.rest.actions.getWorkflowRun({
owner: 'TBD54566975',
repo: '${{ matrix.repo }}',
run_id: ${{ env.RUN_ID }},
});
console.info({run})
return run.conclusion
- id: output
run: |
echo "${{ matrix.repo }}=${{ steps.read-ci-status.outputs.result }}" >> $GITHUB_OUTPUT
collect-results:
name: Collect Tests Results
needs: test
runs-on: ubuntu-latest
steps:
- name: Collect job results
run: |
get_status_emoji() {
if [ "$1" == "success" ]; then
echo "✅"
else
echo "❌"
fi
}
echo "## tbdex Spec Implementation SDKs Test Results" >> $GITHUB_STEP_SUMMARY
echo "| Repository | Status |" >> $GITHUB_STEP_SUMMARY
echo "|------------|--------|" >> $GITHUB_STEP_SUMMARY
echo "|tbdex-js|$(get_status_emoji ${{ needs.test.outputs.tbdex-js }}) (${{ needs.test.outputs.tbdex-js }})|" >> $GITHUB_STEP_SUMMARY
echo "|tbdex-swift|$(get_status_emoji ${{ needs.test.outputs.tbdex-swift }}) (${{ needs.test.outputs.tbdex-swift }})|" >> $GITHUB_STEP_SUMMARY
echo "|tbdex-kt|$(get_status_emoji ${{ needs.test.outputs.tbdex-kt }}) (${{ needs.test.outputs.tbdex-kt }})|" >> $GITHUB_STEP_SUMMARY
echo "|tbdex-rs|$(get_status_emoji ${{ needs.test.outputs.tbdex-rs }}) (${{ needs.test.outputs.tbdex-rs }})|" >> $GITHUB_STEP_SUMMARY
- name: Display job summary
run: echo $GITHUB_STEP_SUMMARY
- name: Upsert comment with job summary
uses: actions/github-script@v6
env:
GITHUB_STEP_SUMMARY: ${{ env.GITHUB_STEP_SUMMARY }}
with:
script: |
const summaryFile = process.env.GITHUB_STEP_SUMMARY
if (!summaryFile) {
throw new Error("GITHUB_STEP_SUMMARY is not set")
}
let githubSummary = '__This is an automated bot message__\n\n' + summaryFile;
const {data: comments} = await github.rest.issues.listComments({
owner: "TBD54566975",
repo: "tbdex",
issue_number: ${{ github.event.pull_request.number }},
});
const summaryComment = comments.find(comment => comment.body.includes("| Repository | Status |" && comment.user.type === "Bot"))
if (summaryComment) {
await github.rest.issues.updateComment({
comment_id: summaryComment.id,
body: githubSummary,
});
} else {
await github.rest.issues.createComment({
owner: "TBD54566975",
repo: "tbdex",
issue_number: ${{ github.event.pull_request.number }},
body: githubSummary,
});
}