Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
53 changes: 53 additions & 0 deletions .github/actions/build-cli-tarball/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
name: 'Build the @shopify/cli tarball'
description: 'Builds the @shopify/cli tarball that a release of the checked-out commit would publish, and uploads it as an artifact'
inputs:
artifact-name:
required: true
description: 'Name of the artifact to upload the tarball as'
outputs:
tarball:
description: 'File name of the tarball in packages/cli'
value: ${{ steps.pack.outputs.tarball }}
version:
description: 'Version of @shopify/cli in the tarball'
value: ${{ steps.pack.outputs.version }}
runs:
using: 'composite'
steps:
- name: Setup deps
uses: ./.github/actions/setup-cli-deps
with:
node-version: 24.22.1

# The same build the release runs, before it publishes.
- name: Bundle
shell: bash
run: pnpm bundle-for-release
env:
SHOPIFY_CLI_BUILD_REPO: ${{ github.repository }}

# The release's prepack also generates the manifest and copies the README. Its error-reporting
# source map upload is left out, and the tarball excludes source maps either way.
- name: Pack @shopify/cli
id: pack
shell: bash
working-directory: packages/cli
run: |
set -euo pipefail
pnpm oclif manifest
cp ../../README.md README.md
TARBALL=$(npm pack --ignore-scripts | tail -n 1)
VERSION=$(tar -xzOf "$TARBALL" package/package.json | node -p 'JSON.parse(require("node:fs").readFileSync(0, "utf8")).version')
{
echo "tarball=$TARBALL"
echo "version=$VERSION"
} >> "$GITHUB_OUTPUT"

- name: Upload the tarball
uses: actions/upload-artifact@v4
with:
name: ${{ inputs.artifact-name }}
path: packages/cli/${{ steps.pack.outputs.tarball }}
if-no-files-found: error
# The tarball is already compressed.
compression-level: 0
93 changes: 93 additions & 0 deletions .github/scripts/smoke-test-cli.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
#!/usr/bin/env bash
# Runs the checks that need no Shopify account against the globally installed `shopify`.
# Works on Linux, macOS and Git Bash on Windows.
#
# Usage: smoke-test-cli.sh <expected-version>
set -euo pipefail

if [ "$#" -ne 1 ] || [ -z "$1" ]; then
echo "Usage: $0 <expected-version>" >&2
exit 2
fi
EXPECTED_VERSION="$1"

# No color codes in the output, no prompts, no analytics, and no auto-upgrade, which the CLI skips
# when CI is set.
export NO_COLOR=1
export SHOPIFY_CLI_NO_ANALYTICS=1
export CI=1

WORK_DIR=$(mktemp -d)
trap 'rm -rf "$WORK_DIR"' EXIT
cd "$WORK_DIR"

CURRENT_CASE=""
trap 'echo "::error::Smoke test failed: $CURRENT_CASE"' ERR

start_case() {
CURRENT_CASE="$1"
echo
echo "=== $1"
}

fail() {
echo "::error::$CURRENT_CASE: $1"
exit 1
}

# A command's JSON output schema names its own result type beside the shared error and event types.
check_schema() {
node -e 'const schema = JSON.parse(require("fs").readFileSync(process.argv[1], "utf8")); if (!schema.definitions?.Result) process.exit(1)' "$1" ||
fail "$1 isn't the command's JSON output schema"
}

start_case "shopify version is $EXPECTED_VERSION"
VERSION_OUTPUT=$(shopify version)
echo "$VERSION_OUTPUT"
# Exact match on one whitespace-separated token, so 5.1.1 doesn't match 5.1.10.
if ! tr -s ' \t\r' '\n' <<< "$VERSION_OUTPUT" | grep -Fxq "$EXPECTED_VERSION"; then
fail "expected version $EXPECTED_VERSION, got: $VERSION_OUTPUT"
fi

start_case "shopify help"
shopify help

start_case "shopify commands"
COMMANDS_OUTPUT=$(shopify commands)
echo "Listed $(wc -l <<< "$COMMANDS_OUTPUT" | tr -d ' ') lines of commands"

for TOPIC in app theme hydrogen; do
start_case "shopify $TOPIC --help"
shopify "$TOPIC" --help
done

# Help comes from the oclif manifest, so it doesn't load a command's code. --json-schema does, from
# the plugin that provides the command, and needs no Shopify account or project.
start_case "shopify hydrogen check --json-schema"
shopify hydrogen check --json-schema > hydrogen-check-schema.json
check_schema hydrogen-check-schema.json

start_case "shopify app info --json-schema"
shopify app info --json-schema > app-info-schema.json
check_schema app-info-schema.json

# A pinned Skeleton release, so a newer one can't fail an older line's theme check. A URL with a
# tag takes the Git-only path: the default Skeleton URL looks up its release through the GitHub
# API, whose unauthenticated rate limit is shared by every machine behind the same address.
start_case "shopify theme init"
shopify theme init qa-theme --clone-url https://github.com/Shopify/skeleton-theme#v1.0.0
[ -f qa-theme/config/settings_schema.json ] || fail "qa-theme/config/settings_schema.json is missing"

# The default fail level, error, lets warnings and suggestions pass.
start_case "shopify theme check"
shopify theme check --path qa-theme --fail-level error

start_case "shopify theme package"
shopify theme package --path qa-theme
ZIPS=$(find qa-theme -maxdepth 1 -name '*.zip')
[ -n "$ZIPS" ] || fail "no .zip file in qa-theme"
echo "Packaged $ZIPS"

CURRENT_CASE=""
echo
echo "All smoke tests passed for @shopify/cli $EXPECTED_VERSION"
Loading
Loading