Skip to content

Commit

Permalink
Configure github actions (#2)
Browse files Browse the repository at this point in the history
* Setup github actions

* Fix lint errors
  • Loading branch information
Paul Boyd authored Jul 29, 2023
1 parent 19253b5 commit 31fe9a3
Show file tree
Hide file tree
Showing 5 changed files with 95 additions and 4 deletions.
25 changes: 25 additions & 0 deletions .github/workflows/go.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
name: Go

on:
push:
branches: [ "master" ]
pull_request:
branches: [ "master" ]

jobs:

build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3

- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: '1.20'

- name: Build
run: go build -v ./...

- name: Test
run: go test -v ./...
55 changes: 55 additions & 0 deletions .github/workflows/golangci-lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
name: golangci-lint
on:
push:
branches:
- master
- main
pull_request:

permissions:
contents: read
# Optional: allow read access to pull request. Use with `only-new-issues` option.
# pull-requests: read

jobs:
golangci:
name: lint
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-go@v4
with:
go-version: '1.20'
cache: false
- name: golangci-lint
uses: golangci/golangci-lint-action@v3
with:
# Require: The version of golangci-lint to use.
# When `install-mode` is `binary` (default) the value can be v1.2 or v1.2.3 or `latest` to use the latest version.
# When `install-mode` is `goinstall` the value can be v1.2.3, `latest`, or the hash of a commit.
version: v1.53

# Optional: working directory, useful for monorepos
# working-directory: somedir

# Optional: golangci-lint command line arguments.
#
# Note: By default, the `.golangci.yml` file should be at the root of the repository.
# The location of the configuration file can be changed by using `--config=`
# args: --timeout=30m --config=/my/path/.golangci.yml --issues-exit-code=0

# Optional: show only new issues if it's a pull request. The default value is `false`.
# only-new-issues: true

# Optional: if set to true, then all caching functionality will be completely disabled,
# takes precedence over all other caching options.
# skip-cache: true

# Optional: if set to true, then the action won't cache or restore ~/go/pkg.
# skip-pkg-cache: true

# Optional: if set to true, then the action won't cache or restore ~/.cache/go-build.
# skip-build-cache: true

# Optional: The mode to install golangci-lint. It can be 'binary' or 'goinstall'.
# install-mode: "goinstall"
11 changes: 9 additions & 2 deletions benchmark_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,11 @@ func BenchmarkIndexLarge(b *testing.B) {
cfg := Config{
Workers: runtime.GOMAXPROCS(0),
}
NewIndex(cfg).AddPath(context.Background(), tmp)

err := NewIndex(cfg).AddPath(context.Background(), tmp)
if err != nil {
b.Fatal(err)
}
}

func BenchmarkIndexTiny(b *testing.B) {
Expand All @@ -30,7 +34,10 @@ func BenchmarkIndexTiny(b *testing.B) {
cfg := Config{
Workers: runtime.GOMAXPROCS(0),
}
NewIndex(cfg).AddPath(context.Background(), tmp)
err := NewIndex(cfg).AddPath(context.Background(), tmp)
if err != nil {
b.Fatal(err)
}
}

// makeTestImages creates b.N test images in a temporary directory.
Expand Down
6 changes: 5 additions & 1 deletion index.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,11 @@ func (idx *Index) insert(color uint32, path string) {

idx.trainingData = append(idx.trainingData, colorVector(color))
idx.expected = append(idx.expected, float64(color))
idx.model.UpdateTrainingSet(idx.trainingData, idx.expected)
err := idx.model.UpdateTrainingSet(idx.trainingData, idx.expected)
if err != nil {
// FIXME: really need to handle this better.
log.Printf("error updating training set: %v", err)
}
}

func (idx *Index) findImages(ctx context.Context, path string) <-chan string {
Expand Down
2 changes: 1 addition & 1 deletion mosaic.go
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ func matchAndSwapTiles(output draw.Image, tiles <-chan image.Image, tileImages *

replacement = imaging.Fill(replacement, config.TileWidth, config.TileHeight, imaging.Center, imaging.Lanczos)
if config.Blend {
draw.Draw(output, tile.Bounds(), replacement, image.ZP, draw.Over)
draw.Draw(output, tile.Bounds(), replacement, image.Point{}, draw.Over)
} else {
draw.Copy(output, tile.Bounds().Min, replacement, replacement.Bounds(), draw.Src, nil)
}
Expand Down

0 comments on commit 31fe9a3

Please sign in to comment.