|
| 1 | +name: golangci-lint |
| 2 | +on: |
| 3 | + push: |
| 4 | + tags: |
| 5 | + - v* |
| 6 | + branches: |
| 7 | + - dev |
| 8 | + pull_request: |
| 9 | +permissions: |
| 10 | + contents: read |
| 11 | + # Optional: allow read access to pull request. Use with `only-new-issues` option. |
| 12 | + # pull-requests: read |
| 13 | +jobs: |
| 14 | + collectpackages: |
| 15 | + name: "Collect all packages to a list" |
| 16 | + runs-on: ubuntu-latest |
| 17 | + outputs: |
| 18 | + packages: "${{ steps.create-package-list.outputs.packages }}" |
| 19 | + steps: |
| 20 | + - uses: actions/checkout@v5 |
| 21 | + - name: "Collect by calling 'make print_collected_packages'" |
| 22 | + id: create-package-list |
| 23 | + run: | |
| 24 | + pkgs=$(make print_collected_packages) |
| 25 | + # replace space by comma, add double quotes and copy to output |
| 26 | + echo "packages=[\"${pkgs// /\",\"}\"]" >> $GITHUB_OUTPUT |
| 27 | + - name: "Debug the collected packages as JSON array" |
| 28 | + run: echo "The collected packages are ${{ steps.create-package-list.outputs.packages }}" |
| 29 | + |
| 30 | + golangci: |
| 31 | + needs: collectpackages |
| 32 | + runs-on: ubuntu-latest |
| 33 | + strategy: |
| 34 | + matrix: |
| 35 | + package: "${{ fromJson(needs.collectpackages.outputs.packages) }}" |
| 36 | + name: "lint ${{ matrix.package }}" |
| 37 | + steps: |
| 38 | + - uses: actions/checkout@v5 |
| 39 | + - uses: actions/setup-go@v6 |
| 40 | + with: |
| 41 | + go-version: '1.22' |
| 42 | + cache: false |
| 43 | + - name: "Debug the workspace and package" |
| 44 | + run: echo "The package ${{ matrix.package }} is in workspace ${{ github.workspace }}" |
| 45 | + - name: golangci-lint |
| 46 | + uses: golangci/golangci-lint-action@v8 |
| 47 | + with: |
| 48 | + version: v2.5.0 |
| 49 | + working-directory: ${{ matrix.package }} |
| 50 | + |
| 51 | + # Optional: golangci-lint command line arguments. |
| 52 | + # Note: exclude arguments, e.g. --exclude-files="my_file", will not affect the "typecheck" linter, |
| 53 | + # at least since v1.61.0 - use build tags instead. |
| 54 | + #args: --exclude-files="platforms/digispark/digispark_adaptor.go" |
| 55 | + |
| 56 | + # Optional: show only new issues if it's a pull request. The default value is `false`. |
| 57 | + # only-new-issues: true |
| 58 | + |
| 59 | + # Optional: if set to true then the all caching functionality will be complete disabled, |
| 60 | + # takes precedence over all other caching options. |
| 61 | + # skip-cache: true |
0 commit comments