Skip to content

Commit

Permalink
Relax Procfile processes definition regex
Browse files Browse the repository at this point in the history
It's okay from processes to include `-` + `_` characters.
  • Loading branch information
CGA1123 committed Apr 5, 2024
1 parent 8cf076f commit 77aff6b
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 12 deletions.
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
}
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

0 comments on commit 77aff6b

Please sign in to comment.