diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..b414b5f --- /dev/null +++ b/.github/workflows/release.yml @@ -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 diff --git a/.github/workflows/verify.yml b/.github/workflows/verify.yml new file mode 100644 index 0000000..561698e --- /dev/null +++ b/.github/workflows/verify.yml @@ -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 diff --git a/.golangci.yml b/.golangci.yml new file mode 100644 index 0000000..a3072cd --- /dev/null +++ b/.golangci.yml @@ -0,0 +1,3 @@ +run: + # Exclude tests + tests: false diff --git a/internal/app/packer-frontend/build.go b/internal/app/packer-frontend/build.go index 4b904d7..04fffc6 100644 --- a/internal/app/packer-frontend/build.go +++ b/internal/app/packer-frontend/build.go @@ -19,7 +19,6 @@ import ( const ( keyMultiPlatform = "multi-platform" - keyContextSubDir = "contextsubdir" ) // Build the image with this frontend. @@ -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() @@ -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 } diff --git a/pack.yaml b/pack.yaml index 74af7ac..3e457c7 100644 --- a/pack.yaml +++ b/pack.yaml @@ -1,2 +1,2 @@ -# syntax = pack.yaml +# syntax = erichripko/pack.yaml entrypoint: ["packer-frontend"] diff --git a/pkg/cib/service.go b/pkg/cib/service.go index c6ba397..d3806c0 100644 --- a/pkg/cib/service.go +++ b/pkg/cib/service.go @@ -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 } diff --git a/pkg/plugins/golang/golang.go b/pkg/plugins/golang/golang.go index 28d1038..4d3857f 100644 --- a/pkg/plugins/golang/golang.go +++ b/pkg/plugins/golang/golang.go @@ -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 (