ci: setup unit tests, linting

This commit is contained in:
Julian Tölle 2024-08-03 03:04:49 +02:00
parent e0b1e2221d
commit 4dfc8e9654
3 changed files with 63 additions and 3 deletions

60
.github/workflows/ci.yaml vendored Normal file
View file

@ -0,0 +1,60 @@
name: ci
on:
push:
branches: [main]
pull_request:
jobs:
lint:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version-file: go.mod
- name: Run golangci-lint
uses: golangci/golangci-lint-action@v6
with:
version: v1.59.1 # renovate: datasource=github-releases depName=golangci/golangci-lint
args: --timeout 5m
test:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version-file: go.mod
- name: Run tests
run: go test -v -race -coverpkg=./... ./...
go-mod-tidy:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version-file: go.mod
- name: Run go mod tidy
run: go mod tidy
- name: Check uncommitted changes
run: git diff --exit-code
- if: failure()
run: echo "::error::Check failed, please run 'go mod tidy' and commit the changes."

View file

@ -200,6 +200,9 @@ func reconcileReleasePR(ctx context.Context, forge rp.Forge, changesets []rp.Cha
}
localCommit, err := repo.CommitObject(releaseCommitHash)
if err != nil {
return err
}
diff, err := localCommit.PatchContext(ctx, remoteCommit)
if err != nil {

View file

@ -8,9 +8,6 @@ import (
)
func TestAnalyzeCommits(t *testing.T) {
type args struct {
commits []Commit
}
tests := []struct {
name string
commits []Commit