From 8aace7ae81462add163d0a5bcce134887eb34cd1 Mon Sep 17 00:00:00 2001 From: Alec Swanson Date: Thu, 4 Jan 2024 10:42:44 -0800 Subject: [PATCH 1/3] fix: Add job to validate data source ids * Creates a new job in the validation workflow * Updates error output to the correct wording --- .github/workflows/validate_packs.yml | 40 +++++++++++++++++++++++ utils/validate-quickstart-data-sources.ts | 6 ++-- 2 files changed, 43 insertions(+), 3 deletions(-) diff --git a/.github/workflows/validate_packs.yml b/.github/workflows/validate_packs.yml index fe93f4cfd6..f95a5e71e6 100644 --- a/.github/workflows/validate_packs.yml +++ b/.github/workflows/validate_packs.yml @@ -204,6 +204,46 @@ jobs: statusContext: "Validation / Install plan ids exist" state: ${{ job.status }} + validate-data-source-ids: + name: Validate data source ids + runs-on: ubuntu-latest + steps: + - name: Download artifact + uses: dawidd6/action-download-artifact@v2 + with: + workflow: validation_gate.yml + run_id: ${{ github.event.workflow_run.id }} + + - name: Get PR number + id: get_pr_number + run: | + export PR_NUMBER=$(cat artifact/pr_number.txt) + echo "pr-number=$PR_NUMBER" >> $GITHUB_ENV + + - name: Checkout repository + uses: actions/checkout@v3 + with: + ref: "refs/pull/${{ env.pr-number }}/merge" + + - name: Setup workspace + uses: './.github/actions/bootstrap' + + - name: Validate new files + id: validation + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + PR_NUMBER: ${{ env.pr-number }} + run: | + URL="https://api.github.com/repos/${GITHUB_REPOSITORY}/pulls/$PR_NUMBER/files" + cd utils && yarn validate-quickstart-data-sources "$URL" + + - name: Add commit status + if: always() + uses: './.github/actions/add-commit-status' + with: + statusContext: "Validation / Data source ids exist" + state: ${{ job.status }} + ensure-quickstart-dashboard-names-are-unique: name: Ensure quickstart dashboard names are unique runs-on: ubuntu-latest diff --git a/utils/validate-quickstart-data-sources.ts b/utils/validate-quickstart-data-sources.ts index 81ea86e2b3..fd69759af6 100644 --- a/utils/validate-quickstart-data-sources.ts +++ b/utils/validate-quickstart-data-sources.ts @@ -56,16 +56,16 @@ export const validateDataSourceIds = async ( if (quickstartsWithInvalidDataSources.length > 0) { console.error( - `ERROR: Found install plans with no corresponding data source id.\n` + `ERROR: Found quickstarts with no corresponding data source id.\n` ); - console.error(`An install plan id must match an existing data source id.`); + console.error(`An data source id must match an existing data source id.`); quickstartsWithInvalidDataSources.forEach((m) => console.error( `- ${m.invalidDataSourceIds.join(', ')} in ${m.quickstart.configPath}` ) ); console.error( - `\nPlease change to an existing install plan id or remove the ids.` + `\nPlease change to an existing data source id or remove the ids.` ); if (require.main === module) { From ee160b9e6725f4e3cf5854e574aba1013aeebd3d Mon Sep 17 00:00:00 2001 From: Alec Swanson Date: Thu, 4 Jan 2024 10:43:50 -0800 Subject: [PATCH 2/3] chore: Add new validation job to branch protection --- .github/workflows/pr-merged.yml | 1 + .github/workflows/release.yml | 1 + 2 files changed, 2 insertions(+) diff --git a/.github/workflows/pr-merged.yml b/.github/workflows/pr-merged.yml index 5fc053a693..04ffea964f 100644 --- a/.github/workflows/pr-merged.yml +++ b/.github/workflows/pr-merged.yml @@ -87,6 +87,7 @@ jobs: 'Validation / Image count and extension compliance', 'Validation / Ensure icons exist', 'Validation / Install plan ids exist', + 'Validation / Validate data source ids', 'Validation / Install plan schema compliance', 'Validation / Data source schema compliance', 'Validation / Quickstart id are unique', diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 973e930367..8206e9da98 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -79,6 +79,7 @@ jobs: 'Validation / Image count and extension compliance', 'Validation / Ensure icons exist', 'Validation / Install plan ids exist', + 'Validation / Validate data source ids', 'Validation / Install plan schema compliance', 'Validation / Data source schema compliance', 'Validation / Quickstart id are unique', From 15650e6ca267576652279ee4a1e13258c74068f2 Mon Sep 17 00:00:00 2001 From: Alec Swanson Date: Thu, 4 Jan 2024 11:07:29 -0800 Subject: [PATCH 3/3] fix: Add needed environment variables --- .github/workflows/validate_packs.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/validate_packs.yml b/.github/workflows/validate_packs.yml index f95a5e71e6..64e5e50a80 100644 --- a/.github/workflows/validate_packs.yml +++ b/.github/workflows/validate_packs.yml @@ -233,6 +233,8 @@ jobs: env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} PR_NUMBER: ${{ env.pr-number }} + NR_API_URL: ${{ secrets.NR_API_URL }} + NR_API_TOKEN: ${{ secrets.NR_API_TOKEN }} run: | URL="https://api.github.com/repos/${GITHUB_REPOSITORY}/pulls/$PR_NUMBER/files" cd utils && yarn validate-quickstart-data-sources "$URL"