feat(gitlab-sim): ✨ first commit
This commit is contained in:
Vendored
+28
@@ -0,0 +1,28 @@
|
||||
stages:
|
||||
- build
|
||||
- test
|
||||
|
||||
# Template — no script of its own; should NOT trigger "missing script"
|
||||
.base:
|
||||
image: golang:1.26
|
||||
before_script:
|
||||
- go env
|
||||
|
||||
# Inherits image + before_script from .base, adds its own script
|
||||
build-job:
|
||||
extends: .base
|
||||
stage: build
|
||||
script:
|
||||
- go build ./...
|
||||
|
||||
# Multi-level: .test-base extends .base, test-job extends .test-base
|
||||
.test-base:
|
||||
extends: .base
|
||||
stage: test
|
||||
variables:
|
||||
CGO_ENABLED: "0"
|
||||
|
||||
test-job:
|
||||
extends: .test-base
|
||||
script:
|
||||
- go test ./...
|
||||
Vendored
+23
@@ -0,0 +1,23 @@
|
||||
stages:
|
||||
- build
|
||||
- test
|
||||
|
||||
build-job:
|
||||
stage: build
|
||||
script:
|
||||
- echo "ok"
|
||||
|
||||
bad-stage-job:
|
||||
stage: nonexistent
|
||||
script:
|
||||
- echo "this stage does not exist"
|
||||
|
||||
no-script-job:
|
||||
stage: test
|
||||
|
||||
deprecated-job:
|
||||
stage: test
|
||||
script:
|
||||
- echo "old style"
|
||||
only:
|
||||
- main
|
||||
Vendored
+128
@@ -0,0 +1,128 @@
|
||||
stages:
|
||||
- build
|
||||
- test
|
||||
|
||||
workflow:
|
||||
rules:
|
||||
- if: '$CI_PIPELINE_SOURCE == "push"'
|
||||
when: on_success # ERROR: workflow rules only allow always/never
|
||||
|
||||
bad-when-job:
|
||||
stage: build
|
||||
script:
|
||||
- echo hello
|
||||
when: whenever # ERROR: invalid when value
|
||||
|
||||
bad-delayed-job:
|
||||
stage: build
|
||||
script:
|
||||
- echo hello
|
||||
when: delayed # ERROR: missing start_in
|
||||
|
||||
bad-start-in-job:
|
||||
stage: build
|
||||
script:
|
||||
- echo hello
|
||||
start_in: 30 minutes # ERROR: start_in without when: delayed
|
||||
|
||||
bad-parallel-job:
|
||||
stage: build
|
||||
script:
|
||||
- echo hello
|
||||
parallel: 1 # ERROR: must be 2–200
|
||||
|
||||
bad-retry-job:
|
||||
stage: build
|
||||
script:
|
||||
- echo hello
|
||||
retry: 5 # ERROR: must be 0–2
|
||||
|
||||
bad-retry-when-job:
|
||||
stage: build
|
||||
script:
|
||||
- echo hello
|
||||
retry:
|
||||
max: 1
|
||||
when: cosmic_ray # ERROR: invalid retry.when value
|
||||
|
||||
bad-allow-failure-job:
|
||||
stage: build
|
||||
script:
|
||||
- echo hello
|
||||
allow_failure:
|
||||
bad_key: true # ERROR: map form must have exit_codes
|
||||
|
||||
bad-coverage-job:
|
||||
stage: build
|
||||
script:
|
||||
- echo hello
|
||||
coverage: "not-a-regex" # ERROR: must be wrapped in /
|
||||
|
||||
bad-release-job:
|
||||
stage: build
|
||||
script:
|
||||
- echo hello
|
||||
release:
|
||||
description: "no tag" # ERROR: missing tag_name
|
||||
|
||||
bad-environment-job:
|
||||
stage: test
|
||||
script:
|
||||
- echo hello
|
||||
environment:
|
||||
url: https://example.com # ERROR: url without name
|
||||
|
||||
bad-environment-action-job:
|
||||
stage: test
|
||||
script:
|
||||
- echo hello
|
||||
environment:
|
||||
name: staging
|
||||
action: dance # ERROR: invalid action value
|
||||
|
||||
bad-artifacts-when-job:
|
||||
stage: build
|
||||
script:
|
||||
- echo hello
|
||||
artifacts:
|
||||
paths:
|
||||
- dist/
|
||||
when: sometimes # ERROR: invalid artifacts.when
|
||||
|
||||
bad-cache-policy-job:
|
||||
stage: build
|
||||
script:
|
||||
- echo hello
|
||||
cache:
|
||||
paths:
|
||||
- .cache/
|
||||
policy: read-write # ERROR: invalid cache.policy
|
||||
|
||||
bad-dependencies-job:
|
||||
stage: test
|
||||
script:
|
||||
- echo hello
|
||||
dependencies:
|
||||
- nonexistent-job # ERROR: unknown job
|
||||
|
||||
bad-dependencies-stage-job:
|
||||
stage: build
|
||||
script:
|
||||
- echo hello
|
||||
needs:
|
||||
- test-job
|
||||
dependencies:
|
||||
- test-job # ERROR: test-job is in a later stage
|
||||
|
||||
test-job:
|
||||
stage: test
|
||||
script:
|
||||
- echo test
|
||||
|
||||
bad-rule-when-job:
|
||||
stage: build
|
||||
script:
|
||||
- echo hello
|
||||
rules:
|
||||
- if: '$CI_MERGE_REQUEST_ID'
|
||||
when: sometimes # ERROR: invalid rules[0].when
|
||||
Vendored
+79
@@ -0,0 +1,79 @@
|
||||
stages:
|
||||
- build
|
||||
- test
|
||||
- release
|
||||
|
||||
workflow:
|
||||
rules:
|
||||
- if: '$CI_PIPELINE_SOURCE == "merge_request_event"'
|
||||
when: always
|
||||
- when: never
|
||||
|
||||
variables:
|
||||
GO_VERSION: "1.26"
|
||||
|
||||
build-job:
|
||||
stage: build
|
||||
image:
|
||||
name: golang:1.26
|
||||
entrypoint: [""]
|
||||
script:
|
||||
- go build ./...
|
||||
artifacts:
|
||||
paths:
|
||||
- bin/
|
||||
when: on_success
|
||||
expire_in: 1 week
|
||||
cache:
|
||||
key: go-modules
|
||||
paths:
|
||||
- .go/pkg/mod
|
||||
policy: pull-push
|
||||
when: on_success
|
||||
retry: 2
|
||||
interruptible: true
|
||||
resource_group: build-group
|
||||
|
||||
test-job:
|
||||
stage: test
|
||||
script:
|
||||
- go test ./...
|
||||
coverage: '/coverage: \d+\.\d+%/'
|
||||
allow_failure:
|
||||
exit_codes: [1, 2]
|
||||
parallel: 4
|
||||
needs:
|
||||
- build-job
|
||||
dependencies:
|
||||
- build-job
|
||||
retry:
|
||||
max: 2
|
||||
when:
|
||||
- script_failure
|
||||
- runner_system_failure
|
||||
|
||||
release-job:
|
||||
stage: release
|
||||
script:
|
||||
- echo "creating release"
|
||||
release:
|
||||
tag_name: $CI_COMMIT_TAG
|
||||
description: "Release $CI_COMMIT_TAG"
|
||||
rules:
|
||||
- if: '$CI_COMMIT_TAG'
|
||||
when: on_success
|
||||
environment:
|
||||
name: production
|
||||
url: https://example.com
|
||||
action: start
|
||||
when: on_success
|
||||
|
||||
.template:
|
||||
before_script:
|
||||
- echo "before"
|
||||
tags:
|
||||
- docker
|
||||
inherit:
|
||||
default: false
|
||||
variables:
|
||||
- GO_VERSION
|
||||
Vendored
+40
@@ -0,0 +1,40 @@
|
||||
stages:
|
||||
- build
|
||||
- test
|
||||
- deploy
|
||||
|
||||
build-job:
|
||||
stage: build
|
||||
script:
|
||||
- go build ./...
|
||||
|
||||
test-job:
|
||||
stage: test
|
||||
script:
|
||||
- go test ./...
|
||||
needs:
|
||||
- build-job # OK: build comes before test
|
||||
|
||||
deploy-job:
|
||||
stage: deploy
|
||||
script:
|
||||
- echo "deploy"
|
||||
needs:
|
||||
- job: test-job
|
||||
artifacts: true # OK: test comes before deploy
|
||||
|
||||
# Bad: needs a job in a later stage
|
||||
bad-needs-job:
|
||||
stage: build
|
||||
script:
|
||||
- echo "bad"
|
||||
needs:
|
||||
- test-job # ERROR: test is after build
|
||||
|
||||
# Bad: needs a job that doesn't exist
|
||||
missing-needs-job:
|
||||
stage: test
|
||||
script:
|
||||
- echo "bad"
|
||||
needs:
|
||||
- nonexistent-job # ERROR: job doesn't exist
|
||||
Vendored
+16
@@ -0,0 +1,16 @@
|
||||
stages:
|
||||
- build
|
||||
|
||||
job-a:
|
||||
stage: build
|
||||
script:
|
||||
- echo a
|
||||
needs:
|
||||
- job-b
|
||||
|
||||
job-b:
|
||||
stage: build
|
||||
script:
|
||||
- echo b
|
||||
needs:
|
||||
- job-a
|
||||
Vendored
+26
@@ -0,0 +1,26 @@
|
||||
stages:
|
||||
- build
|
||||
- test
|
||||
- deploy
|
||||
|
||||
variables:
|
||||
APP_ENV: production
|
||||
|
||||
build-job:
|
||||
stage: build
|
||||
script:
|
||||
- echo "Building..."
|
||||
- go build ./...
|
||||
|
||||
test-job:
|
||||
stage: test
|
||||
script:
|
||||
- go test ./...
|
||||
|
||||
deploy-job:
|
||||
stage: deploy
|
||||
script:
|
||||
- echo "Deploying to $APP_ENV"
|
||||
rules:
|
||||
- if: '$CI_COMMIT_BRANCH == "main"'
|
||||
when: on_success
|
||||
Reference in New Issue
Block a user