IPA Validation Metrics Release #503
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # This workflow will generate metrics about the IPA validation on the current OAS | |
| # (number of adoptions, violations and exceptions) and upload the data to an S3 bucket. | |
| name: IPA Validation Metrics Release | |
| on: | |
| schedule: | |
| - cron: '0 11 * * *' # Runs daily at 11:00 UTC (11 AM UTC) | |
| workflow_dispatch: | |
| permissions: | |
| issues: write | |
| contents: write | |
| id-token: write | |
| jobs: | |
| # Generates and uploads the IPA validation metrics to S3 | |
| release-IPA-metrics: | |
| name: Release IPA Validation Metrics | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout repository (scripts) | |
| uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd | |
| with: | |
| sparse-checkout: | | |
| tools/spectral/ipa | |
| package.json | |
| package-lock.json | |
| .github/scripts | |
| - name: Setup Node | |
| uses: actions/setup-node@v6 | |
| with: | |
| node-version: '20.x' | |
| cache: 'npm' | |
| - name: Install npm dependencies | |
| run: npm install | |
| - name: Install FOASCLI | |
| env: | |
| foascli_version: ${{ vars.FOASCLI_VERSION }} | |
| run: | | |
| wget https://github.com/mongodb/openapi/releases/download/v"${foascli_version}"/mongodb-foas-cli_"${foascli_version}"_linux_x86_64.tar.gz -O foascli.tar.gz | |
| tar -xzvf foascli.tar.gz | |
| pushd mongodb-foas-cli_* | |
| echo "$(pwd)/bin" >> "${GITHUB_PATH}" | |
| popd | |
| - name: Fetch OAS file from Dev Branch | |
| run: curl -O "https://raw.githubusercontent.com/mongodb/openapi/refs/heads/dev/openapi/.raw/v2.json" | |
| working-directory: ${{ github.workspace }} | |
| - name: Get versions excluding private preview | |
| run: | | |
| foascli versions -s v2.json --env dev --stability-level stable --stability-level preview --stability-level upcoming -o versions.json | |
| cat versions.json | |
| working-directory: ${{ github.workspace }} | |
| - name: Filter OAS to exclude private preview versions | |
| run: | | |
| cmd="foascli filter -s v2.json --env dev --keep-ipa-exceptions" | |
| while IFS= read -r version; do | |
| cmd="${cmd} --version ${version}" | |
| done < <(jq -r '.[]' versions.json) | |
| cmd="${cmd} -o v2-filtered.json" | |
| eval "${cmd}" | |
| working-directory: ${{ github.workspace }} | |
| - name: Upload OAS files as artifacts | |
| uses: actions/upload-artifact@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f | |
| with: | |
| name: oas-files | |
| path: | | |
| ${{ github.workspace }}/v2.json | |
| ${{ github.workspace }}/v2-filtered.json | |
| ${{ github.workspace }}/versions.json | |
| retention-days: 1 | |
| - name: Run Metric Collection Job | |
| id: metric-collection | |
| working-directory: tools/spectral/ipa/metrics/scripts | |
| run: | | |
| node runMetricCollection.js "${{ github.workspace }}/v2-filtered.json" | |
| echo "WARNING_COUNT=$(cat ../outputs/warning-count.txt)" >> "$GITHUB_ENV" | |
| - name: Upload Warning Violations as Artifact | |
| uses: actions/upload-artifact@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f | |
| with: | |
| name: warning-violations | |
| path: tools/spectral/ipa/metrics/outputs/warning-violations.json | |
| retention-days: 1 | |
| - name: aws configure | |
| uses: aws-actions/configure-aws-credentials@v6 | |
| with: | |
| role-to-assume: ${{ vars.IPA_METRIC_COLLECTION_AWS_S3_ROLE_TO_ASSUME_PROD }} | |
| aws-region: ${{ vars.AWS_DEFAULT_REGION }} | |
| - name: Dump Metric Collection Job Data to S3 | |
| env: | |
| AWS_REGION: ${{ vars.AWS_DEFAULT_REGION }} | |
| S3_BUCKET_PREFIX: ${{ secrets.IPA_S3_BUCKET_DW_PROD_PREFIX }} | |
| working-directory: tools/spectral/ipa/metrics/scripts | |
| run: node dataDump.js | |
| - name: Handle Warning Violations | |
| env: | |
| TEAM_ID: ${{ vars.JIRA_TEAM_ID_APIX_PLATFORM }} | |
| JIRA_API_TOKEN: ${{ secrets.JIRA_API_TOKEN }} | |
| SLACK_BEARER_TOKEN: ${{ secrets.SLACK_BEARER_TOKEN }} | |
| SLACK_CHANNEL_ID: ${{ secrets.SLACK_CHANNEL_ID_APIX_PLATFORM_DEV }} | |
| SLACK_ONCALL_USER: ${{ secrets.SLACK_APIX_PLATFORM_ONCALL_USER }} | |
| run: .github/scripts/handle_warning_violations.sh | |
| failure-handler: | |
| name: Failure Handler | |
| needs: [ release-IPA-metrics ] | |
| if: ${{ failure() }} | |
| uses: ./.github/workflows/failure-handler.yml | |
| with: | |
| env: 'dev' | |
| release_name: "IPA Metrics" | |
| team_id: ${{ vars.JIRA_TEAM_ID_APIX_PLATFORM }} | |
| secrets: | |
| jira_api_token: ${{ secrets.JIRA_API_TOKEN }} |