Skip to content

Commit

Permalink
ci: add integration tests
Browse files Browse the repository at this point in the history
  • Loading branch information
mrexox committed May 23, 2023
1 parent 0103268 commit 082f28b
Show file tree
Hide file tree
Showing 4 changed files with 48 additions and 4 deletions.
40 changes: 38 additions & 2 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,40 @@ 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:
Expand All @@ -53,9 +87,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
8 changes: 8 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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=. ./...

Expand Down
2 changes: 1 addition & 1 deletion internal/config/command.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"`
Expand Down
2 changes: 1 addition & 1 deletion internal/config/script.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"`
Expand Down

0 comments on commit 082f28b

Please sign in to comment.