diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 11954a41..c806841d 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -28,6 +28,41 @@ jobs: parallel: true flag-name: ${{ join(matrix.*, ' ') }} + test-integration: + strategy: + matrix: + go-version: [1.20.x] + os: [ubuntu-latest, macos-latest, windows-latest] + runs-on: ${{ matrix.os }} + env: + GOCOVERDIR: _icoverdir_ + steps: + - name: Install Go + uses: actions/setup-go@v2 + with: + go-version: ${{ matrix.go-version }} + - name: Checkout code + uses: actions/checkout@v2 + - name: Integration tests + run: | + mkdir _icoverdir_ + make build-with-coverage + cp examples/complete/lefthook.yml . + # TODO: prepare a framework to test the results + - run: | + ./lefthook dump + ./lefthook dump --json + ./lefthook dump --toml + - name: Format coverage + run: | + go tool covdata textfmt -i _icoverdir_ -o coverage.out + - name: Report coverage + uses: coverallsapp/github-action@v2 + with: + file: coverage.out + parallel: true + flag-name: integration-${{ join(matrix.*, ' ') }} + build: runs-on: ubuntu-latest steps: @@ -53,9 +88,11 @@ jobs: coverage: runs-on: ubuntu-latest - needs: test + needs: + - test + - test-integration steps: - uses: coverallsapp/github-action@v2 with: - carryforward: "1.19.x ubuntu-latest,1.19.x macos-latest,1.19.x windows-latest" + carryforward: "integration-1.20.x ubuntu-latest,integration-1.20.x macos-latest,integration-1.20.x windows-latest,1.19.x ubuntu-latest,1.19.x macos-latest,1.19.x windows-latest" parallel-finished: true diff --git a/Makefile b/Makefile index e246c64e..63834a69 100644 --- a/Makefile +++ b/Makefile @@ -3,9 +3,17 @@ COMMIT_HASH = $(shell git rev-parse HEAD) build: go build -ldflags "-s -w -X github.com/evilmartians/lefthook/internal/version.commit=$(COMMIT_HASH)" -o lefthook +build-with-coverage: + go build -cover -ldflags "-s -w -X github.com/evilmartians/lefthook/internal/version.commit=$(COMMIT_HASH)" -o lefthook + test: go test -cpu 24 -race -count=1 -timeout=30s ./... +test-integration: build-with-coverage + ./lefthook dump + ./lefthook dump --json + ./lefthook dump --toml + bench: go test -cpu 24 -race -run=Bench -bench=. ./... diff --git a/internal/config/command.go b/internal/config/command.go index bcb86aa5..f30ad6aa 100644 --- a/internal/config/command.go +++ b/internal/config/command.go @@ -12,7 +12,7 @@ import ( var errFilesIncompatible = errors.New("One of your runners contains incompatible file types") type Command struct { - Run string `mapstructure:"run"` + Run string `mapstructure:"run" yaml:"run" toml:"run" json:"run"` Skip interface{} `mapstructure:"skip" yaml:",omitempty" toml:"skip,omitempty" json:"skip,omitempty"` Only interface{} `mapstructure:"only" yaml:",omitempty" toml:"only,omitempty,inline" json:"only,omitempty"` diff --git a/internal/config/script.go b/internal/config/script.go index a1efd3fc..352d66f8 100644 --- a/internal/config/script.go +++ b/internal/config/script.go @@ -10,7 +10,7 @@ import ( ) type Script struct { - Runner string `mapstructure:"runner"` + Runner string `mapstructure:"runner" yaml:"runner" toml:"runner" json:"runner"` Skip interface{} `mapstructure:"skip" yaml:",omitempty" toml:"skip,omitempty" json:"skip,omitempty"` Only interface{} `mapstructure:"only" yaml:",omitempty" toml:"only,omitempty,inline" json:"only,omitempty"`