GitLabgitlab-org

cli

main
ply5 git calls235 ms104 KiB3 cachedprotocol v2
819 lines27 KiBRaw
1spec:
2 inputs:
3 tag_release_image_version:
4 type: "string"
5 default: "latest"
6 description: "tag for the image used to create new project releases"
7 release_schedule:
8 type: boolean
9 default: false
10 description: "toggle release jobs on/off; set by pipeline schedules only!"
11---
12variables:
13 GO_VERSION: "1.27.4"
14 GITLAB_ADVANCED_SAST_ENABLED: "true"
15 # glab image version for the weekly tag-release job. Defaults to latest
16 # (dogfooding); override on the release schedule to pin a known-good version
17 # if a :latest regression ever breaks the release, without a new commit.
18 TAG_RELEASE_IMAGE_VERSION: $[[ inputs.tag_release_image_version ]]
19 RELEASE_SCHEDULE: $[[ inputs.release_schedule ]]
21.code-patterns: &code-patterns
22 - ".gitlab/**/*"
23 - "**/*.go"
24 - "scripts/**/*"
25 - "test/**/*"
26 - ".gitignore"
27 - ".gitlab-ci.yml"
28 - ".golangci.yml"
29 - "Makefile"
30 - "go.mod"
31 - "go.sum"
33.sign_windows_base:
34 image: ${CI_REGISTRY}/gitlab-com/gl-infra/common-ci-tasks-images/code-signer:1.3.0
35 extends: .google-oidc:auth
36 rules:
37 - if: $CI_COMMIT_TAG && $CI_SERVER_HOST == "gitlab.com" && ($CI_PROJECT_PATH == "gitlab-org/cli" || $CI_PROJECT_PATH == "gitlab-org/security/cli")
38 stage: release
39 artifacts:
40 expire_in: 7 days
41 variables:
42 GCLOUD_PROJECT: gitlab-ci-runners-signing
43 SERVICE_ACCOUNT: gitlab-cli-signer@gitlab-ci-runners-signing.iam.gserviceaccount.com
44 WI_POOL_PROVIDER: //iam.googleapis.com/projects/8522242139/locations/global/workloadIdentityPools/gitlab-pool-oidc-$CI_PROJECT_ID/providers/gitlab-jwt-$CI_PROJECT_ID
46.use_signed_if_available: &use_signed_if_available
47 - |
48 if [ -d "signed/" ]; then
49 echo "Using signed binaries"
50 rm -rf bin/
51 mv signed bin
52 ls -al bin
53 else
54 echo "Using unsigned binaries"
55 fi
57# run the pipeline only on MRs, tags, default branch, and the release schedule
58workflow:
59 auto_cancel:
60 # `conservative`, the default, refuses to cancel a superseded pipeline once
61 # any job with `interruptible: false` has started, and the policy-injected
62 # dependency-scanning job starts immediately and is not ours to mark. That
63 # left superseded pipelines running their whole build stage. `interruptible`
64 # cancels the jobs we did mark and lets the rest finish.
65 on_new_commit: interruptible
66 rules:
67 - if: $CI_PIPELINE_SOURCE == "merge_request_event"
68 - if: $CI_COMMIT_TAG
69 - if: $CI_PIPELINE_SOURCE == "schedule"
70 - if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH
72# Skip jobs in the weekly release schedule, this intentionally does not match other scheduled pipelines
73.skip-on-release-schedule: &skip-on-release-schedule
74 if: $RELEASE_SCHEDULE == "true"
75 when: never
77default:
78 image: ${GITLAB_DEPENDENCY_PROXY}golang:${GO_VERSION}
79 tags:
80 # NOTE: largest linux-based hosted runner available in Free tier.
81 # see https://docs.gitlab.com/ci/runners/hosted_runners/linux/#machine-types-available-for-linux---x86-64
82 - "saas-linux-medium-amd64"
83 retry:
84 max: 2
85 when:
86 - runner_external_dependency_failure
88# Stage order here is presentation, not sequencing: every job declares its own
89# `needs:`, so these are lanes in the pipeline graph rather than gates. The one
90# exception is the dependency-scanning job injected by a group security policy,
91# whose `needs:` we do not control. Declaring its stage (the policy fixes the
92# name) keeps it from being appended after everything else, where it was the
93# last job to finish in every pipeline.
94stages:
95 - application-security-testing
96 - checks
97 - documentation
98 - test
99 - build
100 - review
101 - release
103include:
104 - template: Jobs/SAST.gitlab-ci.yml
105 # No Dependency-Scanning template: it provides the Gemnasium analyzer, which
106 # is deprecated as of GitLab 17.9, and a group security policy already
107 # injects the SBOM-based analyzer that replaces it. Including both ran two
108 # dependency scans per pipeline.
109 - template: Jobs/Secret-Detection.gitlab-ci.yml
110 - project: "gitlab-com/gl-security/security-operations/infrastructure-security-public/oidc-modules"
111 ref: 3.4.0
112 file: templates/gcp_auth.yaml
113 # Uses `secrets`, which doesn't work in contributor (fork) MRs, and will not work
114 # if this project gets mirrored to dev.gitlab.org in the future.
115 - local: .gitlab/ci/review-docs.gitlab-ci.yml
116 rules:
117 - if: '$CI_SERVER_URL != "https://gitlab.com" || $CI_PROJECT_PATH != "gitlab-org/cli"'
118 when: never
119 - if: '$CI_PIPELINE_SOURCE == "merge_request_event" && $CI_MERGE_REQUEST_SOURCE_PROJECT_PATH != "gitlab-org/cli"'
120 when: never
121 - when: always
123# From: https://docs.gitlab.com/ci/caching/#cache-go-dependencies
124# Base template for Go caching - extended by jobs that need Go dependencies
125.go-cache:
126 variables:
127 GOPATH: $CI_PROJECT_DIR/.go
128 GOCACHE: $CI_PROJECT_DIR/.gocache
129 GOLANGCI_LINT_CACHE: $CI_PROJECT_DIR/.golangci-lint-cache
130 cache:
131 paths:
132 - $CI_PROJECT_DIR/.go/pkg/mod/
133 - $CI_PROJECT_DIR/.gocache/
134 - $CI_PROJECT_DIR/.golangci-lint-cache/
135 # One cache per job, starting fresh whenever go.sum or .tool-versions
136 # (Go and golangci-lint versions) changes, so it never accumulates old
137 # builds. The first pipeline after such a change runs without a cache.
138 key:
139 files:
140 - go.sum
141 - .tool-versions
142 prefix: go-$CI_JOB_NAME_SLUG
143 policy: pull-push
145.documentation:
146 stage: documentation
147 interruptible: true
148 rules:
149 - if: $CI_PIPELINE_SOURCE == "merge_request_event"
150 needs: []
151 dependencies: []
153.test:
154 stage: test
155 interruptible: true
156 rules:
157 - *skip-on-release-schedule
158 - changes: *code-patterns
159 # None of these jobs consume another job's output, so none should wait for a
160 # stage boundary. Without this they queued behind the documentation stage.
161 needs: []
163check_docs_update:
164 extends:
165 - .documentation
166 - .go-cache
167 script:
168 - make gen-docs
169 - |-
170 git status
171 if [[ $(git add -A --dry-run) ]]; then
172 echo '✖ ERROR: Documentation changes detected!';
173 git diff --color --ws-error-highlight=all
174 echo '✖ These changes require a documentation update. Run `make gen-docs` to regenerate the docs and navigation, then commit. See https://gitlab.com/gitlab-org/cli/-/tree/main/docs#generating-the-docs.';
175 exit 1;
176 else
177 echo '✔ No documentation updates detected.';
178 exit 0;
179 fi
181check_docs_markdown:
182 image: registry.gitlab.com/gitlab-org/technical-writing/docs-gitlab-com/lint-markdown:alpine-3.24-vale-3.21.0-markdownlint2-0.23.2-lychee-0.24.2-rumdl-0.2.69
183 extends: .documentation
184 script:
185 # Lint prose
186 - vale --minAlertLevel error docs
187 # Lint Markdown
188 - markdownlint-cli2 'docs/**/*.md' *.md
189 - rumdl check --config docs/.rumdl/rumdl.toml docs *.md
190 # Check links
191 - lychee --offline --include-fragments docs/**/*.md *.md
193docs hugo_build:
194 image: registry.gitlab.com/gitlab-org/technical-writing/docs-gitlab-com/docs-gitlab-com-builder:alpine-3.24-hugo-0.166.0
195 extends: .documentation
196 variables:
197 DOCS_BRANCH: "main"
198 before_script:
199 # Check if this a release branch, which would be the case for a backport.
200 # If this is a backport MR, we need to checkout the appropriate version
201 # of the Docs website.
202 - |
203 if [[ $CI_MERGE_REQUEST_TARGET_BRANCH_NAME =~ [0-9]+-[0-9]+-stable ]]; then
204 BRANCH_NAME=$CI_MERGE_REQUEST_TARGET_BRANCH_NAME
205 echo "Detected merge request to stable branch: $BRANCH_NAME"
206 # Check if we're directly on a stable branch (direct push/commit)
207 elif [[ $CI_COMMIT_BRANCH =~ [0-9]+-[0-9]+-stable ]]; then
208 BRANCH_NAME=$CI_COMMIT_BRANCH
209 echo "Detected direct commit to stable branch: $BRANCH_NAME"
210 fi
212 # Extract version info if we found a stable branch
213 if [[ -n $BRANCH_NAME ]]; then
214 MAJOR=$(echo $BRANCH_NAME | cut -d '-' -f 1)
215 MINOR=$(echo $BRANCH_NAME | cut -d '-' -f 2)
216 # Convert GitLab style (17-9-stable-ee) to Docs style (17.9)
217 DOCS_BRANCH_CANDIDATE="$MAJOR.$MINOR"
219 # Check if the branch exists in the Docs website repo, fallback to main if not
220 if git ls-remote --heads --exit-code https://gitlab.com/gitlab-org/technical-writing/docs-gitlab-com.git "refs/heads/$DOCS_BRANCH_CANDIDATE" >/dev/null 2>&1; then
221 DOCS_BRANCH="$DOCS_BRANCH_CANDIDATE"
222 echo "Using docs-gitlab-com branch $DOCS_BRANCH for release branch"
223 else
224 DOCS_BRANCH="main"
225 echo "Branch $DOCS_BRANCH_CANDIDATE does not exist, falling back to main"
226 fi
227 fi
228 # Clone the Docs website project
229 - git clone --depth 1 --filter=tree:0 --branch $DOCS_BRANCH https://gitlab.com/gitlab-org/technical-writing/docs-gitlab-com.git
230 - cd docs-gitlab-com
231 - make add-latest-icons
232 script:
233 # Remove unwanted files from CLI docs/ to avoid conflicts with docs/source/
234 # See https://gitlab.com/gitlab-org/technical-writing/docs-gitlab-com/-/merge_requests/1554#note_2901887344
235 - rm -f ../docs/index.rst ../docs/*.md
236 # Test that Hugo will build
237 - hugo --gc --printPathWarnings --environment test
238 # Test for invalid index pages
239 # See https://gitlab.com/gitlab-org/technical-writing/docs-gitlab-com/-/blob/main/scripts/check-index-filenames.sh
240 - make check-index-pages SEARCH_DIR="../docs/source"
241 #- make check-index-pages SEARCH_DIR="../doc-locale/source" # Enable when translation is added
243check_go_generated_code:
244 extends:
245 - .go-cache
246 - .test
247 stage: checks
248 script:
249 - make generate
250 - |
251 echo "Checking git status"
252 [ -z "$(git status --short)" ] || {
253 echo "Error: Files should have been generated:";
254 git status --short; echo "Diff:";
255 git --no-pager diff HEAD;
256 echo "Run \"make generate\" and try again";
257 exit 1;
258 }
260lint_commit:
261 stage: checks
262 needs: []
263 interruptible: true
264 image: ${GITLAB_DEPENDENCY_PROXY}node:24-slim
265 script:
266 - apt-get update && apt-get install -y git
267 - git fetch origin $CI_MERGE_REQUEST_TARGET_BRANCH_NAME $CI_COMMIT_SHA
268 - cd scripts/commit-lint && npm ci
269 - ./lint.sh
270 rules:
271 - if: '$CI_MERGE_REQUEST_IID && $CI_PROJECT_VISIBILITY == "public"' # lint.js script makes an API call without authentication
272 when: always
274check_go_version:
275 stage: checks
276 needs: []
277 interruptible: true
278 image: ${GITLAB_DEPENDENCY_PROXY}alpine:3
279 before_script:
280 - apk add --no-cache bash
281 script:
282 - scripts/check-go-version.sh
283 rules:
284 - *skip-on-release-schedule
285 - changes:
286 - go.mod
287 - .tool-versions
288 - .gitlab-ci.yml
290check_embed:
291 stage: checks
292 needs: []
293 interruptible: true
294 image: ${GITLAB_DEPENDENCY_PROXY}alpine:3
295 before_script:
296 - apk add --no-cache make
297 script:
298 - make check-embed
300check_args:
301 stage: checks
302 needs: []
303 interruptible: true
304 image: ${GITLAB_DEPENDENCY_PROXY}alpine:3
305 before_script:
306 - apk add --no-cache make
307 script:
308 - make check-args
310# Lefthook runs these too, but it can be skipped with LEFTHOOK=0, so the
311# enforcement point is here. The overlap gate blocks; the ratio is a number
312# for the author to weigh and never fails the job.
313lint:comments:
314 extends:
315 - .go-cache
316 - .test
317 image: ${GITLAB_DEPENDENCY_PROXY}golang:${GO_VERSION}
318 script:
319 - go run ./scripts/comment-overlap -threshold 1.0 -max-findings 0 ./cmd/... ./internal/...
320 - |
321 if [ -n "$CI_MERGE_REQUEST_DIFF_BASE_SHA" ]; then
322 git fetch --quiet origin "$CI_MERGE_REQUEST_DIFF_BASE_SHA"
323 go run ./scripts/comment-ratio -base "$CI_MERGE_REQUEST_DIFF_BASE_SHA"
324 fi
326# Reachability scanning, which the other security jobs do not do: this fails
327# only when our code has a call path into a vulnerable function, not merely
328# when a vulnerable version is somewhere in the module graph.
330# Blocking on the default branch and manual on merge requests. The result
331# depends on the vulnerability database as much as on the code, so a new
332# upstream advisory can turn it red with no change on our side. That belongs to
333# whoever owns the default branch, not to whichever author pushed next. Anyone
334# can still run it on their own merge request from the pipeline view. Modelled
335# on the `vulnerability` job in gitlab-org/gitaly.
336govulncheck:
337 extends: .go-cache
338 stage: application-security-testing
339 needs: []
340 interruptible: true
341 image: ${GITLAB_DEPENDENCY_PROXY}golang:${GO_VERSION}
342 variables:
343 # Pinned rather than @latest so a scanner release cannot change the
344 # pipeline's verdict on its own. Renovate does not manage this.
345 GOVULNCHECK_VERSION: "v1.8.0"
346 rules:
347 - *skip-on-release-schedule
348 - if: $CI_PIPELINE_SOURCE == "merge_request_event"
349 when: manual
350 allow_failure: true
351 - if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH
352 script:
353 # Invoked by path: .go-cache points GOPATH at the project directory so the
354 # cache can pick it up, and $GOPATH/bin is not on PATH in this image.
355 - go install golang.org/x/vuln/cmd/govulncheck@${GOVULNCHECK_VERSION}
356 # Built rather than `go run`, which collapses every non-zero status to 1
357 # and would erase the difference between findings and a broken scanner.
358 - go build -o bin/govulncheck-to-gitlab ./scripts/govulncheck-to-gitlab
359 - $GOPATH/bin/govulncheck -format json ./... > govulncheck.json
360 - ./bin/govulncheck-to-gitlab < govulncheck.json > gl-dependency-scanning-report.json
361 artifacts:
362 when: always
363 access: "developer"
364 expire_in: 7 days
365 paths:
366 - govulncheck.json
367 reports:
368 dependency_scanning: gl-dependency-scanning-report.json
370lint:
371 extends:
372 - .go-cache
373 - .test
374 # Note: keep version in sync with the one in .tool-versions
375 image: ${GITLAB_DEPENDENCY_PROXY}golangci/golangci-lint:v2.15.0-alpine
376 script:
377 # Write the code coverage report to gl-code-quality-report.json
378 # and print linting issues to stdout in the format: path/to/file:line description
379 # add `--issues-exit-code 0` to ignore linting issues
380 - golangci-lint run --output.text.path=stdout --output.text.colors=false --output.text.print-issued-lines=false --output.code-climate.path=gl-code-quality-report.json
381 artifacts:
382 reports:
383 codequality: gl-code-quality-report.json
384 paths:
385 - gl-code-quality-report.json
386 expire_in: 7 days
388tests:unit:
389 extends:
390 - .go-cache
391 - .test
392 # We currently only test on the latest version of Go which we also build against.
393 # If we need to introduce testing for future versions of compatibility reasons
394 # uncomment the below lines and adjust the `GO_VERSION` to included versions to test.
395 # parallel:
396 # matrix:
397 # - GO_VERSION: ["1.22.3"]
398 variables:
399 # NOTE: required for race detector
400 CGO_ENABLED: "1"
401 script:
402 - make test-race
403 artifacts:
404 when: always
405 paths:
406 - coverage-unit.txt
407 reports:
408 junit: coverage-unit.xml
409 access: "developer"
410 expire_in: 7 days
412tests:integration:
413 extends:
414 - .go-cache
415 - .test
416 # We currently only test on the latest version of Go which we also build against.
417 # If we need to introduce testing for future versions of compatibility reasons
418 # uncomment the below lines and adjust the `GO_VERSION` to included versions to test.
419 # parallel:
420 # matrix:
421 # - GO_VERSION: ["1.22.3"]
422 variables:
423 # NOTE: required for race detector
424 CGO_ENABLED: "1"
425 script:
426 # `goreleaser` also uses GITLAB_TOKEN and so we need to distinguish between
427 # the GITLAB_TOKEN_TEST with less privilege used for testing and the GITLAB_TOKEN_RELEASE token
428 # GITLAB_TEST_HOST is the GitLab instance used for the integration tests
429 - GITLAB_TOKEN_TEST=$GITLAB_TOKEN_TEST GITLAB_TEST_HOST=$GITLAB_TEST_HOST make integration-test-race
430 artifacts:
431 when: always
432 paths:
433 - coverage-integration.txt
434 reports:
435 junit: coverage-integration.xml
436 access: "developer"
437 expire_in: 7 days
439tests:coverage:
440 extends:
441 - .go-cache
442 - .test
443 needs:
444 - job: tests:unit
445 artifacts: true
446 - job: tests:integration
447 artifacts: true
448 script:
449 - make coverage-merge
450 after_script:
451 - echo -e "\e[0Ksection_start:`date +%s`:coverage[collapsed=true]\r\e[0KRunning coverage report"
452 - make coverage-report
453 - echo -e "\e[0Ksection_end:`date +%s`:coverage\r\e[0K"
454 coverage: /^total:\t+\(statements\)\t+\d+\.\d+%$/
455 artifacts:
456 when: always
457 paths:
458 - coverage.txt
459 access: "developer"
460 expire_in: 7 days
462.release:
463 extends: .sign_windows_base
464 tags:
465 # NOTE: we really benefit from the capacities of this 2xlarge runner.
466 # we only want to build from the canonical project so we don't really
467 # need to bother about this being compatible with forks.
468 - "saas-linux-2xlarge-amd64"
469 stage: release
470 image: ${GITLAB_DEPENDENCY_PROXY}docker:stable
471 services:
472 - name: docker:28-dind
473 command: ["--mtu=1360"]
474 variables:
475 # Disable shallow cloning so that goreleaser can diff between tags to
476 # generate a changelog.
477 GIT_DEPTH: 0
478 needs: [sign_windows_installer]
479 dependencies: [sign_windows_installer]
480 before_script:
481 - !reference [.google-oidc:auth, before_script]
482 - *use_signed_if_available
483 # The OIDC module creates secrets in /var/run/secrets/gitlab, but this
484 # mount is only available on the job container, not the docker:dind
485 # service. Copy these files into the project dir to ensure
486 # all containers can access it.
487 - cp -r /var/run/secrets/gitlab .gitlab-secrets
488 after_script:
489 - !reference [.google-oidc:auth, after_script]
490 - rm -rf .gitlab-secrets
492build_test:
493 extends: .release
494 stage: build
495 # Set here rather than on .release, which `release` also extends: a snapshot
496 # build publishes nothing and is safe to cancel, an actual release is not.
497 interruptible: true
498 rules:
499 - *skip-on-release-schedule
500 - if: $CI_MERGE_REQUEST_EVENT_TYPE == "merge_train"
501 - if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH
502 - if: $CI_COMMIT_TAG
503 when: never
504 - changes:
505 - .goreleaser.yml
506 - .gitlab-ci.yml
507 script: |
508 docker run --rm --privileged \
509 -e CI=$CI \
510 -e CI_COMMIT_TAG=$CI_COMMIT_TAG \
511 -e APPSTORE_CONNECT_API_KEY_FILE=$APPSTORE_CONNECT_API_KEY_FILE \
512 -e GCLOUD_PROJECT=$GCLOUD_PROJECT \
513 -e GO_VERSION="$GO_VERSION" \
514 -e GOTOOLCHAIN="go$GO_VERSION" \
515 -e GOOGLE_APPLICATION_CREDENTIALS=$GOOGLE_APPLICATION_CREDENTIALS \
516 -e HOST_PWD=$PWD \
517 -v $PWD:/go/src/gitlab.com/gitlab-org/cli \
518 -v /var/run/docker.sock:/var/run/docker.sock \
519 -w /go/src/gitlab.com/gitlab-org/cli \
520 goreleaser/goreleaser:v2.18.3 release --skip=sign --snapshot
521 artifacts:
522 name: goreleaser-artifacts
523 paths:
524 - dist/
525 expire_in: 7 days
526 # tests:unit gates here rather than further up the chain: this is the only
527 # job in it expensive enough to be worth not running speculatively, at ~5
528 # minutes on a 2xlarge. Optional because tests:unit is skipped when no code
529 # changed (e.g. a docs-only merge to main); artifacts:false because only the
530 # signed installer is consumed.
531 needs:
532 - job: windows_installer
533 optional: false
534 - job: sign_windows_installer
535 optional: true
536 - job: tests:unit
537 optional: true
538 artifacts: false
540# Weekly release: create the next tag, which triggers the tag-driven release
541# pipeline below. See docs/release_process.md.
542tag-release:
543 stage: release
544 image: registry.gitlab.com/gitlab-org/cli:$TAG_RELEASE_IMAGE_VERSION
545 needs: []
546 variables:
547 GIT_DEPTH: 0
548 GITLAB_HOST: $CI_SERVER_HOST
549 rules:
550 - if: $CI_PIPELINE_SOURCE == "schedule" && $RELEASE_SCHEDULE == "true"
551 before_script:
552 # glab image is Alpine without bash; the script needs it for set -o pipefail.
553 - apk add --no-cache bash
554 script:
555 # Assign the release token inline, not via `variables:` above: the
556 # project-level GITLAB_TOKEN CI/CD variable outranks job variables, so
557 # setting GITLAB_TOKEN here is the only way glab uses the release token
558 # (must NOT be CI_JOB_TOKEN, whose tags don't trigger the release pipeline).
559 # Matches notify-issues-on-release.
560 - GITLAB_TOKEN="$GITLAB_TOKEN_RELEASE" scripts/release/create-release-tag.sh
562release:
563 extends: .release
564 needs:
565 - sign_windows_installer
566 - job: tests:unit
567 artifacts: false
568 - job: tests:integration
569 artifacts: false
570 rules:
571 - if: $CI_COMMIT_TAG
572 script: |
573 docker run --rm --privileged \
574 -e CI=$CI \
575 -e CI_COMMIT_TAG=$CI_COMMIT_TAG \
576 -e APPSTORE_CONNECT_API_KEY_FILE=$APPSTORE_CONNECT_API_KEY_FILE \
577 -e GCLOUD_PROJECT=$GCLOUD_PROJECT \
578 -e GO_VERSION="$GO_VERSION" \
579 -e GOTOOLCHAIN="go$GO_VERSION" \
580 -e GITLAB_TOKEN=$GITLAB_TOKEN_RELEASE \
581 -e GOOGLE_APPLICATION_CREDENTIALS=$GOOGLE_APPLICATION_CREDENTIALS \
582 -e HOST_PWD=$PWD \
583 -e SLACK_WEBHOOK=$SLACK_WEBHOOK \
584 -e SLACK_CHANNEL=$SLACK_CHANNEL \
585 -v $PWD:/go/src/gitlab.com/gitlab-org/cli \
586 -v /var/run/docker.sock:/var/run/docker.sock \
587 -w /go/src/gitlab.com/gitlab-org/cli \
588 --entrypoint "" \
589 goreleaser/goreleaser:v2.18.3 \
590 bash -c "
591 docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY
592 docker login -u $DOCKER_IO_USER -p $DOCKER_IO_PASSWORD
593 goreleaser release
594 "
596notify-issues-on-release:
597 image: registry.gitlab.com/gitlab-org/cli:latest
598 stage: release
599 needs: [release]
600 rules:
601 - if: $CI_COMMIT_TAG
602 variables:
603 GIT_DEPTH: 0 # Need full history to compare between tags
604 script:
605 - GITLAB_TOKEN="$GITLAB_TOKEN_RELEASE_NOTES" ./scripts/notify-issues-on-release.sh "$CI_COMMIT_TAG"
606 allow_failure: true # Don't block release if notifications fail
608homebrew-release:
609 image: ${GITLAB_DEPENDENCY_PROXY}homebrew/brew:4.6.20
610 stage: release
611 needs: [release]
612 rules:
613 - if: $CI_COMMIT_TAG
614 script:
615 - touch ~/.gitconfig
616 - git config --global user.email "$GITHUB_EMAIL"
617 - git config --global user.name "$GITHUB_NAME"
618 - brew bump-formula-pr glab --no-browse --tag="$CI_COMMIT_TAG" --revision="$CI_COMMIT_SHA"
620windows_installer:
621 stage: build
622 interruptible: true
623 image:
624 name: ${GITLAB_DEPENDENCY_PROXY}amake/innosetup:latest
625 entrypoint: [""]
626 rules:
627 - *skip-on-release-schedule
628 - if: $CI_COMMIT_TAG
629 - if: $CI_MERGE_REQUEST_EVENT_TYPE == "merge_train"
630 - if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH
631 - changes:
632 - .goreleaser.yml
633 - .gitlab-ci.yml
634 - scripts/setup_windows.iss
635 parallel:
636 matrix:
637 - GOARCH: amd64
638 ARCH: x86_64
639 - GOARCH: arm64
640 ARCH: arm64
641 before_script:
642 - *use_signed_if_available
643 script:
644 - mv "bin/glab_${GOARCH}.exe" bin/glab.exe
645 - mv scripts/setup_windows.iss .
646 - iscc "setup_windows.iss" -DVersion=${CI_COMMIT_TAG//v} -DArch=${ARCH}
647 artifacts:
648 paths:
649 - "bin/glab_*_installer.exe"
650 expire_in: 7 days
651 needs:
652 - job: build_windows
653 optional: false
654 - job: sign_windows_glab
655 optional: true
657build_windows:
658 extends: .go-cache
659 stage: build
660 rules:
661 - *skip-on-release-schedule
662 - if: $CI_COMMIT_TAG
663 - if: $CI_MERGE_REQUEST_EVENT_TYPE == "merge_train"
664 - if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH
665 - changes:
666 - .goreleaser.yml
667 - .gitlab-ci.yml
668 - scripts/setup_windows.iss
669 parallel:
670 matrix:
671 - GOARCH: [amd64, arm64]
672 # Ungated: two cross-compiles on a medium runner are cheap enough to run
673 # speculatively, and they head the pipeline's longest chain, so delaying them
674 # delays everything. The gate sits on build_test at the end of that chain,
675 # where the expensive 2xlarge job is.
676 needs: []
677 interruptible: true
678 script:
679 - GOOS=windows GOARCH=${GOARCH} make build
680 - mv bin/glab "bin/glab_${GOARCH}.exe"
681 artifacts:
682 paths:
683 - "bin/glab_*.exe"
684 expire_in: 7 days
686sign_windows_glab:
687 extends: .sign_windows_base
688 stage: build
689 parallel:
690 matrix:
691 - GOARCH: [amd64, arm64]
692 needs:
693 - build_windows
694 script:
695 - sign-windows-binaries --output-dir signed "bin/glab_${GOARCH}.exe"
696 artifacts:
697 paths:
698 - "signed/glab_*.exe"
699 expire_in: 7 days
701sign_windows_installer:
702 extends: .sign_windows_base
703 stage: build
704 parallel:
705 matrix:
706 - ARCH: [x86_64, arm64]
707 needs:
708 - windows_installer
709 script:
710 - sign-windows-binaries --output-dir signed bin/glab_*Windows_${ARCH}_installer.exe
711 artifacts:
712 paths:
713 - "signed/glab_*_installer.exe"
714 expire_in: 7 days
716.snapcraft_base:
717 image:
718 name: ghcr.io/canonical/snapcraft:8_core24
719 entrypoint: [""]
720 script:
721 - apt-get update
722 - apt-get install -y git
723 # Set version dynamically in snapcraft.yaml
724 - |
725 if git describe --exact-match --tags HEAD >/dev/null 2>&1; then
726 VERSION=$(git describe --tags --abbrev=0 | sed 's/^v//')
727 else
728 VERSION=$(git describe --tags --always | sed 's/^v//')
729 fi
730 sed -i "s/^version: git$/version: \"$VERSION\"/" snap/snapcraft.yaml
731 - snapcraft pack --destructive-mode --verbose
732 artifacts:
733 paths:
734 - "*.snap"
735 expire_in: 7 days
737snapcraft_build_stable:
738 extends: .snapcraft_base
739 stage: build
740 rules:
741 - if: $CI_COMMIT_TAG
743snapcraft_build_edge:
744 extends: .snapcraft_base
745 stage: build
746 needs:
747 - job: tests:unit
748 optional: true
749 interruptible: true
750 rules:
751 - *skip-on-release-schedule
752 - if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH && $CI_PIPELINE_SOURCE != "merge_request_event"
753 - if: $CI_MERGE_REQUEST_EVENT_TYPE == "merge_train"
754 - changes:
755 - snap/snapcraft.yaml
756 - .gitlab-ci.yml
758snapcraft_release_stable:
759 stage: release
760 image:
761 name: ghcr.io/canonical/snapcraft:8_core24
762 entrypoint: [""]
763 needs:
764 - snapcraft_build_stable
765 rules:
766 - if: $CI_COMMIT_TAG
767 script:
768 - export SNAPCRAFT_STORE_CREDENTIALS=$(cat $SNAPCRAFT_CREDENTIALS_FILE)
769 - snapcraft whoami
770 - snapcraft upload *.snap --release=latest/stable
771 - snapcraft logout
772 # Snap Store uploads intermittently fail with 5xx or dropped connections.
773 retry:
774 max: 2
775 when:
776 - script_failure
777 - runner_external_dependency_failure
779snapcraft_release_edge:
780 stage: release
781 image:
782 name: ghcr.io/canonical/snapcraft:8_core24
783 entrypoint: [""]
784 needs:
785 - snapcraft_build_edge
786 rules:
787 - *skip-on-release-schedule
788 - if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH
789 script:
790 - export SNAPCRAFT_STORE_CREDENTIALS=$(cat $SNAPCRAFT_CREDENTIALS_FILE)
791 - snapcraft whoami
792 - snapcraft upload *.snap --release=latest/edge
793 - snapcraft logout
794 retry:
795 max: 2
796 when:
797 - script_failure
798 - runner_external_dependency_failure
800# The SAST and secret-detection templates place their jobs in the test stage
801# without a `needs:`, so they queued behind the documentation stage. They scan
802# the source tree and consume no job's output. Moved into the security stage to
803# sit alongside the policy-injected dependency-scanning job.
804gitlab-advanced-sast:
805 stage: application-security-testing
806 needs: []
807 interruptible: true
809secret_detection:
810 stage: application-security-testing
811 needs: []
812 interruptible: true
813 variables:
814 # Fixture keypairs, generated for tests and not credentials for anything.
815 # Twelve of them were reported as Critical before being dismissed, and
816 # every new fixture raises another. Scoped to testdata rather than to all
817 # test files, so a credential committed to a _test.go is still caught.
818 SECRET_DETECTION_EXCLUDED_PATHS: "**/testdata/**"
819 dependencies: [] # Don't download artifacts, especially `./public/`
Diagnostics5 git calls · 235 ms
CallStatusSizeTime0235 ms
discover200185 B3 ms
git.upload-pack discover
http.response.status_code=200
git.upstream.cf_ray=-
git.upstream.phase=fetch
git.upstream.dur_ms=2
git.response.bytes=185
git.server.agent=git/2.56.g1891de4-Linux
git.server.object_format=sha1
git.server.caps=agent ls-refs fetch server-option object-format
git.server.fetch=shallow wait-for-done filter
git.protocol.version=2
git.pkt.frames=9
git.pkt.data=7
git.pkt.flush=2
git.pkt.delim=0
git.pkt.bytes=185
git.pkt.payload.max=35
ls-refs20058 KiB · hit2 ms
git.upload-pack ls-refs
http.response.status_code=200
git.upstream.cf_ray=-
git.upstream.phase=ls-refs
git.upstream.dur_ms=2
git.response.bytes=59849
git.response.cache=HIT
git.response.duration_ms=2
git.protocol.version=2
git.pkt.frames=731
git.pkt.data=730
git.pkt.flush=1
git.pkt.delim=0
git.pkt.bytes=59849
git.pkt.payload.max=143
git.ls_refs.count=730
git.ls_refs.head=refs/heads/main
fetchcombine:blob:none+tree:2 · deepen 12004.2 KiB · hit2 ms
git.upload-pack fetch
http.response.status_code=200
git.upstream.cf_ray=-
git.upstream.phase=fetch
git.upstream.dur_ms=2
git.response.bytes=4273
git.response.cache=HIT
git.response.duration_ms=2
git.fetch.filter=combine:blob:none+tree:2
git.fetch.wants=0dd7574dce9e385c5c30540e6c15657adc6bdce9
git.fetch.haves.count=0
git.fetch.deepen=1
git.fetch.thin_pack=false
git.fetch.ofs_delta=true
git.protocol.version=2
git.pkt.frames=7
git.pkt.data=5
git.pkt.flush=1
git.pkt.delim=1
git.pkt.bytes=4273
git.pkt.payload.max=4173
git.sideband.band1.bytes=4173
git.sideband.band2.bytes=0
git.sideband.band3.bytes=0
git.pack.objects=11
git.pack.bytes=4173
git.fetch.wide.objects=11
git.fetch.wide.extra_bytes=3930
git.fetch.wide.blobs=0
fetchtree:0 · deepen 1020032 KiB · hit2 ms
git.upload-pack fetch
http.response.status_code=200
git.upstream.cf_ray=-
git.upstream.phase=fetch
git.upstream.dur_ms=230
git.response.bytes=32926
git.response.cache=HIT
git.response.duration_ms=2
git.fetch.filter=tree:0
git.fetch.wants=0dd7574dce9e385c5c30540e6c15657adc6bdce9
git.fetch.haves.count=0
git.fetch.deepen=10
git.fetch.thin_pack=false
git.fetch.ofs_delta=true
git.protocol.version=2
git.pkt.frames=22
git.pkt.data=20
git.pkt.flush=1
git.pkt.delim=1
git.pkt.bytes=32926
git.pkt.payload.max=32046
git.sideband.band1.bytes=32046
git.sideband.band2.bytes=0
git.sideband.band3.bytes=0
git.pack.objects=80
git.pack.bytes=32046
git.pack.ofs_delta=36
git.pack.ref_delta=0
git.pack.chain.max=2
git.pack.trailer=cb0bad5d7ffc514895d8b21c4dd470327f90bc91
git.pack.full=44
Open pack map
fetch2008.6 KiB230 ms
git.upload-pack fetch
http.response.status_code=200
git.response.bytes=8785
git.response.cache=MISS
git.response.duration_ms=230
git.fetch.wants=41b6866156f6c1b5d9329397d5be2f655de85f12
git.fetch.haves.count=0
git.fetch.deepen=0
git.fetch.thin_pack=false
git.fetch.ofs_delta=true
git.protocol.version=2
git.pkt.frames=4
git.pkt.data=3
git.pkt.flush=1
git.pkt.delim=0
git.pkt.bytes=8785
git.pkt.payload.max=8758
git.sideband.band1.bytes=8758
git.sideband.band2.bytes=0
git.sideband.band3.bytes=0

Each row is one HTTP round trip ply made to the git server for this page, on one timeline. discover asks what the server speaks, ls-refs lists branch tips, fetch brings objects by id. A hit was served by Workers Cache. Tap a row for its wire details.

Remote
https://gitlab.com/gitlab-org/cli
Ref
refs/heads/main
Commit
0dd7574dce9e385c5c30540e6c15657adc6bdce9
cf-ray
a5e10d3cdf1b910d
Request
20dc8682…
Protocol
v2 · sha1
Agent
git/2.56.g1891de4-Linux
Filter
advertised
Fetch
shallow wait-for-done filter
Capabilities
agent ls-refs fetch server-option object-format