Skip to content

Commit 8eb4be9

Browse files
CLOUDP-298521: Decouple IPA Metrics Collection Job from FOAS Release GH Workflow
1 parent 2b2f6fe commit 8eb4be9

File tree

3 files changed

+26
-67
lines changed

3 files changed

+26
-67
lines changed

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

Lines changed: 25 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -2,56 +2,20 @@
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 22 * * *' # Runs daily at 22:00 UTC (10 PM UTC)
207
workflow_dispatch:
21-
228
permissions:
239
issues: write
10+
env:
11+
NODE_VERSION: '20.x'
12+
WORKING_DIR: ./tools/spectral/ipa/metrics/scripts
13+
RELEASE_ENV: 'dev'
2414

2515
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-
5016
# Generates and uploads the IPA validation metrics to S3
5117
release-IPA-metrics:
5218
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' }}
5519
runs-on: ubuntu-latest
5620
steps:
5721
- name: Checkout
@@ -60,7 +24,7 @@ jobs:
6024
- name: Setup Node
6125
uses: actions/setup-node@v4
6226
with:
63-
node-version: '20.x'
27+
node-version: ${{ env.NODE_VERSION }}
6428
cache: 'npm'
6529

6630
- name: Install npm dependencies
@@ -69,18 +33,29 @@ jobs:
6933
- name: Download openapi-foas
7034
uses: actions/download-artifact@v4
7135
with:
72-
name: openapi-foas-${{ inputs.env }}
73-
github-token: ${{ secrets.api_bot_pat }}
36+
name: openapi-foas-${{ env.RELEASE_ENV }}
37+
github-token: ${{ secrets.API_BOT_PAT }}
7438
run-id: ${{ github.run_id }}
7539

7640
- name: Run Metric Collection Job
77-
working-directory: ./tools/spectral/ipa/metrics/scripts
41+
working-directory: ${{ env.WORKING_DIR }}
7842
run: node runMetricCollection.js ../../../../../openapi-foas.json
7943

8044
- name: Dump Metric Collection Job Data to S3
8145
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
46+
AWS_ACCESS_KEY_ID: ${{ secrets.IPA_S3_BUCKET_DW_STAGING_USERNAME }}
47+
AWS_SECRET_ACCESS_KEY: ${{ secrets.IPA_S3_BUCKET_DW_STAGING_PASSWORD }}
48+
S3_BUCKET_PREFIX: ${{ secrets.IPA_S3_BUCKET_DW_STAGING_PREFIX }}
49+
working-directory: ${{ env.WORKING_DIR }}
8650
run: node dataDump.js
51+
52+
failure-handler:
53+
name: Failure Handler
54+
needs: [ release-IPA-metrics ]
55+
if: ${{ always() && contains(needs.*.result, 'failure') }}
56+
uses: ./.github/workflows/failure-handler.yml
57+
with:
58+
env: ${{ env.RELEASE_ENV }}
59+
release_name: "OpenAPI Spec"
60+
secrets:
61+
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:

0 commit comments

Comments
 (0)