-
Notifications
You must be signed in to change notification settings - Fork 0
85 lines (82 loc) · 3.13 KB
/
Copy pathcontract.yml
File metadata and controls
85 lines (82 loc) · 3.13 KB
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
name: Contract tests
on:
push:
branches: [main]
pull_request:
branches: [main]
schedule:
- cron: '0 6 * * *'
repository_dispatch:
types: [openapi-updated]
permissions:
contents: read
issues: write
jobs:
contract:
name: validate parser against latest audd-openapi fixtures
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
path: audd-java
- name: Check out audd-openapi
uses: actions/checkout@v4
with:
repository: AudDMusic/audd-openapi
path: audd-openapi
ref: main
- uses: actions/setup-java@v4
with:
distribution: temurin
java-version: '21'
cache: maven
- name: Run contract tests
working-directory: audd-java
env:
AUDD_OPENAPI_FIXTURES: ${{ github.workspace }}/audd-openapi/fixtures
run: mvn -B test -Dtest='*ContractTest' -DfailIfNoTests=false
- name: Report drift issue
if: failure() && github.event_name != 'pull_request'
uses: actions/github-script@v7
with:
script: |
const { data: open } = await github.rest.issues.listForRepo({
owner: context.repo.owner, repo: context.repo.repo,
state: 'open', labels: 'contract-drift'
});
const runUrl = `${context.serverUrl}/${context.repo.owner}/${context.repo.repo}/actions/runs/${context.runId}`;
if (open.length > 0) {
await github.rest.issues.createComment({
owner: context.repo.owner, repo: context.repo.repo,
issue_number: open[0].number,
body: `Still failing against the latest audd-openapi spec.\n\nRun: ${runUrl}`
});
} else {
await github.rest.issues.create({
owner: context.repo.owner, repo: context.repo.repo,
title: `contract drift detected (${context.workflow})`,
body: `Contract tests failed against the latest audd-openapi spec.\n\nRun: ${runUrl}`,
labels: ['contract-drift']
});
}
- name: Close drift issue on recovery
if: success() && github.event_name != 'pull_request'
uses: actions/github-script@v7
with:
script: |
const { data: open } = await github.rest.issues.listForRepo({
owner: context.repo.owner, repo: context.repo.repo,
state: 'open', labels: 'contract-drift'
});
const runUrl = `${context.serverUrl}/${context.repo.owner}/${context.repo.repo}/actions/runs/${context.runId}`;
for (const issue of open) {
await github.rest.issues.createComment({
owner: context.repo.owner, repo: context.repo.repo,
issue_number: issue.number,
body: `Contract tests are passing again — closing.\n\nRun: ${runUrl}`
});
await github.rest.issues.update({
owner: context.repo.owner, repo: context.repo.repo,
issue_number: issue.number, state: 'closed'
});
}