-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update golangci-lint action to go through all dirs if no working dire…
…ctory set
- Loading branch information
Showing
3 changed files
with
49 additions
and
17 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
#!/bin/bash | ||
# Recursively finds all directories with a go.mod file and creates | ||
# a GitHub Actions JSON output option. This is used by the linter action. | ||
|
||
echo "Resolving modules in $(pwd)" | ||
|
||
PATHS=$(find . -mindepth 2 -type f -name go.mod -printf '{"workdir":"%h"},') | ||
echo "::set-output name=matrix::{\"include\":[${PATHS%?}]}" |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -91,24 +91,41 @@ jobs: | |
- '!nix-darwin-shell-hook.sh' | ||
- '!LICENSE' | ||
- '!.github/**' | ||
# Golangci-lint needs path to each module to run in monorepo, | ||
# so we resolve the modules first | ||
resolve-modules: | ||
name: Resolve Modules for GolangCI Lint | ||
runs-on: ubuntu-latest | ||
outputs: | ||
matrix: ${{ steps.set-matrix.outputs.matrix }} | ||
steps: | ||
- name: Checkout | ||
uses: actions/[email protected] | ||
- name: Set Matrix for GolangCI Lint | ||
id: set-matrix | ||
run: ./scripts/resolve-modules.sh | ||
|
||
golangci: | ||
name: lint | ||
# We don't directly merge dependabot PRs, so let's not waste the resources | ||
if: ${{ (github.event_name == 'pull_request' || github.event_name == 'schedule') && github.actor != 'dependabot[bot]' }} | ||
name: lint | ||
permissions: | ||
# For golangci-lint-actions to annotate code in the PR. | ||
checks: write | ||
contents: read | ||
# For golangci-lint-action's `only-new-issues` option. | ||
pull-requests: read | ||
runs-on: ubuntu-24.04-8cores-32GB-ARM | ||
needs: [filter, run-frequency] | ||
needs: [filter, run-frequency, resolve-modules] | ||
steps: | ||
- uses: actions/[email protected] | ||
- name: Checkout | ||
uses: actions/[email protected] | ||
- name: Golang Lint | ||
uses: ./.github/actions/golangci-lint | ||
if: ${{ needs.filter.outputs.should-run-golangci == 'true' }} | ||
uses: ./actions/golangci-lint | ||
with: | ||
go-directory: ${{ steps.resolve-modules.outputs.matrix }} | ||
- name: Notify Slack | ||
if: ${{ failure() && needs.run-frequency.outputs.one-per-day-frequency == 'true' }} | ||
uses: slackapi/slack-github-action@6c661ce58804a1a20f6dc5fbee7f0381b469e001 # v1.25.0 | ||
|