API client generation: Add `verify-api-clients` step to drone (#99987)

* add verify-api-clients step to drone

* change to check the verify step fails

* ignore conf dir

* rerun make drone

* undo change to make step fail
pull/100036/head
Ashley Harrison 10 months ago committed by GitHub
parent 443cb092b4
commit c94b8b78ae
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 32
      .drone.yml
  2. 2
      package.json
  3. 3
      scripts/drone/pipelines/lint_frontend.star
  4. 22
      scripts/drone/steps/lib.star
  5. 6
      scripts/process-specs.ts

@ -339,6 +339,16 @@ steps:
- yarn-install - yarn-install
image: node:22-bookworm image: node:22-bookworm
name: verify-i18n 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: trigger:
event: event:
- pull_request - pull_request
@ -1782,6 +1792,16 @@ steps:
- yarn-install - yarn-install
image: node:22-bookworm image: node:22-bookworm
name: verify-i18n 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: trigger:
branch: main branch: main
event: event:
@ -2916,6 +2936,16 @@ steps:
- yarn-install - yarn-install
image: node:22-bookworm image: node:22-bookworm
name: verify-i18n 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: trigger:
branch: branch:
- instant - instant
@ -5569,6 +5599,6 @@ kind: secret
name: gcr_credentials name: gcr_credentials
--- ---
kind: signature kind: signature
hmac: b7abfae4fe14ca97a65bc5869984d81407f61a66fd06301fb2023aab07238a5b hmac: abd48dfdec08a719b414fba06b06dfc97560df31d81751cd833b5fdf5b7f9937
... ...

@ -62,7 +62,7 @@
"plugin:build:commit": "nx run-many -t build:commit --projects='tag:scope:plugin'", "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", "plugin:build:dev": "nx run-many -t dev --projects='tag:scope:plugin' --maxParallel=100",
"generate-icons": "nx run grafana-icons:generate", "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" "generate-apis": "yarn process-specs && rtk-query-codegen-openapi ./scripts/generate-rtk-apis.ts"
}, },
"grafana": { "grafana": {

@ -12,6 +12,7 @@ load(
"enterprise_setup_step", "enterprise_setup_step",
"identify_runner_step", "identify_runner_step",
"lint_frontend_step", "lint_frontend_step",
"verify_api_clients_step",
"verify_i18n_step", "verify_i18n_step",
"yarn_install_step", "yarn_install_step",
) )
@ -35,6 +36,7 @@ def lint_frontend_pipeline(trigger, ver_mode):
init_steps = [] init_steps = []
lint_step = lint_frontend_step() lint_step = lint_frontend_step()
i18n_step = verify_i18n_step() i18n_step = verify_i18n_step()
api_clients_step = verify_api_clients_step()
volumes = [] volumes = []
@ -54,6 +56,7 @@ def lint_frontend_pipeline(trigger, ver_mode):
test_steps = [ test_steps = [
lint_step, lint_step,
i18n_step, i18n_step,
api_clients_step,
] ]
return pipeline( return pipeline(

@ -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): def test_a11y_frontend_step(ver_mode, port = 3001):
"""Runs automated accessiblity tests against the frontend. """Runs automated accessiblity tests against the frontend.

@ -168,10 +168,10 @@ function processDirectory(sourceDir: string, outputDir: string) {
} }
const sourceDirs = [ const sourceDirs = [
path.resolve(__dirname, '../pkg/tests/apis/openapi_snapshots'), path.resolve(import.meta.dirname, '../pkg/tests/apis/openapi_snapshots'),
path.resolve(__dirname, '../pkg/extensions/apiserver/tests/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) { for (const sourceDir of sourceDirs) {
processDirectory(sourceDir, outputDir); processDirectory(sourceDir, outputDir);

Loading…
Cancel
Save