Repository navigation
124 lines (108 loc) · 4.4 KB
/
Copy pathopenapi-diff.yml
File metadata and controls
124 lines (108 loc) · 4.4 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
name: openapi-diff
on:
pull_request:
# Cancel in progress workflows on pull_requests.
# https://docs.github.com/en/actions/using-jobs/using-concurrency#example-using-a-fallback-value
concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
cancel-in-progress: true
# hack for https://github.com/actions/cache/issues/810#issuecomment-1222550359
env:
SEGMENT_DOWNLOAD_TIMEOUT_MINS: 3
# Shared by the jobs below: the artifact the build job hands to the compare
# jobs, and where it puts the PR's RPC schema and the baseline schemas.
DIFF_ARTIFACT: openapi-diff
RPC_SCHEMA: .artifacts/rpc_method_schema.json
BASELINE_DIR: .artifacts/openapi-baseline
jobs:
# Builds this PR's public spec and RPC schema, and fetches the ones on master
# where the PR branched off, for the jobs below to compare.
build:
name: Build the API schemas to compare
runs-on: ubuntu-26.04-arm
timeout-minutes: 90
permissions:
# Artifacts of the openapi workflow on master hold the baselines.
actions: read
contents: read
pull-requests: read
outputs:
api_docs: ${{ steps.changes.outputs.api_docs }}
steps:
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
- name: Check for python file changes
uses: dorny/paths-filter@7b450fff21473bca461d4b92ce414b9d0420d706 # v4.0.2
id: changes
with:
token: ${{ github.token }}
filters: .github/file-filters.yml
- name: Setup sentry env
uses: ./.github/actions/setup-sentry
with:
mode: migrations
if: steps.changes.outputs.api_docs == 'true'
- uses: ./.github/actions/setup-node-pnpm
if: steps.changes.outputs.api_docs == 'true'
- name: Build OpenAPI Derefed JSON
if: steps.changes.outputs.api_docs == 'true'
run: make build-api-docs
- name: Build RPC method schema
if: steps.changes.outputs.api_docs == 'true'
run: make build-rpc-schema
- name: Fetch the merge-base's schemas
if: steps.changes.outputs.api_docs == 'true'
env:
GH_TOKEN: ${{ github.token }}
BASE_SHA: ${{ github.event.pull_request.base.sha }}
HEAD_SHA: ${{ github.event.pull_request.head.sha }}
run: .github/workflows/scripts/openapi-diff.sh baseline "$BASELINE_DIR"
- name: Upload the schemas to compare
if: steps.changes.outputs.api_docs == 'true'
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
with:
name: ${{ env.DIFF_ARTIFACT }}
path: |
tests/apidocs/openapi-derefed.json
${{ env.RPC_SCHEMA }}
${{ env.BASELINE_DIR }}/
include-hidden-files: true
if-no-files-found: error
retention-days: 7
changelog:
name: Public API changelog
needs: build
if: needs.build.outputs.api_docs == 'true'
runs-on: ubuntu-24.04
timeout-minutes: 15
permissions:
contents: read
steps:
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
with:
sparse-checkout: .github/workflows/scripts
- uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4.3.0
with:
name: ${{ env.DIFF_ARTIFACT }}
# Writes the changelog to the job summary. It is information for the
# author and reviewers, so it never fails the build.
- name: Summarize public API changes
run: .github/workflows/scripts/openapi-diff.sh changelog "$BASELINE_DIR/openapi-derefed.json" tests/apidocs/openapi-derefed.json
rpc-breaking:
name: RPC schema breaking changes
needs: build
if: needs.build.outputs.api_docs == 'true'
runs-on: ubuntu-24.04
timeout-minutes: 15
permissions:
contents: read
steps:
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
with:
sparse-checkout: .github/workflows/scripts
- uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4.3.0
with:
name: ${{ env.DIFF_ARTIFACT }}
# Control and cell silos deploy separately, so an RPC change must keep
# working with callers built from the merge-base.
- name: Check RPC schema for breaking changes
run: .github/workflows/scripts/openapi-diff.sh rpc-breaking "$BASELINE_DIR/rpc_method_schema.json" "$RPC_SCHEMA"