Skip to content

Commit

Permalink
Merge pull request #2183 from newrelic/alec/validate-ds-ids
Browse files Browse the repository at this point in the history
Properly validate data source id references on quickstarts
  • Loading branch information
aswanson-nr authored Jan 4, 2024
2 parents 77fb064 + 15650e6 commit b04b665
Show file tree
Hide file tree
Showing 4 changed files with 47 additions and 3 deletions.
1 change: 1 addition & 0 deletions .github/workflows/pr-merged.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
42 changes: 42 additions & 0 deletions .github/workflows/validate_packs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,48 @@ 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 }}
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"
- 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
Expand Down
6 changes: 3 additions & 3 deletions utils/validate-quickstart-data-sources.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit b04b665

Please sign in to comment.