-
Notifications
You must be signed in to change notification settings - Fork 33
60 lines (53 loc) · 1.9 KB
/
reusable-lint-providers.yml
File metadata and controls
60 lines (53 loc) · 1.9 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
name: Lint Providers
on:
workflow_call:
inputs:
only-new-issues:
description: 'Only report new issues (requires pull-requests: read permission at caller workflow level)'
type: boolean
default: false
permissions:
contents: read
jobs:
lint:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
fetch-depth: 0
- name: Import environment variables from file
run: cat ".github/env" >> $GITHUB_ENV
- name: Install Go
uses: actions/setup-go@4b73464bb391d4059bd26b0524d20df3927bd417 # v6.3.0
with:
go-version: ">=${{ env.golang-version }}"
cache: false
- name: Install golangci-lint
run: go install github.com/golangci/golangci-lint/v2/cmd/golangci-lint@5d1e709b7be35cb2025444e19de266b056b7b7ee #v2.10.1
- name: Run golangci-lint on all providers
env:
ONLY_NEW_ISSUES: ${{ inputs.only-new-issues }}
BASE_SHA: ${{ github.event.pull_request.base.sha }}
run: |
failed=""
extra_args=""
if [ "$ONLY_NEW_ISSUES" = "true" ] && [ -n "${BASE_SHA}" ]; then
git fetch origin "${BASE_SHA}" --depth=1
extra_args="--new-from-rev=${BASE_SHA}"
fi
for provider in providers/*/; do
# Skip providers without go.mod (they are part of the main module)
if [ ! -f "$provider/go.mod" ]; then
continue
fi
name=$(basename "$provider")
echo "=== Linting provider: $name ==="
if ! (cd "$provider" && golangci-lint run --timeout=30m $extra_args); then
failed="$failed $name"
fi
done
if [ -n "$failed" ]; then
echo "=== Failed providers:$failed ==="
exit 1
fi