diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 5bc35a6..5ccef8e 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -4,13 +4,37 @@ on: tags: - v* branches: - - actions - main pull_request: + jobs: + generate-matrix: + name: Generate matrix + runs-on: ubuntu-latest + outputs: + matrix: ${{ steps.set-matrix.outputs.matrix }} + golangci_cfg_path: ${{ steps.find-golangci-cfg-path.outputs.golangci_cfg_path }} + steps: + - name: Checkout + uses: actions/checkout@v2 + - name: Set matrix + id: set-matrix + run: | + MODULES=$(find . -type f -name "go.mod" | sed -e 's/\/go.mod//g' | jq -R -s -c 'split("\n")[:-1]') + echo "matrix=${MODULES}" >> $GITHUB_OUTPUT + - name: Find golangci.yml path + id: find-golangci-cfg-path + run: | + GOLANGCI_CFG_PATH=$(find $GITHUB_WORKSPACE -type f -name ".golangci.yml" | head -n 1) + echo "golangci_cfg_path=${GOLANGCI_CFG_PATH}" >> $GITHUB_OUTPUT + golangci: name: golangci + needs: generate-matrix runs-on: ubuntu-latest + strategy: + matrix: + modules: ${{ fromJson(needs.generate-matrix.outputs.matrix) }} steps: - uses: actions/setup-go@v3 with: @@ -19,23 +43,7 @@ jobs: - name: golangci-lint uses: golangci/golangci-lint-action@v3 with: - # Optional: version of golangci-lint to use in form of v1.2 or v1.2.3 or `latest` to use the latest version version: latest + working-directory: ${{ matrix.modules }} + args: -E misspell -E revive -E gochecknoinits -E gofmt -E errname -c ${{ needs.generate-matrix.outputs.golangci_cfg_path }} - # Optional: working directory, useful for monorepos - # working-directory: somedir - - # Optional: golangci-lint command line arguments. - args: -E misspell -E revive -E bodyclose -E errname -E gofmt --timeout=5m - - # Optional: show only new issues if it's a pull request. The default value is `false`. - # only-new-issues: true - - # Optional: if set to true then the action will use pre-installed Go. - # skip-go-installation: true - - # Optional: if set to true then the action don't cache or restore ~/go/pkg. - # skip-pkg-cache: true - - # Optional: if set to true then the action don't cache or restore ~/.cache/go-build. - # skip-build-cache: true diff --git a/Makefile b/Makefile index 6dad65a..833a691 100644 --- a/Makefile +++ b/Makefile @@ -2,7 +2,9 @@ build: $(MAKE) -C testdata/hello-go build tests: build - go test -race -v -covermode=atomic -coverprofile=coverage.out ./... + $(MAKE) -C callbacks tests + $(MAKE) -C engine tests benchmarks: build - go test -bench=. -benchmem ./... + $(MAKE) -C callbacks benchmarks + $(MAKE) -C engine benchmarks diff --git a/callbacks/Makefile b/callbacks/Makefile new file mode 100644 index 0000000..490dc85 --- /dev/null +++ b/callbacks/Makefile @@ -0,0 +1,5 @@ +tests: + go test -race -v -covermode=atomic -coverprofile=coverage.out ./... + +benchmarks: + go test -bench=. -benchmem ./... diff --git a/callbacks/go.mod b/callbacks/go.mod new file mode 100644 index 0000000..296c663 --- /dev/null +++ b/callbacks/go.mod @@ -0,0 +1,3 @@ +module github.com/tarmac-project/wapc-toolkit/callbacks + +go 1.21.4 diff --git a/engine/Makefile b/engine/Makefile new file mode 100644 index 0000000..490dc85 --- /dev/null +++ b/engine/Makefile @@ -0,0 +1,5 @@ +tests: + go test -race -v -covermode=atomic -coverprofile=coverage.out ./... + +benchmarks: + go test -bench=. -benchmem ./... diff --git a/go.mod b/engine/go.mod similarity index 76% rename from go.mod rename to engine/go.mod index 68d5030..9ef7acc 100644 --- a/go.mod +++ b/engine/go.mod @@ -1,4 +1,4 @@ -module github.com/tarmac-project/wapc-toolkit +module github.com/tarmac-project/wapc-toolkit/engine go 1.21.4 diff --git a/go.sum b/engine/go.sum similarity index 100% rename from go.sum rename to engine/go.sum