Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
76 changes: 25 additions & 51 deletions .github/workflows/release-IPA-metrics.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,56 +2,20 @@
# (number of adoptions, violations and exceptions) and upload the data to an S3 bucket.
name: IPA Validation Metrics Release
on:
workflow_call:
secrets: # all secrets are passed explicitly in this workflow
aws_access_key:
required: true
aws_secret_key:
required: true
aws_s3_bucket_prefix:
required: true
api_bot_pat:
required: true
inputs:
env:
description: 'Environment for the FOAS to use for IPA metrics collection'
required: true
type: string
schedule:
- cron: '0 22 * * *' # Runs daily at 22:00 UTC (10 PM UTC)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What are the reasons to run it outside working hours? Keep in mind that you will get a notification if the action fails

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point. Changed it to 11:00 AM. Do we have any standards around it?

Copy link
Collaborator

@lovisaberggren lovisaberggren Feb 5, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Related: Perhaps we should only run mon-fri as well? The OASes don't get updated during the weekend either AFAIK

Copy link
Collaborator

@andreaangiolillo andreaangiolillo Feb 5, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we have any standards around it?

No, it is up to the team. Ideally, it should be working hours so that we can action on failure

Copy link
Collaborator Author

@yelizhenden-mdb yelizhenden-mdb Feb 5, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Related: Perhaps we should only run mon-fri as well? The OASes don't get updated during the weekend either AFAIK

Yes, but the metric collection job is not related to OAS updates anymore. And, DPE team asked us to send the data every day if possible. I checked with them about skipping weekend, but they need the data to be sent every day

workflow_dispatch:

permissions:
issues: write
env:
NODE_VERSION: '20.x'
WORKING_DIR: ./tools/spectral/ipa/metrics/scripts
RELEASE_ENV: 'dev'

jobs:
# Checks the last workflow run, and decides whether the IPA release metrics should be uploaded or
# skipped. The release-IPA-metrics job only runs if the last release was not today and did not fail.
pre-IPA-metrics-release-checks:
name: IPA Metrics Release Pre-Checks
runs-on: ubuntu-latest
outputs:
should_run_release: ${{ steps.get_previous_status.outputs.result }}
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Get Previous Run Date and Status
id: get_previous_status
uses: actions/github-script@v7
with:
github-token: ${{ secrets.api_bot_pat }}
script: |
const { default: getShouldRunMetricsRelease } = await import('${{ github.workspace }}/tools/spectral/ipa/metrics/scripts/getShouldRunMetricsRelease.js')
const shouldRunRelease = await getShouldRunMetricsRelease({github, context}).catch((error) => {
console.error(error.message);
process.exit(1)
})
return shouldRunRelease

# Generates and uploads the IPA validation metrics to S3
release-IPA-metrics:
name: Release IPA Validation Metrics
needs: [pre-IPA-metrics-release-checks]
if: ${{ needs.pre-IPA-metrics-release-checks.outputs.should_run_release == 'true' }}
runs-on: ubuntu-latest
steps:
- name: Checkout
Expand All @@ -60,7 +24,7 @@ jobs:
- name: Setup Node
uses: actions/setup-node@v4
with:
node-version: '20.x'
node-version: $NODE_VERSION
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cache: 'npm'

- name: Install npm dependencies
Expand All @@ -69,18 +33,28 @@ jobs:
- name: Download openapi-foas
uses: actions/download-artifact@v4
with:
name: openapi-foas-${{ inputs.env }}
github-token: ${{ secrets.api_bot_pat }}
run-id: ${{ github.run_id }}
name: openapi-foas-$RELEASE_ENV
github-token: ${{ secrets.API_BOT_PAT }}

- name: Run Metric Collection Job
working-directory: ./tools/spectral/ipa/metrics/scripts
working-directory: $WORKING_DIR
run: node runMetricCollection.js ../../../../../openapi-foas.json

- name: Dump Metric Collection Job Data to S3
env:
AWS_ACCESS_KEY_ID: ${{ secrets.aws_access_key }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.aws_secret_key }}
S3_BUCKET_PREFIX: ${{ secrets.aws_s3_bucket_prefix }}
working-directory: ./tools/spectral/ipa/metrics/scripts
AWS_ACCESS_KEY_ID: ${{ secrets.IPA_S3_BUCKET_DW_STAGING_USERNAME }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.IPA_S3_BUCKET_DW_STAGING_PASSWORD }}
S3_BUCKET_PREFIX: ${{ secrets.IPA_S3_BUCKET_DW_STAGING_PREFIX }}
working-directory: $WORKING_DIR
run: node dataDump.js

failure-handler:
name: Failure Handler
needs: [ release-IPA-metrics ]
if: ${{ failure() }}
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

uses: ./.github/workflows/failure-handler.yml
with:
env: $RELEASE_ENV
release_name: "OpenAPI Spec"
secrets:
jira_api_token: ${{ secrets.JIRA_API_TOKEN }}
3 changes: 0 additions & 3 deletions .github/workflows/release-spec-runner.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,6 @@ jobs:
secrets:
api_bot_pat: ${{ secrets.API_BOT_PAT }}
jira_api_token: ${{ secrets.JIRA_API_TOKEN }}
ipa_aws_access_key: ${{ secrets.IPA_S3_BUCKET_DW_STAGING_USERNAME}}
ipa_aws_secret_key: ${{ secrets.IPA_S3_BUCKET_DW_STAGING_PASSWORD}}
ipa_aws_s3_bucket_prefix: ${{ secrets.IPA_S3_BUCKET_DW_STAGING_PREFIX}}
with:
aws_default_region: ${{ vars.AWS_DEFAULT_REGION}}
aws_s3_bucket: ${{ vars.S3_BUCKET_DEV}}
Expand Down
15 changes: 1 addition & 14 deletions .github/workflows/release-spec.yml
Original file line number Diff line number Diff line change
Expand Up @@ -184,22 +184,9 @@ jobs:
branch: ${{ inputs.branch }}
foascli_version: ${{ inputs.foascli_version }}

release-IPA-metrics:
name: Release IPA Validation Metrics
needs: release
if: ${{ inputs.env == 'dev' && needs.release.outputs.changes_detected == 'true' }}
uses: ./.github/workflows/release-IPA-metrics.yml
secrets:
aws_access_key: ${{ secrets.ipa_aws_access_key}}
aws_secret_key: ${{ secrets.ipa_aws_secret_key}}
aws_s3_bucket_prefix: ${{ secrets.ipa_aws_s3_bucket_prefix}}
api_bot_pat: ${{ secrets.api_bot_pat }}
with:
env: ${{ inputs.env }}

failure-handler:
name: Failure Handler
needs: [ release, release-postman, release-changelog, release-IPA-metrics ]
needs: [ release, release-postman, release-changelog]
if: ${{ always() && contains(needs.*.result, 'failure') }}
uses: ./.github/workflows/failure-handler.yml
with:
Expand Down
Loading