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 5 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
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
...

@ -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": {

@ -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(

@ -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.

@ -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);

Loading…
Cancel
Save