From c8a2546a84efb7640622adc0333a0ddc05b09ad0 Mon Sep 17 00:00:00 2001 From: Neil Roza Date: Mon, 21 Aug 2023 15:21:41 +0000 Subject: [PATCH 1/6] squash fix-7235 --- commands/ci/status/status.go | 4 ++-- pkg/iostreams/iostreams.go | 4 ++++ 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/commands/ci/status/status.go b/commands/ci/status/status.go index 2b36e450c..623df2276 100644 --- a/commands/ci/status/status.go +++ b/commands/ci/status/status.go @@ -110,8 +110,8 @@ func NewCmdStatus(f *cmdutils.Factory) *cobra.Command { } fmt.Fprintf(writer.Newline(), "Pipeline State: %s\n\n", runningPipeline.Status) - // break loop if output is a TTY to avoid prompting - if !f.IO.IsOutputTTY() || !f.IO.PromptEnabled() { + // break loop if input or output is a TTY to avoid prompting + if !(f.IO.IsInputTTY() && f.IO.PromptEnabled()) { break } if (runningPipeline.Status == "pending" || runningPipeline.Status == "running") && live { diff --git a/pkg/iostreams/iostreams.go b/pkg/iostreams/iostreams.go index 8839fe106..f3448d1f5 100644 --- a/pkg/iostreams/iostreams.go +++ b/pkg/iostreams/iostreams.go @@ -215,6 +215,10 @@ func (s *IOStreams) IsOutputTTY() bool { return s.IsErrTTY && s.IsaTTY } +func (s *IOStreams) IsInputTTY() bool { + return s.IsInTTY && s.IsaTTY && s.IsErrTTY +} + func (s *IOStreams) ResolveBackgroundColor(style string) string { if style == "" { style = os.Getenv("GLAMOUR_STYLE") -- GitLab From 74bd2370381b385eb51ca6d1d7ca3cdd7a0a25c9 Mon Sep 17 00:00:00 2001 From: Katrin Leinweber Date: Fri, 25 Aug 2023 10:21:09 +0200 Subject: [PATCH 2/6] Debug danger-review fails at raise_if_we_cannot_find_the_commit --- .gitlab-ci.yml | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 894e69330..d908732cc 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -28,6 +28,13 @@ include: - project: 'gitlab-org/quality/pipeline-common' file: '/ci/danger-review.yml' # danger-review job below +danger-review: + variables: + CI_DEBUG_TRACE: "true" + after_script: + - 'echo "diff base ${CI_MERGE_REQUEST_DIFF_BASE_SHA}"' + - 'echo "source head ${CI_MERGE_REQUEST_SOURCE_BRANCH_SHA}"' + - 'echo "source head:-default ${CI_COMMIT_SHA}"' # From: https://docs.gitlab.com/ee/ci/caching/#cache-go-dependencies .go-cache: -- GitLab From 8fc5e71a80c29365d196b4cf02c2151f6a77cbc5 Mon Sep 17 00:00:00 2001 From: Katrin Leinweber Date: Fri, 25 Aug 2023 10:39:31 +0200 Subject: [PATCH 3/6] Speed up & focus CI iterations on danger-review only --- .gitlab-ci.yml | 201 ------------------------------------------------- 1 file changed, 201 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index d908732cc..261585889 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -8,23 +8,12 @@ workflow: - if: $CI_COMMIT_TAG - if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH -default: - image: golang:${GO_VERSION} - stages: - documentation - test - release include: - # remove the `.latest` from the following templates after 16.0 GitLab release - # the `.latest` indicates the "nightly" version of the job definition - # when we remove the `.latest`, we'll be using the stable job definition - # https://gitlab.com/gitlab-org/cli/-/merge_requests/1100#note_1186302003 - - template: Jobs/SAST.latest.gitlab-ci.yml - - template: Jobs/Dependency-Scanning.latest.gitlab-ci.yml - - template: Jobs/Secret-Detection.latest.gitlab-ci.yml - - template: Jobs/License-Scanning.latest.gitlab-ci.yml - project: 'gitlab-org/quality/pipeline-common' file: '/ci/danger-review.yml' # danger-review job below @@ -35,193 +24,3 @@ danger-review: - 'echo "diff base ${CI_MERGE_REQUEST_DIFF_BASE_SHA}"' - 'echo "source head ${CI_MERGE_REQUEST_SOURCE_BRANCH_SHA}"' - 'echo "source head:-default ${CI_COMMIT_SHA}"' - -# From: https://docs.gitlab.com/ee/ci/caching/#cache-go-dependencies -.go-cache: - variables: - GOPATH: $CI_PROJECT_DIR/.go - GOLANGCI_LINT_CACHE: $CI_PROJECT_DIR/.golangci-lint - before_script: - - mkdir -p .go .golangci-lint - cache: - paths: - - .go/pkg/mod/ - - .golangci-lint/ - -.documentation: - stage: documentation - rules: - - if: $CI_PIPELINE_SOURCE == "merge_request_event" - -check_docs_update: - extends: .documentation - script: - - git fetch origin $CI_MERGE_REQUEST_TARGET_BRANCH_NAME && git checkout $CI_MERGE_REQUEST_TARGET_BRANCH_NAME && git checkout $CI_COMMIT_SHA - - make gen-docs - - |- - git status - if [[ $(git add -A --dry-run) ]]; then - echo '✖ ERROR: Documentation changes detected!'; - echo '✖ These changes require a documentation update. To regenerate the docs, read https://gitlab.com/gitlab-org/cli/-/tree/main/docs#generating-the-docs.'; - exit 1; - else - echo '✔ No documentation updates detected.'; - exit 0; - fi - -check_docs_markdown: - image: registry.gitlab.com/gitlab-org/gitlab-docs/lint-markdown:alpine-3.16-vale-2.20.1-markdownlint-0.32.2 - extends: .documentation - script: - # Lint prose - - vale --minAlertLevel error docs README.md - # Lint Markdown - - markdownlint --config .markdownlint.yml 'docs/**/*.md' README.md - -lint_commit: - stage: test - image: node:16-slim - script: - - apt-get update && apt-get install -y git - - git fetch origin $CI_MERGE_REQUEST_TARGET_BRANCH_NAME && git checkout $CI_MERGE_REQUEST_TARGET_BRANCH_NAME && git checkout $CI_COMMIT_SHA - - cd scripts/commit-lint && npm ci - - node lint.js - rules: - - if: '$CI_MERGE_REQUEST_IID && $CI_PROJECT_VISIBILITY == "public"' # lint.js script makes an API call without authentication - when: always - -lint: - extends: .go-cache - image: registry.gitlab.com/gitlab-org/gitlab-build-images:golangci-lint-1.50-alpine - stage: test - script: - - golangci-lint --version - # Use default .golangci.yml file from the image if one is not present in the project root. - - '[ -e .golangci.yml ] || cp /golangci/.golangci.yml .' - # Write the code coverage report to gl-code-quality-report.json - # remove `--issues-exit-code 0` or set to non-zero to fail the job if linting issues are detected - - golangci-lint run --out-format colored-line-number:stdout,code-climate:gl-code-quality-report.json - artifacts: - reports: - codequality: gl-code-quality-report.json - paths: - - gl-code-quality-report.json - -code_navigation: - stage: test - image: golang:latest - allow_failure: true - script: - - go install github.com/sourcegraph/lsif-go/cmd/lsif-go@latest - - lsif-go - artifacts: - reports: - lsif: dump.lsif - -run_tests: - stage: test - extends: .go-cache - parallel: - matrix: - - GO_VERSION: ["1.19", "1.20"] - script: - # `goreleaser` also uses GITLAB_TOKEN and so we need to distinguish between - # the GITLAB_TOKEN_TEST with less privilege used for testing and the GITLAB_TOKEN_RELEASE token - # GITLAB_TEST_HOST is the GitLab instance used for the integration tests - - GITLAB_TOKEN=$GITLAB_TOKEN_TEST GITLAB_TEST_HOST=$GITLAB_TEST_HOST make test - after_script: - - echo -e "\e[0Ksection_start:`date +%s`:coverage[collapsed=true]\r\e[0KRunning coverage report" - - make coverage - - echo -e "\e[0Ksection_end:`date +%s`:coverage\r\e[0K" - coverage: /^total:\t+\(statements\)\t+\d+\.\d+%$/ - artifacts: - when: always - paths: - - test-output.log - reports: - junit: coverage.xml - -.release: - stage: release - image: docker:stable - services: - - docker:dind - variables: - # Disable shallow cloning so that goreleaser can diff between tags to - # generate a changelog. - GIT_DEPTH: 0 - needs: [windows_installer] - dependencies: [windows_installer] - -release_test: - extends: .release - rules: - - if: $CI_COMMIT_TAG - when: never - - if: $CI_PIPELINE_SOURCE == "merge_request_event" - - if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH - script: | - docker run --rm --privileged \ - -v $PWD:/go/src/gitlab.com/gitlab-org/cli \ - -w /go/src/gitlab.com/gitlab-org/cli \ - -v /var/run/docker.sock:/var/run/docker.sock \ - goreleaser/goreleaser release --snapshot - -build_windows: - stage: test - extends: .go-cache - script: - - GOOS=windows GOARCH=amd64 make build - - mv bin/glab bin/glab.exe - artifacts: - paths: - - "bin/glab.exe" - expire_in: "30 days" - -windows_installer: - stage: release - image: - name: amake/innosetup - entrypoint: [""] - script: - - mv scripts/setup_windows.iss . - - iscc "setup_windows.iss" -DVersion=${CI_COMMIT_TAG//v} - artifacts: - paths: - - "bin/*" - expire_in: "30 days" - dependencies: [build_windows] - needs: [build_windows] - -release: - extends: .release - rules: - - if: $CI_COMMIT_TAG - script: | - docker run --rm --privileged \ - -v $PWD:/go/src/gitlab.com/gitlab-org/cli \ - -w /go/src/gitlab.com/gitlab-org/cli \ - -v /var/run/docker.sock:/var/run/docker.sock \ - -e GITLAB_TOKEN=$GITLAB_TOKEN_RELEASE \ - --entrypoint "" \ - goreleaser/goreleaser \ - bash -c " - docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY - docker login -u $DOCKER_IO_USER -p $DOCKER_IO_PASSWORD - goreleaser release - " - -homebrew-release: - image: homebrew/ubuntu22.04:latest - stage: release - rules: - - if: $CI_COMMIT_TAG - script: - - touch ~/.gitconfig - - git config --global user.email "$GITHUB_EMAIL" - - git config --global user.name "$GITHUB_NAME" - - curl "$CI_PROJECT_URL/-/archive/$CI_COMMIT_TAG/$CI_PROJECT_NAME-$CI_COMMIT_TAG.tar.gz" --output "$CI_PROJECT_NAME-$CI_COMMIT_TAG.tar.gz" - - brew bump-formula-pr glab --no-browse --url="$CI_PROJECT_URL/-/archive/$CI_COMMIT_TAG/$CI_PROJECT_NAME-$CI_COMMIT_TAG.tar.gz" --sha256="$(sha256sum $CI_PROJECT_NAME-$CI_COMMIT_TAG.tar.gz | cut -d ' ' -f 1)" - -secret_detection: - dependencies: [] # Don't download artifacts, especially `./public/` -- GitLab From c9105eebc98a21ccf01906901aece337968e1362 Mon Sep 17 00:00:00 2001 From: Katrin Leinweber Date: Fri, 25 Aug 2023 10:41:30 +0200 Subject: [PATCH 4/6] Enable temporary inclusion of MR into Merge Train --- .gitlab-ci.yml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 261585889..fe85765a7 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -24,3 +24,8 @@ danger-review: - 'echo "diff base ${CI_MERGE_REQUEST_DIFF_BASE_SHA}"' - 'echo "source head ${CI_MERGE_REQUEST_SOURCE_BRANCH_SHA}"' - 'echo "source head:-default ${CI_COMMIT_SHA}"' + +exit_the_merge_train: + image: alpine:latest + script: + - exit 1 -- GitLab From ec8f36c37d0d84067b2b21b228b1e3e44e2764a8 Mon Sep 17 00:00:00 2001 From: Katrin Leinweber Date: Fri, 25 Aug 2023 13:16:58 +0200 Subject: [PATCH 5/6] Investigate local refs --- .gitlab-ci.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index fe85765a7..3574be704 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -24,6 +24,8 @@ danger-review: - 'echo "diff base ${CI_MERGE_REQUEST_DIFF_BASE_SHA}"' - 'echo "source head ${CI_MERGE_REQUEST_SOURCE_BRANCH_SHA}"' - 'echo "source head:-default ${CI_COMMIT_SHA}"' + - git fetch --unshallow --all && find .git/refs -type f -exec ls -l {} \; -exec cat {} \; + - git fetch refs/merge_requests/$CI_MERGE_REQUEST_IID/train || git fetch 'refs/merge_requests/*' exit_the_merge_train: image: alpine:latest -- GitLab From d3409aee5d5d6d435cc9bf7231b8a63db04928ba Mon Sep 17 00:00:00 2001 From: Katrin Leinweber Date: Fri, 25 Aug 2023 13:27:11 +0200 Subject: [PATCH 6/6] Add forked remote --- .gitlab-ci.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 3574be704..41ff50e6c 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -24,6 +24,7 @@ danger-review: - 'echo "diff base ${CI_MERGE_REQUEST_DIFF_BASE_SHA}"' - 'echo "source head ${CI_MERGE_REQUEST_SOURCE_BRANCH_SHA}"' - 'echo "source head:-default ${CI_COMMIT_SHA}"' + - git remote add neil https://gitlab.com/realtime-neil/glab-cli.git - git fetch --unshallow --all && find .git/refs -type f -exec ls -l {} \; -exec cat {} \; - git fetch refs/merge_requests/$CI_MERGE_REQUEST_IID/train || git fetch 'refs/merge_requests/*' -- GitLab