Skip to content

Commit

Permalink
Add automation via GH actions (#1)
Browse files Browse the repository at this point in the history
  • Loading branch information
EricHripko authored Feb 20, 2021
1 parent c13ce5d commit ad4b940
Show file tree
Hide file tree
Showing 7 changed files with 65 additions and 5 deletions.
26 changes: 26 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: Release

on:
push:
branches:
- $default-branch

jobs:
release:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2

- name: Login to DockerHub
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}

- name: Build and push
uses: docker/build-push-action@v2
with:
push: true
tags: erichripko/pack.yaml
context: .
file: pack.yaml
28 changes: 28 additions & 0 deletions .github/workflows/verify.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
name: Verify

on: push

jobs:
verify:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2

- name: Set up Go
uses: actions/setup-go@v2
with:
go-version: 1.15

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

- name: Lint
uses: golangci/golangci-lint-action@v2
with:
version: v1.37

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

- name: Upload coverage report
uses: codecov/codecov-action@v1
3 changes: 3 additions & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
run:
# Exclude tests
tests: false
5 changes: 3 additions & 2 deletions internal/app/packer-frontend/build.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ import (

const (
keyMultiPlatform = "multi-platform"
keyContextSubDir = "contextsubdir"
)

// Build the image with this frontend.
Expand All @@ -29,6 +28,7 @@ func Build(ctx context.Context, c client.Client) (*client.Result, error) {

// BuildWithService uses the provided container image build service to
// perform the build.
//nolint:gocyclo // Frontends are complex
func BuildWithService(ctx context.Context, c client.Client, svc cib.Service) (*client.Result, error) {
opts := svc.GetOpts()

Expand Down Expand Up @@ -105,7 +105,8 @@ func BuildWithService(ctx context.Context, c client.Client, svc cib.Service) (*c
img.Config.Cmd = metadata.Command
} else {
// Find command
cmd, err := cib.FindCommand(ctx, ref)
var cmd string
cmd, err = cib.FindCommand(ctx, ref)
if err != nil {
return err
}
Expand Down
2 changes: 1 addition & 1 deletion pack.yaml
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
# syntax = pack.yaml
# syntax = erichripko/pack.yaml
entrypoint: ["packer-frontend"]
4 changes: 3 additions & 1 deletion pkg/cib/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,9 @@ func (s *service) SrcState() (state llb.State, err error) {
if s.src == nil {
err = s.initSrc()
}
state, err = s.src.ToState()
if err == nil {
state, err = s.src.ToState()
}
return
}

Expand Down
2 changes: 1 addition & 1 deletion pkg/plugins/golang/golang.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import (
)

// Regular expression for detecting a Go project.
var fileRegex = regexp.MustCompile("(?:.*\\.go)|(?:go\\.mod)|(?:go\\.sum)")
var fileRegex = regexp.MustCompile(`(?:.*\.go)|(?:go\.mod)|(?:go\.sum)`)

// Errors returned by the plugin.
var (
Expand Down

0 comments on commit ad4b940

Please sign in to comment.