Merge pull request #1496 from gofiber/dependabot/go_modules/s3/github… #1519
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
name: Golangci-Lint Check | |
on: | |
push: | |
branches: | |
- "master" | |
- "main" | |
paths-ignore: | |
- "**.md" | |
- LICENSE | |
- ".github/ISSUE_TEMPLATE/*.yml" | |
- ".github/dependabot.yml" | |
pull_request: | |
branches: | |
- "*" | |
paths-ignore: | |
- "**.md" | |
- LICENSE | |
- ".github/ISSUE_TEMPLATE/*.yml" | |
- ".github/dependabot.yml" | |
jobs: | |
generate-matrix: | |
runs-on: ubuntu-latest | |
outputs: | |
matrix: ${{ steps.set-matrix.outputs.matrix }} | |
steps: | |
- name: Fetch Repository | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- id: set-matrix | |
run: | | |
# Determine the base and head commits for diff based on the event type | |
BASE_SHA="${{ github.event.pull_request.base.sha || github.event.before }}" | |
HEAD_SHA="${{ github.event.pull_request.head.sha || github.event.after }}" | |
# Extract directories from changed files, only include those with go.mod files | |
GO_MOD_DIRECTORIES=() | |
FILES=$(git diff --name-only $BASE_SHA $HEAD_SHA | grep -vE '/\.') | |
DIRECTORIES=$(echo "$FILES" | xargs -L1 dirname | sort -u) | |
for dir in $DIRECTORIES; do | |
if [[ -f "$dir/go.mod" ]]; then | |
GO_MOD_DIRECTORIES+=("$dir") | |
fi | |
done | |
# Export the JSON array | |
JSON_ARRAY=$(printf '%s\n' "${GO_MOD_DIRECTORIES[@]}" | jq -R -s -c 'split("\n")[:-1]') | |
echo "matrix=${JSON_ARRAY}" >> $GITHUB_OUTPUT | |
lint: | |
needs: generate-matrix | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
modules: ${{fromJson(needs.generate-matrix.outputs.matrix)}} | |
steps: | |
- name: Fetch Repository | |
uses: actions/checkout@v4 | |
- name: Run golangci-lint | |
uses: reviewdog/action-golangci-lint@v2 | |
with: | |
golangci_lint_flags: "--tests=false --timeout=5m" | |
workdir: ${{ matrix.modules }} | |
fail_on_error: true | |
filter_mode: nofilter |