Repository navigation
130 lines (120 loc) · 4.28 KB
/
Copy pathsdk-coverage.yml
File metadata and controls
130 lines (120 loc) · 4.28 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
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
name: SDK coverage
on:
workflow_call:
inputs:
source_repository:
description: Source repository containing the API contracts
required: true
type: string
source_sha:
description: Exact source revision to inspect
required: true
type: string
source_branch:
description: Source branch whose contract changed
required: true
type: string
sdk_target_branch:
description: SDK integration branch (main)
required: true
type: string
messaging_spec_path:
description: Repository-relative Messaging OpenAPI path
required: true
type: string
platform_spec_path:
description: Repository-relative Platform OpenAPI path
required: true
type: string
secrets:
SDK_COVERAGE_CLIENT_ID:
required: true
SDK_COVERAGE_APP_PRIVATE_KEY:
required: true
LINEAR_API_KEY:
required: false
permissions:
contents: read
jobs:
synchronize:
runs-on: ubuntu-latest
steps:
- name: Enforce SDK main routing
env:
SOURCE_BRANCH: ${{ inputs.source_branch }}
SDK_TARGET_BRANCH: ${{ inputs.sdk_target_branch }}
run: |
if [[ "$SOURCE_BRANCH" != "dev" && "$SOURCE_BRANCH" != "main" ]]; then
echo "source_branch must be dev or main" >&2
exit 1
fi
if [[ "$SDK_TARGET_BRANCH" != "main" ]]; then
echo "SDK contracts from dev and main both target SDK main" >&2
exit 1
fi
- name: Check out source contracts
uses: actions/checkout@v6
with:
repository: ${{ inputs.source_repository }}
ref: ${{ inputs.source_sha }}
path: source
persist-credentials: false
- name: Create SDK repository token
id: sdk-token
uses: actions/create-github-app-token@bcd2ba49218906704ab6c1aa796996da409d3eb1 # v3
with:
client-id: ${{ secrets.SDK_COVERAGE_CLIENT_ID }}
private-key: ${{ secrets.SDK_COVERAGE_APP_PRIVATE_KEY }}
owner: polymorfa
repositories: sdks
permission-contents: read
- name: Check out SDK coverage ledger
uses: actions/checkout@v6
with:
repository: polymorfa/sdks
ref: ${{ inputs.sdk_target_branch }}
path: sdk
token: ${{ steps.sdk-token.outputs.token }}
persist-credentials: false
- uses: actions/setup-node@v6
with:
node-version: 24
cache: npm
cache-dependency-path: sdk/package-lock.json
- name: Install SDK tooling
working-directory: sdk
run: npm ci
- name: Compare contracts with handwritten coverage
env:
MESSAGING_SPEC_PATH: ${{ inputs.messaging_spec_path }}
PLATFORM_SPEC_PATH: ${{ inputs.platform_spec_path }}
working-directory: sdk
run: |
node scripts/check-coverage.mjs \
--messaging "../source/$MESSAGING_SPEC_PATH" \
--platform "../source/$PLATFORM_SPEC_PATH" \
--ledger contracts/coverage.json \
--report "$RUNNER_TEMP/sdk-coverage.json"
- name: Save coverage evidence before tracker synchronization
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a
with:
name: sdk-coverage-${{ inputs.source_sha }}
path: ${{ runner.temp }}/sdk-coverage.json
retention-days: 90
- name: Reconcile engineering coverage in Linear
env:
LINEAR_API_KEY: ${{ secrets.LINEAR_API_KEY }}
LINEAR_TEAM_ID: ${{ vars.LINEAR_TEAM_ID }}
SOURCE_REPOSITORY: ${{ inputs.source_repository }}
SOURCE_SHA: ${{ inputs.source_sha }}
COVERAGE_REPORT: ${{ runner.temp }}/sdk-coverage.json
COVERAGE_LINKS_OUTPUT: ${{ runner.temp }}/linear-coverage-links.json
working-directory: sdk
run: node scripts/sync-linear-coverage.mjs
- name: Save feature-to-ticket mappings
if: success()
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a
with:
name: linear-coverage-links-${{ inputs.source_sha }}
path: ${{ runner.temp }}/linear-coverage-links.json
retention-days: 90