Skip to content

Commit a1aea1b

Browse files
CLOUDP-298521: Decouple IPA Metrics Collection Job from FOAS Release GH Workflow (#401)
1 parent fac3425 commit a1aea1b

File tree

4 files changed

+47
-102
lines changed

4 files changed

+47
-102
lines changed

.github/workflows/release-IPA-metrics.yml

Lines changed: 46 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -2,85 +2,73 @@
22
# (number of adoptions, violations and exceptions) and upload the data to an S3 bucket.
33
name: IPA Validation Metrics Release
44
on:
5-
workflow_call:
6-
secrets: # all secrets are passed explicitly in this workflow
7-
aws_access_key:
8-
required: true
9-
aws_secret_key:
10-
required: true
11-
aws_s3_bucket_prefix:
12-
required: true
13-
api_bot_pat:
14-
required: true
15-
inputs:
16-
env:
17-
description: 'Environment for the FOAS to use for IPA metrics collection'
18-
required: true
19-
type: string
5+
schedule:
6+
- cron: '0 11 * * *' # Runs daily at 11:00 UTC (11 AM UTC)
207
workflow_dispatch:
21-
228
permissions:
239
issues: write
10+
env:
11+
NODE_VERSION: '20.x'
12+
OAS_BRANCH: 'dev'
13+
OAS_FILE: 'openapi/v2.json'
14+
IPA_PATH: ${{ github.workspace }}/ipa
15+
DEV_OAS_PATH: ${{ github.workspace }}/dev-oas
2416

2517
jobs:
26-
# Checks the last workflow run, and decides whether the IPA release metrics should be uploaded or
27-
# skipped. The release-IPA-metrics job only runs if the last release was not today and did not fail.
28-
pre-IPA-metrics-release-checks:
29-
name: IPA Metrics Release Pre-Checks
30-
runs-on: ubuntu-latest
31-
outputs:
32-
should_run_release: ${{ steps.get_previous_status.outputs.result }}
33-
steps:
34-
- name: Checkout
35-
uses: actions/checkout@v4
36-
37-
- name: Get Previous Run Date and Status
38-
id: get_previous_status
39-
uses: actions/github-script@v7
40-
with:
41-
github-token: ${{ secrets.api_bot_pat }}
42-
script: |
43-
const { default: getShouldRunMetricsRelease } = await import('${{ github.workspace }}/tools/spectral/ipa/metrics/scripts/getShouldRunMetricsRelease.js')
44-
const shouldRunRelease = await getShouldRunMetricsRelease({github, context}).catch((error) => {
45-
console.error(error.message);
46-
process.exit(1)
47-
})
48-
return shouldRunRelease
49-
5018
# Generates and uploads the IPA validation metrics to S3
5119
release-IPA-metrics:
5220
name: Release IPA Validation Metrics
53-
needs: [pre-IPA-metrics-release-checks]
54-
if: ${{ needs.pre-IPA-metrics-release-checks.outputs.should_run_release == 'true' }}
5521
runs-on: ubuntu-latest
5622
steps:
57-
- name: Checkout
58-
uses: actions/checkout@v4
23+
- name: Checkout repository (scripts)
24+
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332
25+
with:
26+
sparse-checkout:
27+
tools/spectral/ipa
28+
path: ipa
29+
30+
- name: Checkout repository (dev branch)
31+
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332
32+
with:
33+
ref: $OAS_BRANCH
34+
sparse-checkout: $OAS_FILE
35+
path: dev-oas
36+
37+
- name: Validate OAS file
38+
run: |
39+
if [ ! -f "dev-oas/$OAS_FILE" ]; then
40+
echo "::error::OAS file not found in $OAS_BRANCH branch"
41+
exit 1
42+
fi
5943
6044
- name: Setup Node
6145
uses: actions/setup-node@v4
6246
with:
63-
node-version: '20.x'
47+
node-version: $NODE_VERSION
6448
cache: 'npm'
6549

6650
- name: Install npm dependencies
6751
run: npm install
6852

69-
- name: Download openapi-foas
70-
uses: actions/download-artifact@v4
71-
with:
72-
name: openapi-foas-${{ inputs.env }}
73-
github-token: ${{ secrets.api_bot_pat }}
74-
run-id: ${{ github.run_id }}
75-
7653
- name: Run Metric Collection Job
77-
working-directory: ./tools/spectral/ipa/metrics/scripts
78-
run: node runMetricCollection.js ../../../../../openapi-foas.json
54+
working-directory: $IPA_PATH/metrics/scripts
55+
run: node runMetricCollection.js "$DEV_OAS_PATH/openapi/v2.json"
7956

8057
- name: Dump Metric Collection Job Data to S3
8158
env:
82-
AWS_ACCESS_KEY_ID: ${{ secrets.aws_access_key }}
83-
AWS_SECRET_ACCESS_KEY: ${{ secrets.aws_secret_key }}
84-
S3_BUCKET_PREFIX: ${{ secrets.aws_s3_bucket_prefix }}
85-
working-directory: ./tools/spectral/ipa/metrics/scripts
59+
AWS_ACCESS_KEY_ID: ${{ secrets.IPA_S3_BUCKET_DW_STAGING_USERNAME }}
60+
AWS_SECRET_ACCESS_KEY: ${{ secrets.IPA_S3_BUCKET_DW_STAGING_PASSWORD }}
61+
S3_BUCKET_PREFIX: ${{ secrets.IPA_S3_BUCKET_DW_STAGING_PREFIX }}
62+
working-directory: $IPA_PATH/metrics/scripts
8663
run: node dataDump.js
64+
65+
failure-handler:
66+
name: Failure Handler
67+
needs: [ release-IPA-metrics ]
68+
if: ${{ failure() }}
69+
uses: ./.github/workflows/failure-handler.yml
70+
with:
71+
env: $OAS_BRANCH
72+
release_name: "IPA Metrics"
73+
secrets:
74+
jira_api_token: ${{ secrets.JIRA_API_TOKEN }}

.github/workflows/release-spec-runner.yml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,9 +52,6 @@ jobs:
5252
secrets:
5353
api_bot_pat: ${{ secrets.API_BOT_PAT }}
5454
jira_api_token: ${{ secrets.JIRA_API_TOKEN }}
55-
ipa_aws_access_key: ${{ secrets.IPA_S3_BUCKET_DW_STAGING_USERNAME}}
56-
ipa_aws_secret_key: ${{ secrets.IPA_S3_BUCKET_DW_STAGING_PASSWORD}}
57-
ipa_aws_s3_bucket_prefix: ${{ secrets.IPA_S3_BUCKET_DW_STAGING_PREFIX}}
5855
with:
5956
aws_default_region: ${{ vars.AWS_DEFAULT_REGION}}
6057
aws_s3_bucket: ${{ vars.S3_BUCKET_DEV}}

.github/workflows/release-spec.yml

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -184,22 +184,9 @@ jobs:
184184
branch: ${{ inputs.branch }}
185185
foascli_version: ${{ inputs.foascli_version }}
186186

187-
release-IPA-metrics:
188-
name: Release IPA Validation Metrics
189-
needs: release
190-
if: ${{ inputs.env == 'dev' && needs.release.outputs.changes_detected == 'true' }}
191-
uses: ./.github/workflows/release-IPA-metrics.yml
192-
secrets:
193-
aws_access_key: ${{ secrets.ipa_aws_access_key}}
194-
aws_secret_key: ${{ secrets.ipa_aws_secret_key}}
195-
aws_s3_bucket_prefix: ${{ secrets.ipa_aws_s3_bucket_prefix}}
196-
api_bot_pat: ${{ secrets.api_bot_pat }}
197-
with:
198-
env: ${{ inputs.env }}
199-
200187
failure-handler:
201188
name: Failure Handler
202-
needs: [ release, release-postman, release-changelog, release-IPA-metrics ]
189+
needs: [ release, release-postman, release-changelog]
203190
if: ${{ always() && contains(needs.*.result, 'failure') }}
204191
uses: ./.github/workflows/failure-handler.yml
205192
with:

tools/spectral/ipa/metrics/scripts/getShouldRunMetricsRelease.js

Lines changed: 0 additions & 27 deletions
This file was deleted.

0 commit comments

Comments
 (0)