Skip to content

Commit

Permalink
FIx recursive behavior so that it pushes all dockerfiles with process…
Browse files Browse the repository at this point in the history
… types not provided (#2958)
  • Loading branch information
eablack authored Jul 30, 2024
1 parent 7ff333a commit 7363461
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 1 deletion.
2 changes: 2 additions & 0 deletions packages/cli/src/commands/container/push.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ async function selectJobs(jobs: DockerHelper.groupedDockerJobs, processTypes: st
if (recursive) {
if (processTypes.length > 0) {
filteredJobs = DockerHelper.filterByProcessType(jobs, processTypes)
} else {
filteredJobs = jobs
}

selectedJobs = await DockerHelper.chooseJobs(filteredJobs)
Expand Down
27 changes: 26 additions & 1 deletion packages/cli/test/unit/commands/container/push.unit.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ describe('container push', function () {
sandbox.assert.calledOnce(push)
})

it('pushes several dockerfiles recursively', async function () {
it('pushes specified dockerfiles recursively', async function () {
const dockerfiles = sandbox.stub(DockerHelper, 'getDockerfiles')
.returns(['/path/to/Dockerfile.web', '/path/to/Dockerfile.worker'])
const build = sandbox.stub(DockerHelper, 'buildImage')
Expand All @@ -198,6 +198,31 @@ describe('container push', function () {
sandbox.assert.calledTwice(push)
})

it('pushes all dockerfiles recursively when process types are not specified', async function () {
const dockerfiles = sandbox.stub(DockerHelper, 'getDockerfiles')
.returns(['/path/to/Dockerfile.web', '/path/to/Dockerfile.worker'])
const build = sandbox.stub(DockerHelper, 'buildImage')
build.withArgs('/path/to/Dockerfile.web', 'registry.heroku.com/testapp/web', [])
build.withArgs('/path/to/Dockerfile.worker', 'registry.heroku.com/testapp/worker', [])
const push = sandbox.stub(DockerHelper, 'pushImage')
push.withArgs('registry.heroku.com/testapp/web')
push.withArgs('registry.heroku.com/testapp/worker')

await runCommand(Cmd, [
'--app',
'testapp',
'--recursive',
])

expect(stdout.output).to.contain('Building web (/path/to/Dockerfile.web)')
expect(stdout.output).to.contain('Building worker (/path/to/Dockerfile.worker)')
expect(stdout.output).to.contain('Pushing web (/path/to/Dockerfile.web)')
expect(stdout.output).to.contain('Pushing worker (/path/to/Dockerfile.worker)')
sandbox.assert.calledOnce(dockerfiles)
sandbox.assert.calledTwice(build)
sandbox.assert.calledTwice(push)
})

it('builds with custom context path and pushes to the docker registry', async function () {
const dockerfiles = sandbox.stub(DockerHelper, 'getDockerfiles')
.returns(['/path/to/Dockerfile'])
Expand Down

0 comments on commit 7363461

Please sign in to comment.