Add patch_when_closed to GitOps and generate-gitops #37932
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: golangci-lint | |
| on: | |
| push: | |
| branches: | |
| - main | |
| - patch-* | |
| - prepare-* | |
| paths: | |
| - '**.go' | |
| - '.github/workflows/golangci-lint.yml' | |
| - '.golangci.yml' | |
| - '.golangci-incremental.yml' | |
| - '.custom-gcl.yml' | |
| pull_request: | |
| paths: | |
| - '**.go' | |
| - '.github/workflows/golangci-lint.yml' | |
| - '.golangci.yml' | |
| - '.golangci-incremental.yml' | |
| - '.custom-gcl.yml' | |
| workflow_dispatch: # Manual | |
| schedule: | |
| - cron: '0 4 * * *' # Daily 4 AM UTC, runs the full OS lint matrix | |
| # This allows a subsequently queued workflow run to interrupt previous runs | |
| concurrency: | |
| group: ${{ github.workflow }}-${{ github.head_ref || github.run_id}} | |
| cancel-in-progress: true | |
| defaults: | |
| run: | |
| # fail-fast using bash -eo pipefail. See https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#exit-codes-and-error-action-preference | |
| shell: bash | |
| permissions: | |
| contents: read | |
| jobs: | |
| golangci: | |
| permissions: | |
| contents: read # for actions/checkout to fetch code | |
| pull-requests: read # for actions/checkout to fetch pull requests | |
| name: lint | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| # PR/push runs Linux only for fast, cheap feedback. The full OS matrix | |
| # (macOS + Windows) runs nightly via the schedule trigger and on manual dispatch. | |
| os: ${{ fromJSON((github.event_name == 'schedule' || github.event_name == 'workflow_dispatch') && '["ubuntu-4core","macos-latest","windows-latest"]' || '["ubuntu-4core"]') }} | |
| runs-on: ${{ matrix.os }} | |
| steps: | |
| # Tell git not to change line endings when checking out files on Windows. Without this gofmt | |
| # flags every single file on windows-latest | |
| - run: 'git config --global core.autocrlf input' | |
| - name: Harden Runner | |
| uses: step-security/harden-runner@9af89fc71515a100421586dfdb3dc9c984fbf411 # v2.19.4 | |
| with: | |
| egress-policy: audit | |
| - name: Checkout code | |
| uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3.5.3 | |
| with: | |
| persist-credentials: false | |
| - name: Install Go | |
| uses: actions/setup-go@4b73464bb391d4059bd26b0524d20df3927bd417 # v6.3.0 | |
| with: | |
| go-version-file: 'go.mod' | |
| - name: Install dependencies (Linux) | |
| if: matrix.os == 'ubuntu-4core' | |
| run: | | |
| # The following packages are needed to build Fleet Desktop on Ubuntu. | |
| sudo apt update -y && sudo apt install -y gcc libgtk-3-dev libayatana-appindicator3-dev | |
| - name: Run go lint | |
| run: | | |
| # Don't forget to update | |
| # docs/Contributing/Testing-and-local-development.md when this version changes | |
| go install github.com/golangci/golangci-lint/v2/cmd/golangci-lint@6008b81b81c690c046ffc3fd5bce896da715d5fd # v2.11.3 | |
| SKIP_INCREMENTAL=1 make lint-go | |
| - name: Run cloner-check tool | |
| run: | | |
| go run ./tools/cloner-check/main.go -check | |
| - name: Ensure all FLEET_DEV_* env var accesses are proxied | |
| run: | | |
| if grep -R 'os.Getenv("FLEET_DEV' --include="*.go" .; then | |
| echo "Error: Found unproxied FLEET_DEV_* env var access. Please proxy via dev_mode.Env()." >&2 | |
| exit 1 | |
| else | |
| echo "OK: No unproxied FLEET_DEV_* env var accesses found." | |
| fi | |
| - name: Restrict FLEET_DEV_* env var overrides to test code only | |
| run: | | |
| if grep -R 'SetOverride("FLEET_DEV' --include="*.go" --exclude="*_test.go" --exclude="testing_utils.go" --exclude-dir="mdmtest" --exclude-dir="maintainedappstest" .; then | |
| echo "Error: Found FLEET_DEV_* overrides in non-test code." >&2 | |
| exit 1 | |
| else | |
| echo "OK: No FLEET_DEV_* overrides in non-test code." | |
| fi | |
| golangci-incremental: | |
| # Only run on pull requests (needs base branch for incremental comparison) | |
| if: github.event_name == 'pull_request' | |
| permissions: | |
| contents: read | |
| pull-requests: read | |
| name: lint-incremental | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| os: [ubuntu-4core] | |
| runs-on: ${{ matrix.os }} | |
| steps: | |
| - name: Harden Runner | |
| uses: step-security/harden-runner@9af89fc71515a100421586dfdb3dc9c984fbf411 # v2.19.4 | |
| with: | |
| egress-policy: audit | |
| - name: Checkout code | |
| uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3.5.3 | |
| with: | |
| fetch-depth: 0 # Fetch full history for accurate diff | |
| persist-credentials: false | |
| - name: Install Go | |
| uses: actions/setup-go@4b73464bb391d4059bd26b0524d20df3927bd417 # v6.3.0 | |
| with: | |
| go-version-file: 'go.mod' | |
| - name: Install dependencies (Linux) | |
| if: matrix.os == 'ubuntu-4core' | |
| run: | | |
| # The following packages are needed to build Fleet Desktop on Ubuntu. | |
| sudo apt update -y && sudo apt install -y gcc libgtk-3-dev libayatana-appindicator3-dev | |
| - name: Run incremental go lint | |
| run: | | |
| # Don't forget to update | |
| # docs/Contributing/Testing-and-local-development.md when this version changes | |
| go install github.com/golangci/golangci-lint/v2/cmd/golangci-lint@6008b81b81c690c046ffc3fd5bce896da715d5fd # v2.11.3 | |
| # custom build of golangci-lint that incorporates nilaway - see .custom-gcl.yml | |
| golangci-lint custom | |
| ./custom-gcl run -c .golangci-incremental.yml --new-from-rev=origin/${{ github.base_ref }} --timeout 15m ./... |