feat(linter): add GL046-GL049 rules, AND-group support, and GL032 fix
- GL046: validate image/service pull_policy values (always, if-not-present, never)
- GL047: error when a variables.options default value is not in the options list
- GL048: error on unrecognised trigger.forward keys
- GL049: validate rules[n].allow_failure (bool or {exit_codes:} map)
- Parse and evaluate workflow.rules/job.rules nested-array AND-groups; crash
on !!seq nodes is fixed; all members of a group must match for it to fire
- Add workflow.name and workflow.auto_cancel fields to Workflow struct
- Fix GL032 false positive: variables declared in any workflow rule's variables:
block no longer trigger an undeclared-variable warning in sibling workflow
rule if: expressions
- Add Windows ARM64 release build target (task build-windows-arm64)
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Vendored
+54
@@ -2,6 +2,13 @@ stages:
|
||||
- build
|
||||
- test
|
||||
|
||||
variables:
|
||||
DEPLOY_ENV:
|
||||
value: canary # ERROR: not listed in options
|
||||
options:
|
||||
- staging
|
||||
- production
|
||||
|
||||
workflow:
|
||||
rules:
|
||||
- if: '$CI_PIPELINE_SOURCE == "push"'
|
||||
@@ -126,3 +133,50 @@ bad-rule-when-job:
|
||||
rules:
|
||||
- if: '$CI_MERGE_REQUEST_ID'
|
||||
when: sometimes # ERROR: invalid rules[0].when
|
||||
|
||||
bad-pull-policy-job:
|
||||
stage: build
|
||||
script:
|
||||
- echo hello
|
||||
image:
|
||||
name: alpine
|
||||
pull_policy: on-demand # ERROR: invalid pull_policy value
|
||||
|
||||
bad-pull-policy-service-job:
|
||||
stage: build
|
||||
script:
|
||||
- echo hello
|
||||
services:
|
||||
- name: postgres:15
|
||||
pull_policy: lazy # ERROR: invalid service pull_policy value
|
||||
|
||||
bad-trigger-forward-job:
|
||||
trigger:
|
||||
project: mygroup/myproject
|
||||
forward:
|
||||
all_variables: true # ERROR: unrecognised trigger.forward key
|
||||
|
||||
bad-trigger-forward-key2-job:
|
||||
trigger:
|
||||
include:
|
||||
- artifact: child.yml
|
||||
job: build
|
||||
forward:
|
||||
inherit: false # ERROR: unrecognised trigger.forward key
|
||||
|
||||
bad-rules-allow-failure-job:
|
||||
stage: build
|
||||
script:
|
||||
- echo hello
|
||||
rules:
|
||||
- if: $CI_COMMIT_BRANCH
|
||||
allow_failure: maybe # ERROR: invalid rules[0].allow_failure value
|
||||
|
||||
bad-rules-allow-failure-map-job:
|
||||
stage: build
|
||||
script:
|
||||
- echo hello
|
||||
rules:
|
||||
- if: $CI_COMMIT_BRANCH
|
||||
allow_failure:
|
||||
codes: [1] # ERROR: map missing exit_codes key
|
||||
|
||||
Vendored
+25
@@ -15,12 +15,19 @@ default:
|
||||
|
||||
variables:
|
||||
GO_VERSION: "1.26"
|
||||
DEPLOY_ENV:
|
||||
value: staging
|
||||
options:
|
||||
- staging
|
||||
- production
|
||||
- review
|
||||
|
||||
build-job:
|
||||
stage: build
|
||||
image:
|
||||
name: golang:1.26
|
||||
entrypoint: [""]
|
||||
pull_policy: if-not-present
|
||||
script:
|
||||
- go build ./...
|
||||
artifacts:
|
||||
@@ -72,6 +79,24 @@ release-job:
|
||||
action: start
|
||||
when: on_success
|
||||
|
||||
.trigger-valid:
|
||||
trigger:
|
||||
include:
|
||||
- artifact: child.yml
|
||||
job: build
|
||||
forward:
|
||||
pipeline_variables: true
|
||||
yaml_variables: false
|
||||
|
||||
.rules-allow-failure-valid:
|
||||
script: echo ok
|
||||
rules:
|
||||
- if: $CI_COMMIT_BRANCH
|
||||
allow_failure: true
|
||||
- if: $CI_COMMIT_TAG
|
||||
allow_failure:
|
||||
exit_codes: [1, 2]
|
||||
|
||||
.template:
|
||||
before_script:
|
||||
- echo "before"
|
||||
|
||||
Vendored
+31
@@ -0,0 +1,31 @@
|
||||
---
|
||||
# Tests that workflow.rules and job.rules accept the nested-array (AND-group)
|
||||
# form where each outer entry can itself be a sequence of rule conditions.
|
||||
workflow:
|
||||
name: "${PIPELINE_NAME}"
|
||||
auto_cancel:
|
||||
on_new_commit: interruptible
|
||||
rules:
|
||||
- if: "$CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH"
|
||||
variables:
|
||||
PIPELINE_NAME: "main"
|
||||
- - if: "$CI_PIPELINE_SOURCE == 'push' && $CI_COMMIT_BRANCH =~ /^feat\\///"
|
||||
variables:
|
||||
PIPELINE_NAME: "feature"
|
||||
- - if: "$CI_COMMIT_TAG"
|
||||
- if: "$DEPLOY"
|
||||
variables:
|
||||
PIPELINE_NAME: "deploy"
|
||||
|
||||
variables:
|
||||
DEPLOY: "false"
|
||||
|
||||
build:
|
||||
stage: build
|
||||
script: echo building
|
||||
rules:
|
||||
- if: "$CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH"
|
||||
- - if: "$CI_PIPELINE_SOURCE == 'push'"
|
||||
allow_failure: true
|
||||
- if: "$DEPLOY"
|
||||
when: manual
|
||||
Vendored
+4
@@ -17,6 +17,10 @@ workflow:
|
||||
- if: '$CI_COMMIT_BRANCH == "main"'
|
||||
variables:
|
||||
DEPLOY_TARGET: "production"
|
||||
WORKFLOW_FLAG: "true"
|
||||
# workflow rule referencing a variable set by a sibling rule's variables: — GL032 must not fire
|
||||
- if: '$WORKFLOW_FLAG == "true"'
|
||||
when: always
|
||||
- when: always
|
||||
|
||||
build:
|
||||
|
||||
Reference in New Issue
Block a user