Skip to content

Commit

Permalink
Add CI pipeline (#1)
Browse files Browse the repository at this point in the history
* Add CI pipeline

* Fix revive issue
  • Loading branch information
atkrad authored Aug 11, 2023
1 parent 0704002 commit e5a3319
Show file tree
Hide file tree
Showing 3 changed files with 86 additions and 0 deletions.
57 changes: 57 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
name: GoURN CI

on:
push:
branches:
- 'main'
tags:
- 'v*'
pull_request:
branches:
- '*'

jobs:
check:
name: Check
runs-on: ubuntu-latest
steps:
- name: Set up Go 1.20.x
uses: actions/setup-go@v4
with:
go-version: 1.20.x
cache-dependency-path: go.sum

- name: Checkout Code
uses: actions/checkout@v3

- name: go-fmt
run: |
if [ -n "$(gofmt -s -l .)" ]; then
echo "Go code is not formatted, run 'gofmt -s -w .'"
exit 1
fi
- name: go-vet
run: go vet ./...

- name: revive
run: |
go install github.com/mgechev/[email protected]
revive -config .revive.toml -formatter friendly ./...
test:
name: Test
needs: check
runs-on: ubuntu-latest
steps:
- name: Checkout Code
uses: actions/checkout@v3

- name: Set up Go 1.20.x
uses: actions/setup-go@v4
with:
go-version: 1.20.x
cache-dependency-path: go.sum

- name: Test GoURN
run: go test -v -covermode=count -coverprofile=coverage.out ./...
28 changes: 28 additions & 0 deletions .revive.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
ignoreGeneratedHeader = false
severity = "warning"
confidence = 0.8
errorCode = 1
warningCode = 1

[rule.blank-imports]
[rule.context-as-argument]
[rule.context-keys-type]
[rule.dot-imports]
[rule.empty-block]
[rule.error-naming]
[rule.error-return]
[rule.error-strings]
[rule.errorf]
[rule.exported]
[rule.increment-decrement]
[rule.indent-error-flow]
[rule.range]
[rule.receiver-naming]
[rule.redefines-builtin-id]
[rule.superfluous-else]
[rule.time-naming]
[rule.unexported-return]
[rule.unreachable-code]
[rule.unused-parameter]
[rule.var-declaration]
[rule.var-naming]
1 change: 1 addition & 0 deletions urn.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
)

var (
// ErrInvalidURN represents an error for invalid URN
ErrInvalidURN = errors.New("invalid URN")
genericPattern = regexp.MustCompile(`^(?i)urn:(?P<nid>[a-z0-9][a-z0-9-]{0,31}):(?P<nss>(?:[-a-z0-9()+,.:=@;$_!*'&~/]|%[0-9a-fA-F]{2})+)$`)
)
Expand Down

0 comments on commit e5a3319

Please sign in to comment.