Files
grafana/scripts/drone/pipelines/lint_backend.star
Kevin Minehart 2400483d6c CI: Add github app token generation in pipelines that use GITHUB_TOKEN (#96646)
* Add github app token generation in pipelines that use GITHUB_TOKEN

* ci?

* clone gh repo using x-access-token user

* address linting issues

* use mounted volume for exporting token

* remove unused github_token env var swagger gen step

* replace pat on release_pr pipepline

* cleanup GH PAT references

* linting

* Update scripts/drone/steps/lib.star

* make drone

---------

Co-authored-by: Matheus Macabu <macabu.matheus@gmail.com>
2024-11-21 17:08:02 +02:00

72 lines
1.6 KiB
Plaintext

"""
This module returns the pipeline used for linting backend code.
"""
load(
"scripts/drone/steps/github.star",
"github_app_generate_token_step",
"github_app_pipeline_volumes",
)
load(
"scripts/drone/steps/lib.star",
"compile_build_cmd",
"enterprise_setup_step",
"identify_runner_step",
"lint_drone_step",
"validate_modfile_step",
"validate_openapi_spec_step",
"wire_install_step",
)
load(
"scripts/drone/utils/utils.star",
"pipeline",
)
def lint_backend_pipeline(trigger, ver_mode):
"""Generates the pipelines used linting backend code.
Args:
trigger: controls which events can trigger the pipeline execution.
ver_mode: used in the naming of the pipeline.
Returns:
Drone pipeline.
"""
environment = {"EDITION": "oss"}
wire_step = wire_install_step()
wire_step.update({"depends_on": []})
init_steps = [
identify_runner_step(),
compile_build_cmd(),
]
volumes = []
if ver_mode == "pr":
# In pull requests, attempt to clone grafana enterprise.
init_steps.append(github_app_generate_token_step())
init_steps.append(enterprise_setup_step())
volumes += github_app_pipeline_volumes()
init_steps.append(wire_step)
test_steps = [
validate_modfile_step(),
validate_openapi_spec_step(),
]
if ver_mode == "main":
test_steps.append(lint_drone_step())
return pipeline(
name = "{}-lint-backend".format(ver_mode),
trigger = trigger,
services = [],
steps = init_steps + test_steps,
environment = environment,
volumes = volumes,
)