From 9bfea8ef7d2a26b86548667c724110d8f2e58d3a Mon Sep 17 00:00:00 2001 From: Matt Dale <9760375+matthewdale@users.noreply.github.com> Date: Fri, 1 Aug 2025 01:50:27 -0700 Subject: [PATCH 1/2] Use a pinned Go version for golangci-lint. (#2151) --- .github/workflows/test.yml | 3 +++ .pre-commit-config.yaml | 9 +++++++-- Makefile | 18 +++++++----------- etc/golangci-lint.sh | 24 ++++++++++++++++++++++++ 4 files changed, 41 insertions(+), 13 deletions(-) create mode 100755 etc/golangci-lint.sh diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index c4e5498fbf..a72ffa4ad9 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -18,4 +18,7 @@ jobs: steps: - uses: actions/checkout@v4 - uses: actions/setup-python@v5 + - uses: actions/setup-go@v5 + with: + go-version: 'stable' - uses: pre-commit/action@v3.0.1 diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index f78a95601b..db12c76224 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -50,7 +50,12 @@ repos: - id: markdown-link-check exclude: ^(vendor) -- repo: https://github.com/golangci/golangci-lint - rev: v1.60.1 +- repo: local hooks: - id: golangci-lint + name: golangci-lint + language: system + types: [go] + require_serial: true + pass_filenames: false + entry: etc/golangci-lint.sh diff --git a/Makefile b/Makefile index a3db27e0d1..f6045ba766 100644 --- a/Makefile +++ b/Makefile @@ -70,22 +70,18 @@ doc: fmt: go fmt ./... -.PHONY: install-golangci-lint -install-golangci-lint: - go install github.com/golangci/golangci-lint/cmd/golangci-lint@v1.60.1 - # Lint with various GOOS and GOARCH targets to catch static analysis failures that may only affect # specific operating systems or architectures. For example, staticcheck will only check for 64-bit # alignment of atomically accessed variables on 32-bit architectures (see # https://staticcheck.io/docs/checks#SA1027) .PHONY: lint -lint: install-golangci-lint - GOOS=linux GOARCH=386 golangci-lint run --config .golangci.yml ./... - GOOS=linux GOARCH=arm golangci-lint run --config .golangci.yml ./... - GOOS=linux GOARCH=arm64 golangci-lint run --config .golangci.yml ./... - GOOS=linux GOARCH=amd64 golangci-lint run --config .golangci.yml ./... - GOOS=linux GOARCH=ppc64le golangci-lint run --config .golangci.yml ./... - GOOS=linux GOARCH=s390x golangci-lint run --config .golangci.yml ./... +lint: + GOOS=linux GOARCH=386 etc/golangci-lint.sh + GOOS=linux GOARCH=arm etc/golangci-lint.sh + GOOS=linux GOARCH=arm64 etc/golangci-lint.sh + GOOS=linux GOARCH=amd64 etc/golangci-lint.sh + GOOS=linux GOARCH=ppc64le etc/golangci-lint.sh + GOOS=linux GOARCH=s390x etc/golangci-lint.sh .PHONY: update-notices update-notices: diff --git a/etc/golangci-lint.sh b/etc/golangci-lint.sh new file mode 100755 index 0000000000..8d7903e927 --- /dev/null +++ b/etc/golangci-lint.sh @@ -0,0 +1,24 @@ +#!/usr/bin/env bash +set -ex + +# Keep this in sync with go version used in static-analysis Evergreen build variant. +GO_VERSION=1.22.8 +GOLANGCI_LINT_VERSION=1.60.1 + +# Unset the cross-compiler overrides while downloading binaries. +GOOS_ORIG=${GOOS:-} +export GOOS= +GOARCH_ORIG=${GOARCH:-} +export GOARCH= + +go install golang.org/dl/go$GO_VERSION@latest +go${GO_VERSION} download +GOROOT="$(go${GO_VERSION} env GOROOT)" +PATH="$GOROOT/bin:$PATH" +export PATH +export GOROOT +go install github.com/golangci/golangci-lint/cmd/golangci-lint@v${GOLANGCI_LINT_VERSION} + +export GOOS=$GOOS_ORIG +export GOARCH=$GOARCH_ORIG +golangci-lint run --config .golangci.yml ./... From d4064746e1ae2adcc9ef98147e3d3ef80e23425c Mon Sep 17 00:00:00 2001 From: Andreas Braun Date: Fri, 1 Aug 2025 10:59:10 +0200 Subject: [PATCH 2/2] GODRIVER-3564: Add config and workflows for release note labels (#2148) --- .evergreen/config.yml | 28 ---------------------------- .github/CODEOWNERS | 1 + .github/labeler.yml | 5 ++--- .github/release.yml | 25 +++++++++++++++++++++++++ .github/reviewers.txt | 3 --- .github/workflows/check-labels.yml | 19 +++++++++++++++++++ .github/workflows/labeler.yml | 12 ++++++++++++ 7 files changed, 59 insertions(+), 34 deletions(-) create mode 100644 .github/CODEOWNERS create mode 100644 .github/release.yml delete mode 100644 .github/reviewers.txt create mode 100644 .github/workflows/check-labels.yml create mode 100644 .github/workflows/labeler.yml diff --git a/.evergreen/config.yml b/.evergreen/config.yml index 1800457b2b..6820eee952 100644 --- a/.evergreen/config.yml +++ b/.evergreen/config.yml @@ -410,32 +410,6 @@ functions: export HEAD_SHA=${github_commit} bash etc/api_report.sh - "add PR labels": - - command: shell.exec - type: test - params: - shell: "bash" - working_dir: src/go.mongodb.org/mongo-driver - add_expansions_to_env: true - script: | - ${PREPARE_SHELL} - export CONFIG=$PROJECT_DIRECTORY/.github/labeler.yml - export SCRIPT="$DRIVERS_TOOLS/.evergreen/github_app/apply-labels.sh" - bash $SCRIPT -l $CONFIG -h ${github_commit} -o "mongodb" -n "mongo-go-driver" - - "add PR reviewer": - - command: shell.exec - type: test - params: - shell: "bash" - working_dir: src/go.mongodb.org/mongo-driver - add_expansions_to_env: true - script: | - ${PREPARE_SHELL} - export CONFIG=$PROJECT_DIRECTORY/.github/reviewers.txt - export SCRIPT="$DRIVERS_TOOLS/.evergreen/github_app/assign-reviewer.sh" - bash $SCRIPT -p $CONFIG -h ${github_commit} -o "mongodb" -n "mongo-go-driver" - "backport pr": - command: subprocess.exec type: test @@ -936,8 +910,6 @@ tasks: allowed_requesters: ["patch", "github_pr"] commands: - func: assume-test-secrets-ec2-role - - func: "add PR reviewer" - - func: "add PR labels" - func: "create-api-report" - name: backport-pr diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS new file mode 100644 index 0000000000..1fad82a6a2 --- /dev/null +++ b/.github/CODEOWNERS @@ -0,0 +1 @@ +* @mongodb/dbx-go diff --git a/.github/labeler.yml b/.github/labeler.yml index 58eb1bbd43..ae7a121cc6 100644 --- a/.github/labeler.yml +++ b/.github/labeler.yml @@ -1,15 +1,14 @@ - priority-3-low: - changed-files: - any-glob-to-any-file: '*' documentation: - changed-files: - - any-glob-to-any-file: + - any-glob-to-any-file: - docs/** - examples/** dependencies: - changed-files: - - any-glob-to-any-file: + - any-glob-to-any-file: - go.mod diff --git a/.github/release.yml b/.github/release.yml new file mode 100644 index 0000000000..34b72a0bdf --- /dev/null +++ b/.github/release.yml @@ -0,0 +1,25 @@ +changelog: + exclude: + labels: + - ignore-for-release + - github_actions + - submodules + authors: + - mongodb-drivers-pr-bot + categories: + - title: ⚠️ Breaking Changes + labels: + - breaking + - title: ✨ New Features + labels: + - enhancement + - feature + - title: 🐛 Fixed + labels: + - bug + - title: 📦 Dependency Updates + labels: + - dependencies + - title: 📝 Other Changes + labels: + - "*" diff --git a/.github/reviewers.txt b/.github/reviewers.txt deleted file mode 100644 index 2230c13423..0000000000 --- a/.github/reviewers.txt +++ /dev/null @@ -1,3 +0,0 @@ -qingyang-hu -matthewdale -prestonvasquez diff --git a/.github/workflows/check-labels.yml b/.github/workflows/check-labels.yml new file mode 100644 index 0000000000..6a1be9c31c --- /dev/null +++ b/.github/workflows/check-labels.yml @@ -0,0 +1,19 @@ +name: Label Checker +on: + pull_request: + types: + - opened + - synchronize + - reopened + - labeled + - unlabeled + +jobs: + check_labels: + name: Check labels + runs-on: ubuntu-latest + steps: + - uses: docker://agilepathway/pull-request-label-checker:latest + with: + one_of: bug,feature,enhancement,documentation,dependencies + repo_token: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/labeler.yml b/.github/workflows/labeler.yml new file mode 100644 index 0000000000..52474c6a6c --- /dev/null +++ b/.github/workflows/labeler.yml @@ -0,0 +1,12 @@ +name: "Pull Request Labeler" +on: + - pull_request_target + +jobs: + labeler: + permissions: + contents: read + pull-requests: write + runs-on: ubuntu-latest + steps: + - uses: actions/labeler@v5