Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 13 additions & 15 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
@@ -1,28 +1,26 @@
name: lint
name: Lint

on:
push:
branches:
- main
pull_request:
env:
GOPRIVATE: "github.com/speakeasy-api"

permissions:
contents: read

jobs:
golangci:
name: lint
golangci-lint:
name: golangci-lint
runs-on: ubuntu-latest
steps:
- uses: actions/setup-go@v3
with:
go-version: 1.21
- uses: actions/checkout@v4

- name: Configure git for private modules
env:
GIT_AUTH_TOKEN: ${{ secrets.BOT_REPO_TOKEN }}
run: git config --global url."https://speakeasybot:${GITHUB_TOKEN}@github.com".insteadOf "https://github.com"
- uses: actions/setup-go@v5
with:
go-version-file: go.mod

- uses: actions/checkout@v3
- name: golangci-lint
uses: golangci/golangci-lint-action@v3
uses: golangci/golangci-lint-action@v7
with:
version: v1.57.2
version: v2.1.6
29 changes: 11 additions & 18 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,27 +5,20 @@ on:
branches:
- main
pull_request:
env:
GOPRIVATE: "github.com/speakeasy-api"
jobs:
tests:
runs-on: ubuntu-latest

strategy:
fail-fast: true
matrix:
go-version: [1.21.x]

name: Tests - Go ${{ matrix.go-version }}
permissions:
contents: read

jobs:
test:
runs-on: ubuntu-latest
name: Tests
steps:
- name: Checkout the code
uses: actions/checkout@v2
- uses: actions/checkout@v4

- name: Install Go
uses: actions/setup-go@v2
- uses: actions/setup-go@v5
with:
go-version: ${{ matrix.go-version }}
go-version-file: go.mod

- name: Run the tests
run: go test ./...
- name: Run tests
run: go test -race -count=1 ./...
96 changes: 90 additions & 6 deletions .golangci.yaml
Original file line number Diff line number Diff line change
@@ -1,8 +1,92 @@
version: "2"

run:
go: "1.19"
linters-settings:
tagliatelle:
case:
use-field-name: true
go: "1.21"
timeout: 5m

formatters:
enable:
- gofumpt

settings:
gofumpt:
extra-rules: true

linters:
enable:
# Bugs / correctness
- govet
- staticcheck
- errcheck
- ineffassign
- bodyclose
- nilerr
- copyloopvar

# Style / simplicity
- revive
- misspell
- unconvert
- unused
- nolintlint
- gocritic
- dupword
- usestdlibvars

# Complexity
- gocyclo
- cyclop

# Testing
- testifylint

# Tags
- tagliatelle

settings:
gocyclo:
min-complexity: 30

cyclop:
max-complexity: 30

gocritic:
enabled-tags:
- diagnostic
- style
- performance

revive:
rules:
json: snake
- name: blank-imports
- name: context-as-argument
- name: dot-imports
- name: error-naming
- name: error-return
- name: exported
disabled: true
- name: increment-decrement
- name: indent-error-flow
- name: range
- name: receiver-naming
- name: redefines-builtin-id
- name: superfluous-else
- name: unreachable-code
- name: unused-parameter

tagliatelle:
case:
use-field-name: true
rules:
json: snake

nolintlint:
require-explanation: true
require-specific: true

testifylint:
enable-all: true

issues:
max-issues-per-linter: 0
max-same-issues: 0
9 changes: 7 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
.PHONY: *
.PHONY: lint fmt test

lint:
gofumpt -l -w .
golangci-lint run

fmt:
gofumpt -l -w .

test:
go test -race -count=1 ./...
25 changes: 25 additions & 0 deletions api_significance.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package git_diff_parser

type (
ContentChange = contentChange
ContentChangeType = contentChangeType
FileDiff = fileDiff
FileDiffType = fileDiffType
)

const (
ContentChangeTypeAdd = contentChangeTypeAdd
ContentChangeTypeDelete = contentChangeTypeDelete
ContentChangeTypeModify = contentChangeTypeModify
ContentChangeTypeNOOP = contentChangeTypeNOOP

FileDiffTypeAdded = fileDiffTypeAdded
FileDiffTypeDeleted = fileDiffTypeDeleted
FileDiffTypeModified = fileDiffTypeModified
)

func SignificantChange(diff string, isSignificant func(*FileDiff, *ContentChange) (bool, string)) (significant bool, msg string, err error) {
return significantChange(diff, func(fileDiff *fileDiff, change *contentChange) (bool, string) {
return isSignificant(fileDiff, change)
})
}
Loading
Loading