mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
CI: Introduce lint-backend
pipeline (#55476)
* Introduce lint-backend pipeline * Use go image and install make * Don't run lint pipeline on .drone.yml changes
This commit is contained in:
parent
b25ea75bac
commit
c18432971b
162
.drone.yml
162
.drone.yml
@ -152,12 +152,6 @@ steps:
|
||||
- echo $DRONE_RUNNER_NAME
|
||||
image: alpine:3.15.6
|
||||
name: identify-runner
|
||||
- commands:
|
||||
- mkdir -p bin
|
||||
- curl -fL -o bin/grabpl https://grafana-downloads.storage.googleapis.com/grafana-build-pipeline/v3.0.7/grabpl
|
||||
- chmod +x bin/grabpl
|
||||
image: byrnedo/alpine-curl:0.1.8
|
||||
name: grabpl
|
||||
- commands:
|
||||
- go build -o ./bin/build -ldflags '-extldflags -static' ./pkg/build/cmd
|
||||
depends_on: []
|
||||
@ -180,14 +174,6 @@ steps:
|
||||
- verify-gen-cue
|
||||
image: grafana/build-container:1.6.2
|
||||
name: wire-install
|
||||
- commands:
|
||||
- make lint-go
|
||||
depends_on:
|
||||
- wire-install
|
||||
environment:
|
||||
CGO_ENABLED: "1"
|
||||
image: grafana/build-container:1.6.2
|
||||
name: lint-backend
|
||||
- commands:
|
||||
- go test -short -covermode=atomic -timeout=30m ./pkg/...
|
||||
depends_on:
|
||||
@ -228,6 +214,66 @@ depends_on: []
|
||||
image_pull_secrets:
|
||||
- dockerconfigjson
|
||||
kind: pipeline
|
||||
name: pr-lint-backend
|
||||
node:
|
||||
type: no-parallel
|
||||
platform:
|
||||
arch: amd64
|
||||
os: linux
|
||||
services: []
|
||||
steps:
|
||||
- commands:
|
||||
- echo $DRONE_RUNNER_NAME
|
||||
image: alpine:3.15.6
|
||||
name: identify-runner
|
||||
- commands:
|
||||
- go build -o ./bin/build -ldflags '-extldflags -static' ./pkg/build/cmd
|
||||
depends_on: []
|
||||
environment:
|
||||
CGO_ENABLED: 0
|
||||
image: golang:1.19.1
|
||||
name: compile-build-cmd
|
||||
- commands:
|
||||
- make gen-go
|
||||
depends_on: []
|
||||
image: grafana/build-container:1.6.2
|
||||
name: wire-install
|
||||
- commands:
|
||||
- apt-get update && apt-get install make
|
||||
- make lint-go
|
||||
depends_on:
|
||||
- wire-install
|
||||
environment:
|
||||
CGO_ENABLED: "1"
|
||||
image: golang:1.19.1
|
||||
name: lint-backend
|
||||
trigger:
|
||||
event:
|
||||
- pull_request
|
||||
paths:
|
||||
exclude:
|
||||
- docs/**
|
||||
- '*.md'
|
||||
include:
|
||||
- pkg/**
|
||||
- packaging/**
|
||||
- conf/**
|
||||
- go.sum
|
||||
- go.mod
|
||||
- public/app/plugins/**/plugin.json
|
||||
- devenv/**
|
||||
type: docker
|
||||
volumes:
|
||||
- host:
|
||||
path: /var/run/docker.sock
|
||||
name: docker
|
||||
---
|
||||
clone:
|
||||
retries: 3
|
||||
depends_on: []
|
||||
image_pull_secrets:
|
||||
- dockerconfigjson
|
||||
kind: pipeline
|
||||
name: pr-build-e2e
|
||||
node:
|
||||
type: no-parallel
|
||||
@ -908,12 +954,6 @@ steps:
|
||||
- echo $DRONE_RUNNER_NAME
|
||||
image: alpine:3.15.6
|
||||
name: identify-runner
|
||||
- commands:
|
||||
- mkdir -p bin
|
||||
- curl -fL -o bin/grabpl https://grafana-downloads.storage.googleapis.com/grafana-build-pipeline/v3.0.7/grabpl
|
||||
- chmod +x bin/grabpl
|
||||
image: byrnedo/alpine-curl:0.1.8
|
||||
name: grabpl
|
||||
- commands:
|
||||
- go build -o ./bin/build -ldflags '-extldflags -static' ./pkg/build/cmd
|
||||
depends_on: []
|
||||
@ -936,14 +976,6 @@ steps:
|
||||
- verify-gen-cue
|
||||
image: grafana/build-container:1.6.2
|
||||
name: wire-install
|
||||
- commands:
|
||||
- make lint-go
|
||||
depends_on:
|
||||
- wire-install
|
||||
environment:
|
||||
CGO_ENABLED: "1"
|
||||
image: grafana/build-container:1.6.2
|
||||
name: lint-backend
|
||||
- commands:
|
||||
- go test -short -covermode=atomic -timeout=30m ./pkg/...
|
||||
depends_on:
|
||||
@ -956,6 +988,60 @@ steps:
|
||||
- wire-install
|
||||
image: grafana/build-container:1.6.2
|
||||
name: test-backend-integration
|
||||
trigger:
|
||||
branch: main
|
||||
event:
|
||||
- push
|
||||
paths:
|
||||
exclude:
|
||||
- '*.md'
|
||||
- docs/**
|
||||
- latest.json
|
||||
type: docker
|
||||
volumes:
|
||||
- host:
|
||||
path: /var/run/docker.sock
|
||||
name: docker
|
||||
---
|
||||
clone:
|
||||
retries: 3
|
||||
depends_on: []
|
||||
image_pull_secrets:
|
||||
- dockerconfigjson
|
||||
kind: pipeline
|
||||
name: main-lint-backend
|
||||
node:
|
||||
type: no-parallel
|
||||
platform:
|
||||
arch: amd64
|
||||
os: linux
|
||||
services: []
|
||||
steps:
|
||||
- commands:
|
||||
- echo $DRONE_RUNNER_NAME
|
||||
image: alpine:3.15.6
|
||||
name: identify-runner
|
||||
- commands:
|
||||
- go build -o ./bin/build -ldflags '-extldflags -static' ./pkg/build/cmd
|
||||
depends_on: []
|
||||
environment:
|
||||
CGO_ENABLED: 0
|
||||
image: golang:1.19.1
|
||||
name: compile-build-cmd
|
||||
- commands:
|
||||
- make gen-go
|
||||
depends_on: []
|
||||
image: grafana/build-container:1.6.2
|
||||
name: wire-install
|
||||
- commands:
|
||||
- apt-get update && apt-get install make
|
||||
- make lint-go
|
||||
depends_on:
|
||||
- wire-install
|
||||
environment:
|
||||
CGO_ENABLED: "1"
|
||||
image: golang:1.19.1
|
||||
name: lint-backend
|
||||
- commands:
|
||||
- ./bin/build verify-drone
|
||||
depends_on:
|
||||
@ -2115,12 +2201,13 @@ steps:
|
||||
image: golang:1.19.1
|
||||
name: compile-build-cmd
|
||||
- commands:
|
||||
- apt-get update && apt-get install make
|
||||
- make lint-go
|
||||
depends_on:
|
||||
- wire-install
|
||||
environment:
|
||||
CGO_ENABLED: "1"
|
||||
image: grafana/build-container:1.6.2
|
||||
image: golang:1.19.1
|
||||
name: lint-backend
|
||||
- commands:
|
||||
- yarn run prettier:check
|
||||
@ -2772,12 +2859,13 @@ steps:
|
||||
image: grafana/build-container:1.6.2
|
||||
name: verify-gen-cue
|
||||
- commands:
|
||||
- apt-get update && apt-get install make
|
||||
- make lint-go
|
||||
depends_on:
|
||||
- wire-install
|
||||
environment:
|
||||
CGO_ENABLED: "1"
|
||||
image: grafana/build-container:1.6.2
|
||||
image: golang:1.19.1
|
||||
name: lint-backend
|
||||
- commands:
|
||||
- yarn run prettier:check
|
||||
@ -2811,12 +2899,13 @@ steps:
|
||||
image: grafana/build-container:1.6.2
|
||||
name: test-frontend
|
||||
- commands:
|
||||
- apt-get update && apt-get install make
|
||||
- make lint-go
|
||||
depends_on:
|
||||
- wire-install
|
||||
environment:
|
||||
CGO_ENABLED: "1"
|
||||
image: grafana/build-container:1.6.2
|
||||
image: golang:1.19.1
|
||||
name: lint-backend-enterprise2
|
||||
- commands:
|
||||
- go test -tags=pro -covermode=atomic -timeout=30m ./pkg/...
|
||||
@ -4080,12 +4169,13 @@ steps:
|
||||
image: golang:1.19.1
|
||||
name: compile-build-cmd
|
||||
- commands:
|
||||
- apt-get update && apt-get install make
|
||||
- make lint-go
|
||||
depends_on:
|
||||
- wire-install
|
||||
environment:
|
||||
CGO_ENABLED: "1"
|
||||
image: grafana/build-container:1.6.2
|
||||
image: golang:1.19.1
|
||||
name: lint-backend
|
||||
- commands:
|
||||
- yarn run prettier:check
|
||||
@ -4701,12 +4791,13 @@ steps:
|
||||
image: grafana/build-container:1.6.2
|
||||
name: verify-gen-cue
|
||||
- commands:
|
||||
- apt-get update && apt-get install make
|
||||
- make lint-go
|
||||
depends_on:
|
||||
- wire-install
|
||||
environment:
|
||||
CGO_ENABLED: "1"
|
||||
image: grafana/build-container:1.6.2
|
||||
image: golang:1.19.1
|
||||
name: lint-backend
|
||||
- commands:
|
||||
- yarn run prettier:check
|
||||
@ -4740,12 +4831,13 @@ steps:
|
||||
image: grafana/build-container:1.6.2
|
||||
name: test-frontend
|
||||
- commands:
|
||||
- apt-get update && apt-get install make
|
||||
- make lint-go
|
||||
depends_on:
|
||||
- wire-install
|
||||
environment:
|
||||
CGO_ENABLED: "1"
|
||||
image: grafana/build-container:1.6.2
|
||||
image: golang:1.19.1
|
||||
name: lint-backend-enterprise2
|
||||
- commands:
|
||||
- go test -tags=pro -covermode=atomic -timeout=30m ./pkg/...
|
||||
@ -5178,6 +5270,6 @@ kind: secret
|
||||
name: packages_secret_access_key
|
||||
---
|
||||
kind: signature
|
||||
hmac: b08cb03f133c943a789bf6abf7f2645536598e4d8a5a86b34b9231db8afc8ff4
|
||||
hmac: a17adc518f8ba4ea5c123bf440adf9aceec5e7ba5d9fdae9e467dbd1ec91fd46
|
||||
|
||||
...
|
||||
|
@ -47,6 +47,11 @@ load(
|
||||
'enterprise_downstream_pipeline',
|
||||
)
|
||||
|
||||
load(
|
||||
'scripts/drone/pipelines/lint_backend.star',
|
||||
'lint_backend_pipeline',
|
||||
)
|
||||
|
||||
load('scripts/drone/vault.star', 'from_secret')
|
||||
|
||||
|
||||
@ -84,6 +89,7 @@ def main_pipelines(edition):
|
||||
docs_pipelines(edition, ver_mode, trigger_docs_main()),
|
||||
test_frontend(trigger, ver_mode),
|
||||
test_backend(trigger, ver_mode),
|
||||
lint_backend_pipeline(trigger, ver_mode),
|
||||
build_e2e(trigger, ver_mode, edition),
|
||||
integration_tests(trigger, ver_mode, edition),
|
||||
windows(trigger, edition, ver_mode),
|
||||
|
@ -39,6 +39,11 @@ load(
|
||||
'shellcheck_pipeline',
|
||||
)
|
||||
|
||||
load(
|
||||
'scripts/drone/pipelines/lint_backend.star',
|
||||
'lint_backend_pipeline',
|
||||
)
|
||||
|
||||
ver_mode = 'pr'
|
||||
trigger = {
|
||||
'event': [
|
||||
@ -59,6 +64,7 @@ def pr_pipelines(edition):
|
||||
verify_drone(get_pr_trigger(include_paths=['scripts/drone/**', '.drone.yml', '.drone.star']), ver_mode),
|
||||
test_frontend(get_pr_trigger(exclude_paths=['pkg/**', 'packaging/**', 'go.sum', 'go.mod']), ver_mode),
|
||||
test_backend(get_pr_trigger(include_paths=['pkg/**', 'packaging/**', '.drone.yml', 'conf/**', 'go.sum', 'go.mod', 'public/app/plugins/**/plugin.json', 'devenv/**']), ver_mode),
|
||||
lint_backend_pipeline(get_pr_trigger(include_paths=['pkg/**', 'packaging/**', 'conf/**', 'go.sum', 'go.mod', 'public/app/plugins/**/plugin.json', 'devenv/**']), ver_mode),
|
||||
build_e2e(trigger, ver_mode, edition),
|
||||
integration_tests(get_pr_trigger(include_paths=['pkg/**', 'packaging/**', '.drone.yml', 'conf/**', 'go.sum', 'go.mod', 'public/app/plugins/**/plugin.json']), ver_mode, edition),
|
||||
docs_pipelines(edition, ver_mode, trigger_docs_pr()),
|
||||
|
31
scripts/drone/pipelines/lint_backend.star
Normal file
31
scripts/drone/pipelines/lint_backend.star
Normal file
@ -0,0 +1,31 @@
|
||||
load(
|
||||
'scripts/drone/steps/lib.star',
|
||||
'identify_runner_step',
|
||||
'wire_install_step',
|
||||
'lint_backend_step',
|
||||
'lint_drone_step',
|
||||
'compile_build_cmd',
|
||||
)
|
||||
|
||||
load(
|
||||
'scripts/drone/utils/utils.star',
|
||||
'pipeline',
|
||||
)
|
||||
|
||||
def lint_backend_pipeline(trigger, ver_mode):
|
||||
wire_step = wire_install_step()
|
||||
wire_step.update({ 'depends_on': [] })
|
||||
init_steps = [
|
||||
identify_runner_step(),
|
||||
compile_build_cmd(),
|
||||
wire_step,
|
||||
]
|
||||
test_steps = [
|
||||
lint_backend_step(edition="oss"),
|
||||
]
|
||||
if ver_mode == 'main':
|
||||
test_steps.extend([lint_drone_step()])
|
||||
|
||||
return pipeline(
|
||||
name='{}-lint-backend'.format(ver_mode), edition="oss", trigger=trigger, services=[], steps=init_steps + test_steps,
|
||||
)
|
@ -1,10 +1,7 @@
|
||||
load(
|
||||
'scripts/drone/steps/lib.star',
|
||||
'identify_runner_step',
|
||||
'download_grabpl_step',
|
||||
'wire_install_step',
|
||||
'lint_backend_step',
|
||||
'lint_drone_step',
|
||||
'test_backend_step',
|
||||
'test_backend_integration_step',
|
||||
'verify_gen_cue_step',
|
||||
@ -19,18 +16,14 @@ load(
|
||||
def test_backend(trigger, ver_mode):
|
||||
init_steps = [
|
||||
identify_runner_step(),
|
||||
download_grabpl_step(),
|
||||
compile_build_cmd(),
|
||||
verify_gen_cue_step(edition="oss"),
|
||||
wire_install_step(),
|
||||
]
|
||||
test_steps = [
|
||||
lint_backend_step(edition="oss"),
|
||||
test_backend_step(edition="oss"),
|
||||
test_backend_integration_step(edition="oss"),
|
||||
]
|
||||
if ver_mode == 'main':
|
||||
test_steps.extend([lint_drone_step()])
|
||||
|
||||
return pipeline(
|
||||
name='{}-test-backend'.format(ver_mode), edition="oss", trigger=trigger, services=[], steps=init_steps + test_steps,
|
||||
|
@ -207,7 +207,7 @@ def enterprise_downstream_step(edition, ver_mode):
|
||||
def lint_backend_step(edition):
|
||||
return {
|
||||
'name': 'lint-backend' + enterprise2_suffix(edition),
|
||||
'image': build_image,
|
||||
'image': go_image,
|
||||
'environment': {
|
||||
# We need CGO because of go-sqlite3
|
||||
'CGO_ENABLED': '1',
|
||||
@ -216,6 +216,7 @@ def lint_backend_step(edition):
|
||||
'wire-install',
|
||||
],
|
||||
'commands': [
|
||||
'apt-get update && apt-get install make',
|
||||
# Don't use Make since it will re-download the linters
|
||||
'make lint-go',
|
||||
],
|
||||
|
Loading…
Reference in New Issue
Block a user