Skip to content

Commit

Permalink
Merge pull request #31 from adrg/update-github-actions
Browse files Browse the repository at this point in the history
Update GitHub Actions workflows
  • Loading branch information
adrg authored Mar 19, 2024
2 parents c992fc7 + a9937b0 commit c287b57
Show file tree
Hide file tree
Showing 8 changed files with 108 additions and 87 deletions.
31 changes: 31 additions & 0 deletions .github/workflows/analyze.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
name: Analyze

on:
push:
branches: [master]
pull_request:
branches: [master]
schedule:
- cron: "0 6 * * 1"

permissions:
actions: read
contents: read
security-events: write

jobs:
analyze:
runs-on: ubuntu-latest

steps:
- name: Checkout
uses: actions/checkout@v4

- name: Initialize CodeQL
uses: github/codeql-action/init@v3
with:
languages: go
queries: security-and-quality

- name: Run CodeQL analysis
uses: github/codeql-action/analyze@v3
39 changes: 0 additions & 39 deletions .github/workflows/ci.yml

This file was deleted.

38 changes: 0 additions & 38 deletions .github/workflows/codeql-analysis.yml

This file was deleted.

34 changes: 34 additions & 0 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
name: Lint

on:
push:
branches: [master]
pull_request:

permissions:
contents: read

jobs:
lint:
strategy:
matrix:
go: ['1.21']
os: [ubuntu-latest]
runs-on: ${{ matrix.os }}
steps:
- name: Setup
uses: actions/setup-go@v5
with:
go-version: ${{ matrix.go }}

- name: Prepare checkout
run: git config --global core.autocrlf false

- name: Checkout
uses: actions/checkout@v4

- name: Lint
uses: golangci/[email protected]
with:
version: "v1.54"
args: --timeout=5m
34 changes: 34 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
name: Test

on:
push:
branches: [master]
pull_request:

permissions:
contents: read

jobs:
test:
strategy:
matrix:
go: ['1.21']
os: [ubuntu-latest]
runs-on: ${{ matrix.os }}
steps:
- name: Setup
uses: actions/setup-go@v5
with:
go-version: ${{ matrix.go }}

- name: Prepare checkout
run: git config --global core.autocrlf false

- name: Checkout
uses: actions/checkout@v4

- name: Test
run: go test -v -coverprofile coverage.txt -covermode atomic ./...

- name: Coverage
uses: codecov/codecov-action@v3
8 changes: 7 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
module github.com/adrg/strutil

go 1.14
go 1.19

require github.com/stretchr/testify v1.8.4

require (
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
)
7 changes: 0 additions & 7 deletions go.sum
Original file line number Diff line number Diff line change
@@ -1,17 +1,10 @@
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw=
github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo=
github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU=
github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk=
github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
4 changes: 2 additions & 2 deletions internal/ngram/ngram.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ func Map(runes []rune, size int) (map[string]int, int) {
var ngramCount int
for i := 0; i < limit; i++ {
ngram := string(runes[i : i+size])
count, _ := ngrams[ngram]
count := ngrams[ngram]
ngrams[ngram] = count + 1
ngramCount++
}
Expand Down Expand Up @@ -94,7 +94,7 @@ func Intersection(a, b []rune, size int) (map[string]int, int, int, int) {

// Update common n-grams map with the matched n-gram and its
// frequency.
count, _ = commonNgrams[ngram]
count = commonNgrams[ngram]
commonNgrams[ngram] = count + 1
}
}
Expand Down

0 comments on commit c287b57

Please sign in to comment.