|
2 | 2 | # (number of adoptions, violations and exceptions) and upload the data to an S3 bucket. |
3 | 3 | name: IPA Validation Metrics Release |
4 | 4 | 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) |
20 | 7 | workflow_dispatch: |
21 | | - |
22 | 8 | permissions: |
23 | 9 | 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 |
24 | 16 |
|
25 | 17 | 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 | | -
|
50 | 18 | # Generates and uploads the IPA validation metrics to S3 |
51 | 19 | release-IPA-metrics: |
52 | 20 | 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' }} |
55 | 21 | runs-on: ubuntu-latest |
56 | 22 | 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 |
59 | 43 |
|
60 | 44 | - name: Setup Node |
61 | 45 | uses: actions/setup-node@v4 |
62 | 46 | with: |
63 | | - node-version: '20.x' |
| 47 | + node-version: $NODE_VERSION |
64 | 48 | cache: 'npm' |
65 | 49 |
|
66 | 50 | - name: Install npm dependencies |
67 | 51 | run: npm install |
68 | 52 |
|
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 | | - |
76 | 53 | - 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" |
79 | 56 |
|
80 | 57 | - name: Dump Metric Collection Job Data to S3 |
81 | 58 | 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 |
86 | 63 | 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 }} |
0 commit comments