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

Stop cloudchamber build from trying to push image when build fails #8220

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

IRCody
Copy link
Contributor

@IRCody IRCody commented Feb 21, 2025

Describe your change...
Fixes issue where cloudchamber build --push ... would continue trying to push the image even if the build failed. Adds a check to verify the passed in context dir is actually a directory and also checks the builds error code on exit to stop progressing to pushing if that fails.

The behavior now is:

With a file that doesn't exist:

% wrangler cloudchamber build -t test:1 --push ./noexist
 Error when checking ./noexist: Error: ENOENT: no such file or directory, stat './noexist'   

When given a file and not a directory:

% wrangler cloudchamber build -t test:1 --push ./Dockerfile
PATH must be a directory

When docker build returns a non-zero exit code:

% wrangler cloudchamber build -t test:1 --push ./DockerfileDir
.... <Docker build output including dockers failure message>

Error: Build exited with code: 1

  • Tests
    • TODO (before merge)
    • Tests included
    • Tests not necessary because: Would probably belong in e2e tests which cloudchamber doesn't have yet.
  • Wrangler E2E Tests CI Job required? (Use "e2e" label or ask maintainer to run separately)
    • I don't know
    • Required
    • Not required because: Cloudchamber has no e2e tests
  • Public documentation
    • TODO (before merge)
    • Cloudflare docs PR(s):
    • Documentation not necessary because: Cloudchamber is not documented externally

Copy link

changeset-bot bot commented Feb 21, 2025

🦋 Changeset detected

Latest commit: 059dc67

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 2 packages
Name Type
wrangler Patch
@cloudflare/vitest-pool-workers Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

Copy link
Contributor

github-actions bot commented Feb 21, 2025

A wrangler prerelease is available for testing. You can install this latest build in your project with:

npm install --save-dev https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/13467233733/npm-package-wrangler-8220

You can reference the automatically updated head of this PR with:

npm install --save-dev https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/prs/8220/npm-package-wrangler-8220

Or you can use npx with this latest build directly:

npx https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/13467233733/npm-package-wrangler-8220 dev path/to/script.js
Additional artifacts:

cloudflare-workers-bindings-extension:

wget https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/13467233733/npm-package-cloudflare-workers-bindings-extension-8220 -O ./cloudflare-workers-bindings-extension.0.0.0-vf17949989.vsix && code --install-extension ./cloudflare-workers-bindings-extension.0.0.0-vf17949989.vsix

create-cloudflare:

npx https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/13467233733/npm-package-create-cloudflare-8220 --no-auto-update

@cloudflare/kv-asset-handler:

npm install https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/13467233733/npm-package-cloudflare-kv-asset-handler-8220

miniflare:

npm install https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/13467233733/npm-package-miniflare-8220

@cloudflare/pages-shared:

npm install https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/13467233733/npm-package-cloudflare-pages-shared-8220

@cloudflare/unenv-preset:

npm install https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/13467233733/npm-package-cloudflare-unenv-preset-8220

@cloudflare/vite-plugin:

npm install https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/13467233733/npm-package-cloudflare-vite-plugin-8220

@cloudflare/vitest-pool-workers:

npm install https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/13467233733/npm-package-cloudflare-vitest-pool-workers-8220

@cloudflare/workers-editor-shared:

npm install https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/13467233733/npm-package-cloudflare-workers-editor-shared-8220

@cloudflare/workers-shared:

npm install https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/13467233733/npm-package-cloudflare-workers-shared-8220

@cloudflare/workflows-shared:

npm install https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/13467233733/npm-package-cloudflare-workflows-shared-8220

Note that these links will no longer work once the GitHub Actions artifact expires.


[email protected] includes the following runtime dependencies:

Package Constraint Resolved
miniflare workspace:* 3.20250214.0
workerd 1.20250214.0 1.20250214.0
workerd --version 1.20250214.0 2025-02-14

Please ensure constraints are pinned, and miniflare/workerd minor versions match.

@IRCody IRCody force-pushed the cloudchamber-docker-build-fix branch from ce0245b to d5e3fc7 Compare February 21, 2025 23:46
@IRCody IRCody force-pushed the cloudchamber-docker-build-fix branch from d5e3fc7 to 059dc67 Compare February 21, 2025 23:53
@IRCody IRCody marked this pull request as ready for review February 22, 2025 00:15
@IRCody IRCody requested review from a team as code owners February 22, 2025 00:15
logRaw(`Error when checking ${args.PATH}: ${error}`);
return;
}

try {
await constructBuildCommand({
imageTag: args.tag,
pathToDockerfile: args.PATH,
pathToDocker: args.pathToDocker,
})
Copy link
Contributor

@gabivlj gabivlj Feb 22, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit, no need for async keyword: maybe .then(bc => dockerBuild({ buildCmd: bc })?

);
await new Promise((resolve) => {
child.on("close", resolve);
export async function dockerBuild(options: {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: I think we shouldnt mark the function async as we are already returning a promise and we dont call await

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Untriaged
Development

Successfully merging this pull request may close these issues.

2 participants