-
Notifications
You must be signed in to change notification settings - Fork 60
ci(executable): verify the packaged binary per PR and make the release verify actually fail #2307
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
Merged
+119
−25
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
5e75da6
ci(executable): gate executable build+verify per PR and make verify a…
rishigupta1599 e9ae637
ci(executable): drop pkg --debug flag to silence per-file packaging logs
rishigupta1599 e32e1aa
Potential fix for pull request finding 'CodeQL / Workflow does not co…
rishigupta1599 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,36 @@ | ||
| name: Verify Executable | ||
|
|
||
| # Per-PR gate: build the packaged executables exactly as the release pipeline | ||
| # does and smoke-test them — but without signing, notarizing or uploading. This | ||
| # catches binary-only breakages (e.g. a bad require produced by the CJS | ||
| # transpile that never shows up in the Node/source test suite) on the PR that | ||
| # introduces them, so they can't reach a release. | ||
| # | ||
| # No secrets are used or needed: scripts/executable.sh skips the macOS | ||
| # signing/notarization block when APPLE_DEV_CERT is unset, which also makes this | ||
| # safe to run on pull requests from forks. | ||
| on: | ||
| pull_request: | ||
| branches: [master] | ||
|
|
||
| permissions: | ||
| contents: read | ||
|
|
||
| concurrency: | ||
| group: verify-executable-${{ github.workflow }}-${{ github.ref }} | ||
| cancel-in-progress: true | ||
|
|
||
| jobs: | ||
| verify: | ||
| name: Build & verify executable | ||
| runs-on: macos-latest | ||
| steps: | ||
| - uses: actions/checkout@v5 | ||
| - uses: actions/setup-node@v4 | ||
| with: | ||
| node-version: 14 | ||
| architecture: x64 | ||
| - name: Build executables (no signing, no upload) | ||
| run: ./scripts/executable.sh | ||
| - name: Verify executable | ||
| run: ./scripts/verify-executable.sh ./percy | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,45 @@ | ||
| #!/bin/bash | ||
| # Smoke-test a packaged percy executable. | ||
| # | ||
| # Why this isn't just `./percy --version`: the executables are built on Node 14, | ||
| # where an unhandled promise rejection is reported as a *warning* and the process | ||
| # still exits 0. So a binary that throws on startup (e.g. a bad require produced | ||
| # by the CJS transpile) prints a stack trace yet a bare `--version` exit-code | ||
| # check passes — and the release pipeline happily uploads a broken binary. | ||
| # | ||
| # This script treats the binary as broken if `--version` either exits non-zero, | ||
| # fails to print a real version, or emits any runtime-error marker on stdout/stderr. | ||
| # | ||
| # Usage: scripts/verify-executable.sh [path-to-binary] (default: ./percy) | ||
| set -u -o pipefail | ||
|
|
||
| BIN="${1:-./percy}" | ||
| echo "Verifying: $BIN --version" | ||
|
|
||
| # Capture stdout+stderr together; keep the exit code without tripping set -e. | ||
| output="$("$BIN" --version 2>&1)" | ||
| status=$? | ||
|
|
||
| echo "----- output -----" | ||
| echo "$output" | ||
| echo "------------------" | ||
|
|
||
| if [ "$status" -ne 0 ]; then | ||
| echo "::error::'$BIN --version' exited with status $status" | ||
| exit 1 | ||
| fi | ||
|
|
||
| # Node 14 turns startup crashes into non-fatal warnings, so scan the output for | ||
| # the error signatures a broken binary leaves behind. | ||
| if echo "$output" | grep -qiE 'UnhandledPromiseRejection|is not a function|TypeError|ReferenceError|SyntaxError|Cannot find module|Error:'; then | ||
| echo "::error::'$BIN --version' emitted a runtime error (binary is broken)" | ||
| exit 1 | ||
| fi | ||
|
|
||
| # A healthy binary prints its semver. If it crashed before printing one, fail. | ||
| if ! echo "$output" | grep -qE '[0-9]+\.[0-9]+\.[0-9]+'; then | ||
| echo "::error::'$BIN --version' did not print a valid version string" | ||
| exit 1 | ||
| fi | ||
|
|
||
| echo "OK: $BIN is healthy" |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.