diff --git a/.github/workflows/pr-checks.yml b/.github/workflows/pr-checks.yml index 1e83a4ea7a..467af8b47d 100644 --- a/.github/workflows/pr-checks.yml +++ b/.github/workflows/pr-checks.yml @@ -1,6 +1,6 @@ name: Validate PR Artifact -on: +on: pull_request: jobs: @@ -15,3 +15,16 @@ jobs: uses: "./.github/actions/bootstrap" - name: Validate PR Artifact uses: "./.github/actions/build-validate-artifact" + validate-quickstart-ids: + runs-on: ubuntu-latest + if: ${{ github.base_ref == 'main' && github.head_ref == 'release' }} + steps: + - name: Checkout repository + uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 + with: + ref: ${{ github.sha }} + - name: Setup workspace + uses: "./.github/actions/bootstrap" + - name: Validate Quickstart IDs + run: | + cd utils && yarn validate-quickstart-ids diff --git a/utils/package.json b/utils/package.json index 2c5c738747..65cd01ecfe 100644 --- a/utils/package.json +++ b/utils/package.json @@ -23,7 +23,8 @@ "set-alert-policy-required-datasources": "ts-node set-alert-policy-required-datasources.ts", "set-dashboards-required-datasources": "ts-node set-dashboards-required-datasources.ts", "release": "ts-node release.ts", - "add-datasource-ids": "cd ./schema && ts-node add-datasource-ids.ts" + "add-datasource-ids": "cd ./schema && ts-node add-datasource-ids.ts", + "validate-quickstart-ids": "ts-node validate-quickstart-ids.ts" }, "dependencies": { "@actions/core": "^1.10.0", diff --git a/utils/schema/artifact.json b/utils/schema/artifact.json index 0b36de8fd6..0114436fe4 100644 --- a/utils/schema/artifact.json +++ b/utils/schema/artifact.json @@ -79,7 +79,6 @@ } }, "required": [ - "id", "description", "summary", "title", diff --git a/utils/validate-quickstart-ids.ts b/utils/validate-quickstart-ids.ts new file mode 100644 index 0000000000..e9603090ad --- /dev/null +++ b/utils/validate-quickstart-ids.ts @@ -0,0 +1,43 @@ +import * as fs from 'fs'; +import * as path from 'path'; +import * as glob from 'glob'; +import * as yaml from 'js-yaml'; + +import { QuickstartConfig } from './types/QuickstartConfig'; + +const getQuickstartPaths = () => + glob.sync(path.resolve('..', 'quickstarts', '**', 'config.+(yml|yaml)')); + +const findMissingIds = (quickstartPaths: string[]) => { + const quickstartsMissingIds: string[] = []; + + quickstartPaths.forEach((filePath) => { + const config = yaml.load( + fs.readFileSync(filePath).toString('utf-8') + ) as QuickstartConfig; + + if (!config.id) { + quickstartsMissingIds.push(config.title); + } + }); + + return quickstartsMissingIds; +}; + +const main = () => { + const quickstartPaths = getQuickstartPaths(); + const quickstartsMissingIds = findMissingIds(quickstartPaths); + + if (quickstartsMissingIds.length > 0) { + console.log('\nThe following quickstarts are missing IDs:'); + quickstartsMissingIds.forEach((title) => console.log(`\t- ${title}`)); + + process.exit(1); + } + + console.log('[*] All quickstarts have IDs'); +}; + +if (require.main === module) { + main(); +}