diff --git a/.github/workflows/acceptance.yml b/.github/workflows/acceptance.yml index 7fbabc4c..3687b2d1 100644 --- a/.github/workflows/acceptance.yml +++ b/.github/workflows/acceptance.yml @@ -14,6 +14,7 @@ jobs: test: if: ${{ github.event_name == 'push' || github.event.label.name == 'run-acceptance-tests' || github.event_name == 'schedule' || github.event_name == 'workflow_dispatch' }} name: Acceptance + container: heroku/heroku:20-build runs-on: ubuntu-latest env: SLUGCMPLR_ACC: "true" diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 4cd8441b..38da3480 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -29,5 +29,5 @@ jobs: - uses: actions/checkout@v3 - uses: golangci/golangci-lint-action@v3.4.0 with: - version: v1.50 + version: v1.57 diff --git a/buildpack/buildpack.go b/buildpack/buildpack.go index 0a3ecea3..146d66a3 100644 --- a/buildpack/buildpack.go +++ b/buildpack/buildpack.go @@ -119,11 +119,12 @@ func (b *Buildpack) Compile(ctx context.Context, exports []*Buildpack, build *Bu func (b *Buildpack) Export(_ context.Context, build *Build) (string, bool, error) { export := filepath.Join(build.BuildDir, BuildpacksDir, b.Directory, "export") - if _, err := os.Stat(export); err == nil { - return export, true, nil - } else if os.IsNotExist(err) { - return "", false, nil - } else { + if _, err := os.Stat(export); err != nil { + if os.IsNotExist(err) { + return "", false, nil + } return "", false, err } + + return export, true, nil } diff --git a/cmd/slugcmplr/compile.go b/cmd/slugcmplr/compile.go index fcb8b990..7751e9a1 100644 --- a/cmd/slugcmplr/compile.go +++ b/cmd/slugcmplr/compile.go @@ -68,8 +68,7 @@ func compile(ctx context.Context, out outputter, h *heroku.Service, c *Compile, return fmt.Errorf("error encoding metadata: %w", err) } - // #nosec G306 - if err := os.WriteFile( + if err := os.WriteFile( // #nosec G306 filepath.Join(buildDir, "release.json"), b.Bytes(), 0644, @@ -87,7 +86,7 @@ func compileCmd(verbose bool) *cobra.Command { Use: "compile", Short: "compile the target applications", Args: cobra.NoArgs, - RunE: func(cmd *cobra.Command, args []string) error { + RunE: func(cmd *cobra.Command, _ []string) error { output := outputterFromCmd(cmd, verbose) if cacheDir == "" { diff --git a/cmd/slugcmplr/main_test.go b/cmd/slugcmplr/main_test.go index 863cdfdd..d9235e97 100644 --- a/cmd/slugcmplr/main_test.go +++ b/cmd/slugcmplr/main_test.go @@ -38,7 +38,7 @@ func testPrepare(t *testing.T) { t.Parallel() withHarness(t, "CGA1123/slugcmplr-fixture-binary", - func(t *testing.T, appName, repoDir string, h *heroku.Service) { + func(t *testing.T, appName, _ string, _ *heroku.Service) { buildDir, err := os.MkdirTemp("", "CGA1123__slugmplr-fixture-binary_build_") if err != nil { t.Fatalf("failed to create build directory: %v", err) @@ -136,7 +136,7 @@ func testDetectFail(t *testing.T) { configVars := map[string]string{"FOO": "BAR", "BAR": "FOO"} - withStubPrepare(t, "CGA1123/slugcmplr-fixture-binary", buildpacks, configVars, func(t *testing.T, app, buildDir string) { + withStubPrepare(t, "CGA1123/slugcmplr-fixture-binary", buildpacks, configVars, func(t *testing.T, _, buildDir string) { var compileErr error // Compile logBuilder := &strings.Builder{} @@ -177,7 +177,7 @@ func testSlugIgnore(t *testing.T) { configVars := map[string]string{"FOO": "BAR", "BAR": "FOO"} - withStubPrepare(t, "CGA1123/slugcmplr-fixture-slugignore", buildpacks, configVars, func(t *testing.T, app, buildDir string) { + withStubPrepare(t, "CGA1123/slugcmplr-fixture-slugignore", buildpacks, configVars, func(t *testing.T, _, buildDir string) { foundPaths := []string{} expectedPaths := []string{ "/README.md", @@ -237,7 +237,7 @@ func testRails(t *testing.T) { func endToEndSmoke(t *testing.T, fixture string) { t.Helper() - withHarness(t, fixture, func(t *testing.T, app, src string, h *heroku.Service) { + withHarness(t, fixture, func(t *testing.T, app, src string, _ *heroku.Service) { pattn := strings.ReplaceAll(fixture, "/", "__") + "_" buildDir, err := os.MkdirTemp("", pattn) if err != nil { diff --git a/cmd/slugcmplr/release.go b/cmd/slugcmplr/release.go index 2fda30bc..84a8949d 100644 --- a/cmd/slugcmplr/release.go +++ b/cmd/slugcmplr/release.go @@ -23,7 +23,7 @@ func releaseCmd(verbose bool) *cobra.Command { Use: "release", Short: "release a slug", Args: cobra.NoArgs, - RunE: func(cmd *cobra.Command, args []string) error { + RunE: func(cmd *cobra.Command, _ []string) error { ctx := cmd.Context() out := outputterFromCmd(cmd, verbose) h, err := netrcClient(out) diff --git a/cmd/slugcmplr/version.go b/cmd/slugcmplr/version.go index 3afdcea6..80f67d78 100644 --- a/cmd/slugcmplr/version.go +++ b/cmd/slugcmplr/version.go @@ -11,7 +11,7 @@ func versionCmd(verbose bool) *cobra.Command { Use: "version", Short: "version information", Args: cobra.NoArgs, - RunE: func(cmd *cobra.Command, args []string) error { + RunE: func(cmd *cobra.Command, _ []string) error { out := outputterFromCmd(cmd, verbose).OutOrStdout() fmt.Fprintf(out, "Build Version: %v\n", version) diff --git a/processfile/procfile.go b/processfile/procfile.go index 5a6ceb1f..2d62977a 100644 --- a/processfile/procfile.go +++ b/processfile/procfile.go @@ -10,7 +10,7 @@ import ( // Procfile contains the definition of a Procfile. type Procfile map[string]string -var regex = regexp.MustCompile(`^(?P[a-zA-Z0-9]+): (?P.*)$`) +var regex = regexp.MustCompile(`^(?P[a-zA-Z0-9_-]+): (?P.*)$`) // New creates a new Procfile in-memory. func New() Procfile { diff --git a/processfile/procfile_test.go b/processfile/procfile_test.go index bd6ed462..7cefa94f 100644 --- a/processfile/procfile_test.go +++ b/processfile/procfile_test.go @@ -86,19 +86,21 @@ func Test_Read(t *testing.T) { valid := `web: bin/server worker: bundle exec sidekiq -c config/sidekiq.yml -cron: bin/scheduler` +cron: bin/scheduler +my_process: echo "hello"` procf, err := processfile.Read(strings.NewReader(valid)) if err != nil { t.Fatalf("unexpected error when reading procfile: %v", err) } - Contain(t, []string{"web", "worker", "cron"}, procf.Processes()) + Contain(t, []string{"web", "worker", "cron", "my_process"}, procf.Processes()) expected := map[string]string{ - "web": "bin/server", - "worker": "bundle exec sidekiq -c config/sidekiq.yml", - "cron": "bin/scheduler", + "web": "bin/server", + "worker": "bundle exec sidekiq -c config/sidekiq.yml", + "cron": "bin/scheduler", + "my_process": `echo "hello"`, } for proc, cmd := range expected {