build(go.mod): missing 'go mod tidy' #8
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: Tests and Linters Scalingo go-utils Packages | |
on: [push] | |
# # The list of permissions is explained on the GitHub doc: | |
# # https://docs.github.com/en/actions/using-jobs/assigning-permissions-to-jobs | |
# permissions: | |
# # allow read access to pull request. Use with golangci-lint `only-new-issues` option. | |
# pull-requests: read | |
jobs: | |
detect-modules: | |
name: Detect the Go modules declared in go-utils | |
runs-on: ubuntu-22.04 | |
outputs: | |
modules: ${{ steps.set-modules.outputs.modules }} | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
# We need to define the fetch-depth to 0 so that we can get the commit ID of the master branch | |
fetch-depth: 0 | |
- uses: actions/setup-go@v5 | |
with: | |
go-version: stable | |
check-latest: true | |
- id: set-modules | |
run: | | |
echo -n "modules=" > $GITHUB_OUTPUT | |
for m in ./*/*go.mod; do | |
pushd $(dirname "$m") > /dev/null | |
module_path="$(go list -m -json | jq --slurp '.' | jq --compact-output --raw-output '.[].Dir')" | |
echo $module_path | |
popd > /dev/null | |
done | jq --raw-input --slurp 'split("\n")' | jq --compact-output 'map(select(length > 0))' >> $GITHUB_OUTPUT | |
linter-pull-request: | |
needs: detect-modules | |
name: golangci-lint on a PR or from a tag | |
runs-on: ubuntu-22.04 | |
strategy: | |
matrix: | |
modules: ${{ fromJSON(needs.detect-modules.outputs.modules) }} | |
if: github.ref != 'refs/heads/master' | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
# We need to define the fetch-depth to 0 so that we can get the commit ID of the master branch | |
fetch-depth: 0 | |
- uses: actions/setup-go@v5 | |
with: | |
go-version: stable | |
check-latest: true | |
- name: Get golangci-lint configuration file | |
run: wget --output-document=$(pwd)/.golangci.yml https://sc-devtools.s3.eu-west-1.amazonaws.com/golang-ci/golangci.yml | |
- name: Get master branch commit ID | |
id: new-from-rev | |
run: echo "NEW_FROM_REV=$( git rev-parse origin/master )" >> "$GITHUB_OUTPUT" | |
- name: "Execute golangci-lint on a pull request" | |
uses: golangci/golangci-lint-action@v6 | |
with: | |
working-directory: ${{ matrix.modules }} | |
# The `only-new-issues` flag is not working (https://github.com/golangci/golangci-lint-action/issues/531). | |
# We rather decided to use the suggestion from the FAQ (https://golangci-lint.run/welcome/faq/#how-to-integrate-golangci-lint-into-large-project-with-thousands-of-issues) and use `--new-from-rev` | |
# only-new-issues: false | |
args: "--config=$(pwd)/../.golangci.yml --new-from-rev=${{ steps.new-from-rev.outputs.NEW_FROM_REV }} --modules-download-mode=mod" | |
tests: | |
needs: detect-modules | |
name: Unit Tests | |
runs-on: ubuntu-22.04 | |
strategy: | |
matrix: | |
modules: ${{ fromJSON(needs.detect-modules.outputs.modules) }} | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: actions/setup-go@v5 | |
with: | |
go-version: stable | |
check-latest: true | |
- name: Execute the tests | |
working-directory: ${{ matrix.modules }} | |
run: go test -race ./... |