Repository navigation
Add --format json to CLI commands #388
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
Open
dhruv8sh
wants to merge
17
commits into
main
Choose a base branch
from
spec/383-cli-format-json
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
09c7bf5
Add machine-readable CLI output spec
dhruv8sh c74d707
Add --format json to CLI commands
dhruv8sh ee94a6a
Merge branch 'main' into spec/383-cli-format-json
aram356 12ed8fc
Update --format json spec for the PR #388 review
dhruv8sh 9b8c710
Add plan recording the PR #388 review fixes
dhruv8sh cc6f1ac
Fix --format json results from the PR #388 review
dhruv8sh 082168c
Merge branch 'main' into spec/383-cli-format-json
prk-Jr e6a0b12
Address the second PR #388 review
dhruv8sh 392546a
Merge main into spec/383-cli-format-json
dhruv8sh daa1028
Merge branch 'main' into spec/383-cli-format-json
prk-Jr a8af11d
Merge branch 'main' into spec/383-cli-format-json
aram356 be91017
Address the third and fourth PR #388 reviews
dhruv8sh 8e0075a
Merge branch 'main' into spec/383-cli-format-json
prk-Jr a90da4e
fix: isolate request-fidelity runner from root clippy rules
dhruv8sh ac9493d
Merge branch 'main' into spec/383-cli-format-json
aram356 bfc6335
fix: address fifth review of --format json
dhruv8sh b1cde39
fix: point the JSON deploy smoke at the release manifest
dhruv8sh 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
47 changes: 47 additions & 0 deletions
47
.github/actions/deploy-fastly/tests/assert-json-deploy-version.sh
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,47 @@ | ||
| #!/usr/bin/env bash | ||
| set -euo pipefail | ||
|
|
||
| # Runs the fixture release's CLI with `deploy --format json` against the | ||
| # stateful fake Fastly provider, and asserts that a deploy failing after it | ||
| # cloned version 42 still reports that version and its state. | ||
| # | ||
| # Args: the expected `version_state` (`draft` or `unknown`). | ||
| # Reads (env): | ||
| # GITHUB_WORKSPACE, RUNNER_TEMP, FAKE_CALL_LOG (from make-fake-fastly-env.sh) | ||
| # Writes: none | ||
|
|
||
| SCRIPT_DIR=$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" && pwd) | ||
| # shellcheck source=../../fastly-common/scripts/common.sh | ||
| source "$SCRIPT_DIR/../../fastly-common/scripts/common.sh" | ||
|
|
||
| main() { | ||
| local expected_state="${1:?expected version_state is required}" | ||
| local workspace="${GITHUB_WORKSPACE:?GITHUB_WORKSPACE is required}" | ||
| local runner_temp="${RUNNER_TEMP:?RUNNER_TEMP is required}" | ||
| local root bin cli fastly_archive envelope rc=0 | ||
| root=$(mktemp -d "$runner_temp/json-deploy-release.XXXXXX") | ||
| bin=$(mktemp -d "$runner_temp/json-deploy-bin.XXXXXX") | ||
| envelope="$bin/envelope.json" | ||
|
|
||
| tar -xzf "$workspace/fixture-release/app-release.tar.gz" -C "$root" | ||
| tar -xf "$root/$(jq -er '.app_cli.path' "$root/release.json")" -C "$bin" | ||
| cli="$bin/$(jq -er '."app-cli-bin"' "$bin/app-cli-meta.json")" | ||
| # make-fake-fastly-env.sh stages the fake `fastly` for install-fastly.sh; | ||
| # this script runs no action, so it puts it on PATH itself. | ||
| fastly_archive=$(find "$runner_temp/edgezero-action-tools/downloads" -name 'fastly-*-linux-amd64.tar.gz' | head -n 1) | ||
| [[ -n "$fastly_archive" ]] || fail "the fake Fastly CLI archive is missing" | ||
| tar -xzf "$fastly_archive" -C "$bin" fastly | ||
|
|
||
| PATH="$bin:$PATH" FASTLY_API_TOKEN=dummy-token \ | ||
| EDGEZERO_MANIFEST="$root/$(jq -er '.manifests.edgezero.path' "$root/release.json")" \ | ||
| "$cli" deploy --adapter fastly --format json --service-id dummyservice \ | ||
| --application-release "$root" >"$envelope" || rc=$? | ||
|
|
||
| [[ "$rc" -ne 0 ]] || fail "the injected provider failure did not fail the deploy" | ||
| grep -q '^PUT .*/service/dummyservice/version/40/clone$' "$FAKE_CALL_LOG" || fail "failure occurred before the clone" | ||
| jq -e --arg state "$expected_state" \ | ||
| '.ok == false and .result.service_id == "dummyservice" and .result.version == 42 and .result.version_state == $state' \ | ||
| "$envelope" >/dev/null || fail "unexpected envelope: $(cat "$envelope")" | ||
| notice "a failed JSON deploy reported version 42 as $expected_state" | ||
| } | ||
| main "$@" |
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
Oops, something went wrong.
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.