forked from opensearch-project/opensearch-protobufs
-
Notifications
You must be signed in to change notification settings - Fork 0
136 lines (119 loc) · 4.84 KB
/
Copy pathbackward-compatible-report.yml
File metadata and controls
136 lines (119 loc) · 4.84 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
131
132
133
134
135
136
name: Backward Compatible Report
on:
workflow_call:
inputs:
opensearch_version:
description: 'OpenSearch version. Leave empty to fetch latest.'
required: false
type: string
spec_artifact_name:
description: 'Name of the uploaded artifact containing opensearch-openapi.yaml'
required: false
type: string
default: 'openapi-spec'
outputs:
report:
description: 'The compatibility report in markdown format'
value: ${{ jobs.generate-report.outputs.report }}
workflow_dispatch:
inputs:
opensearch_version:
description: 'OpenSearch version. Leave empty to fetch latest.'
required: false
type: string
jobs:
generate-report:
runs-on: ubuntu-latest
outputs:
report: ${{ steps.merge_report.outputs.report }}
steps:
- name: Checkout Repository
uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4
with:
repository: ${{ github.repository_owner }}/opensearch-protobufs
ref: main
- name: Setup Node.js
uses: actions/setup-node@3235b876344d2a9aa001b8d1453c930bba69e610 # v3
with:
node-version: 20
- name: Setup Java
uses: actions/setup-java@17f84c3641ba7b8f6deff6309fc4c864478f5d62 # v3
with:
distribution: temurin
java-version: 17
- name: Download OpenAPI spec artifact
if: ${{ inputs.spec_artifact_name != '' }}
uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4
with:
name: ${{ inputs.spec_artifact_name }}
path: .
- name: Get Latest OpenSearch Core Version
id: get_opensearch_version
uses: actions/github-script@d7906e4ad0b1822421a7e6a35d5ca353c962f410 # v6
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
// Check if version was provided as input
const inputVersion = "${{ inputs.opensearch_version }}";
if (inputVersion && inputVersion.trim() !== "") {
core.setOutput("version", inputVersion.trim());
console.log("Using provided OpenSearch version: " + inputVersion.trim());
return;
}
// Otherwise fetch version from buildSrc/version.properties on main branch
try {
const response = await github.request(
'GET /repos/{owner}/{repo}/contents/{path}',
{
owner: 'opensearch-project',
repo: 'OpenSearch',
path: 'buildSrc/version.properties',
ref: 'main'
}
);
// Decode the file content
const content = Buffer.from(response.data.content, 'base64').toString('utf-8');
// Extract opensearch version (e.g., "opensearch = 3.4.0")
const match = content.match(/opensearch\s*=\s*([^\s]+)/);
if (match && match[1]) {
const version = match[1].trim();
core.setOutput("version", version);
console.log("Fetched OpenSearch version from source: " + version);
} else {
core.setFailed("Could not find opensearch version in version.properties");
}
} catch (error) {
core.setFailed("Could not fetch OpenSearch version: " + error.message);
}
- name: Run Proto Conversion
env:
OPENSEARCH_VERSION: ${{ steps.get_opensearch_version.outputs.version }}
run: npm ci && npm run preprocessing -- --opensearch-version "$OPENSEARCH_VERSION"
- name: Convert protobuf
env:
OPENAPI_GENERATOR_VERSION: 7.19.0
run: |
npx --yes @openapitools/openapi-generator-cli generate \
-c tools/proto-convert/src/config/protobuf-generator-config.yaml
- name: Check for auto-pr-branch and use its protos if exists
run: |
# Check if auto-pr-branch exists
if git ls-remote --exit-code --heads origin auto-pr-branch > /dev/null 2>&1; then
echo "Found auto-pr-branch, using its proto files for comparison"
git fetch origin auto-pr-branch
git checkout origin/auto-pr-branch -- protos/schemas/
else
echo "auto-pr-branch not found, using main branch proto files"
fi
- name: Post Process Protobuf (dry-run for report)
id: merge_report
run: |
npm run postprocessing:dry-run
REPORT_PATH="/tmp/merge-report.md"
echo "=== Compatibility Report ==="
cat "$REPORT_PATH"
echo "============================="
REPORT=$(cat "$REPORT_PATH")
echo "report<<EOF" >> $GITHUB_OUTPUT
echo "$REPORT" >> $GITHUB_OUTPUT
echo "EOF" >> $GITHUB_OUTPUT