Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Relax Procfile processes definition regex #130

Merged
merged 1 commit into from
Apr 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/workflows/acceptance.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,5 +29,5 @@ jobs:
- uses: actions/checkout@v3
- uses: golangci/[email protected]
with:
version: v1.50
version: v1.57

11 changes: 6 additions & 5 deletions buildpack/buildpack.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
5 changes: 2 additions & 3 deletions cmd/slugcmplr/compile.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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 == "" {
Expand Down
8 changes: 4 additions & 4 deletions cmd/slugcmplr/main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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{}
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion cmd/slugcmplr/release.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion cmd/slugcmplr/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion processfile/procfile.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (
// Procfile contains the definition of a Procfile.
type Procfile map[string]string

var regex = regexp.MustCompile(`^(?P<process>[a-zA-Z0-9]+): (?P<command>.*)$`)
var regex = regexp.MustCompile(`^(?P<process>[a-zA-Z0-9_-]+): (?P<command>.*)$`)

// New creates a new Procfile in-memory.
func New() Procfile {
Expand Down
12 changes: 7 additions & 5 deletions processfile/procfile_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
Loading