diff --git a/.drone.yml b/.drone.yml index 224e42dc60c..b00daa6bcaf 100644 --- a/.drone.yml +++ b/.drone.yml @@ -339,6 +339,16 @@ steps: - yarn-install image: node:22-bookworm name: verify-i18n +- commands: + - yarn generate-apis + - "\n file_diff=$(git diff ':!conf')\n if [ -n \"$file_diff\" + ]; then\n echo $file_diff\n echo \"\nAPI client + generation has not been committed. Please run 'yarn generate-apis', commit the + changes and push again.\"\n exit 1\n fi\n " + depends_on: + - yarn-install + image: node:22-bookworm + name: verify-api-clients trigger: event: - pull_request @@ -1782,6 +1792,16 @@ steps: - yarn-install image: node:22-bookworm name: verify-i18n +- commands: + - yarn generate-apis + - "\n file_diff=$(git diff ':!conf')\n if [ -n \"$file_diff\" + ]; then\n echo $file_diff\n echo \"\nAPI client + generation has not been committed. Please run 'yarn generate-apis', commit the + changes and push again.\"\n exit 1\n fi\n " + depends_on: + - yarn-install + image: node:22-bookworm + name: verify-api-clients trigger: branch: main event: @@ -2916,6 +2936,16 @@ steps: - yarn-install image: node:22-bookworm name: verify-i18n +- commands: + - yarn generate-apis + - "\n file_diff=$(git diff ':!conf')\n if [ -n \"$file_diff\" + ]; then\n echo $file_diff\n echo \"\nAPI client + generation has not been committed. Please run 'yarn generate-apis', commit the + changes and push again.\"\n exit 1\n fi\n " + depends_on: + - yarn-install + image: node:22-bookworm + name: verify-api-clients trigger: branch: - instant @@ -5569,6 +5599,6 @@ kind: secret name: gcr_credentials --- kind: signature -hmac: b7abfae4fe14ca97a65bc5869984d81407f61a66fd06301fb2023aab07238a5b +hmac: abd48dfdec08a719b414fba06b06dfc97560df31d81751cd833b5fdf5b7f9937 ... diff --git a/package.json b/package.json index 682378efec3..5fd921a0cc7 100644 --- a/package.json +++ b/package.json @@ -62,7 +62,7 @@ "plugin:build:commit": "nx run-many -t build:commit --projects='tag:scope:plugin'", "plugin:build:dev": "nx run-many -t dev --projects='tag:scope:plugin' --maxParallel=100", "generate-icons": "nx run grafana-icons:generate", - "process-specs": "npx tsx scripts/process-specs.ts", + "process-specs": "node --experimental-strip-types scripts/process-specs.ts", "generate-apis": "yarn process-specs && rtk-query-codegen-openapi ./scripts/generate-rtk-apis.ts" }, "grafana": { diff --git a/scripts/drone/pipelines/lint_frontend.star b/scripts/drone/pipelines/lint_frontend.star index 1f98e371bb9..381f79373db 100644 --- a/scripts/drone/pipelines/lint_frontend.star +++ b/scripts/drone/pipelines/lint_frontend.star @@ -12,6 +12,7 @@ load( "enterprise_setup_step", "identify_runner_step", "lint_frontend_step", + "verify_api_clients_step", "verify_i18n_step", "yarn_install_step", ) @@ -35,6 +36,7 @@ def lint_frontend_pipeline(trigger, ver_mode): init_steps = [] lint_step = lint_frontend_step() i18n_step = verify_i18n_step() + api_clients_step = verify_api_clients_step() volumes = [] @@ -54,6 +56,7 @@ def lint_frontend_pipeline(trigger, ver_mode): test_steps = [ lint_step, i18n_step, + api_clients_step, ] return pipeline( diff --git a/scripts/drone/steps/lib.star b/scripts/drone/steps/lib.star index 36cd3a2db86..3ee633dfb06 100644 --- a/scripts/drone/steps/lib.star +++ b/scripts/drone/steps/lib.star @@ -676,6 +676,28 @@ def verify_i18n_step(): ], } +def verify_api_clients_step(): + uncommited_error_message = "\nAPI client generation has not been committed. Please run 'yarn generate-apis', commit the changes and push again." + return { + "name": "verify-api-clients", + "image": images["node_deb"], + "depends_on": [ + "yarn-install", + ], + "commands": [ + "yarn generate-apis", + # Verify that client generation has been run and committed + ''' + file_diff=$(git diff ':!conf') + if [ -n "$file_diff" ]; then + echo $file_diff + echo "{}" + exit 1 + fi + '''.format(uncommited_error_message), + ], + } + def test_a11y_frontend_step(ver_mode, port = 3001): """Runs automated accessiblity tests against the frontend. diff --git a/scripts/process-specs.ts b/scripts/process-specs.ts index fb96a8beaa9..f13fdf7cb74 100644 --- a/scripts/process-specs.ts +++ b/scripts/process-specs.ts @@ -168,10 +168,10 @@ function processDirectory(sourceDir: string, outputDir: string) { } const sourceDirs = [ - path.resolve(__dirname, '../pkg/tests/apis/openapi_snapshots'), - path.resolve(__dirname, '../pkg/extensions/apiserver/tests/openapi_snapshots'), + path.resolve(import.meta.dirname, '../pkg/tests/apis/openapi_snapshots'), + path.resolve(import.meta.dirname, '../pkg/extensions/apiserver/tests/openapi_snapshots'), ]; -const outputDir = path.resolve(__dirname, '../data/openapi'); +const outputDir = path.resolve(import.meta.dirname, '../data/openapi'); for (const sourceDir of sourceDirs) { processDirectory(sourceDir, outputDir);