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
443 changes: 361 additions & 82 deletions .github/scripts/generate-consumer-project.js

Large diffs are not rendered by default.

39 changes: 11 additions & 28 deletions .github/scripts/test-workspace-cleanup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -187,44 +187,27 @@ if [[ "$MODE" == "setup" ]]; then
}
trap cleanup_staging_dir EXIT

IS_DYNAMIC_CONSUMER=false
FIXTURE_DIR=""
if [[ "$FIXTURE" == "consumer-project" || "$TYPE" == "consumer-integration" ]]; then
IS_DYNAMIC_CONSUMER=true
FIXTURE_DIR="consumer-project (dynamic)"
fi

if [[ "$IS_DYNAMIC_CONSUMER" == "true" ]]; then
node "$REPO_ROOT/.github/scripts/generate-consumer-project.js" "$TMP_FIX" || {
echo "Error: Failed to generate dynamic consumer project." >&2
if [ -n "$FIXTURE" ] && [ -d "$FIXTURE" ]; then
cp -r "$FIXTURE"/* "$TMP_FIX"/ || {
echo "Error: Failed to copy fixture into temp dir." >&2
exit 1
}
else
if [ -n "$FIXTURE" ]; then
if [[ "$FIXTURE" == /* ]]; then
FIXTURE_DIR="$FIXTURE"
else
FIXTURE_DIR="__tests__/fixtures/${FIXTURE}"
fi
else
FIXTURE_DIR="__tests__/fixtures/${ACTION}/${RUNTIME}/${PM}/${TYPE}"
fi

if [ ! -d "$FIXTURE_DIR" ]; then
echo "Error: Missing expected fixture directory for matrix combination '${ACTION} (${RUNTIME}, ${PM}, ${TYPE})': $FIXTURE_DIR" >&2
exit 1
fi

cp -r "$FIXTURE_DIR"/* "$TMP_FIX"/ || {
echo "Error: Failed to copy fixture into temp dir." >&2
node "$REPO_ROOT/.github/scripts/generate-consumer-project.js" "$TMP_FIX" \
--action "$ACTION" \
--runtime "$RUNTIME" \
--pm "$PM" \
--type "$TYPE" \
${FIXTURE:+--fixture "$FIXTURE"} || {
echo "Error: Failed to generate dynamic scenario project." >&2
exit 1
}
fi

# Guard reserved local action directories and unallowed fixture root items that collide with existing workspace items
for reserved in pages autofix; do
if [ -e "$TMP_FIX/$reserved" ]; then
echo "Error: Fixture '${FIXTURE_DIR}' contains reserved local action directory '${reserved}'. Aborting setup to protect action source." >&2
echo "Error: Fixture contains reserved local action directory '${reserved}'. Aborting setup to protect action source." >&2
exit 1
fi
done
Expand Down
70 changes: 19 additions & 51 deletions .github/workflows/test-actions.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,67 +21,57 @@ jobs:
runtime: node
pm: npm
type: basic
fixture: pages/node/npm/basic
verify_site: true
- action: pages
runtime: node
pm: npm
type: minimal
fixture: pages/node/npm/minimal
verify_site: true
- action: pages
runtime: node
pm: npm
type: vite
fixture: pages/node/npm/vite
verify_site: true
- action: pages
runtime: node
pm: npm
type: consumer-integration
fixture: consumer-project
verify_site: true
- action: pages
runtime: node
pm: pnpm
type: basic
fixture: pages/node/pnpm/basic
verify_site: true
- action: pages
runtime: node
pm: pnpm
type: minimal
fixture: pages/node/pnpm/minimal
verify_site: true
- action: pages
runtime: node
pm: pnpm
type: minimal
fixture: vite-plus/node/pnpm/minimal
type: vite-plus
toolchain: vite-plus
verify_site: true
- action: pages
runtime: node
pm: bun
type: basic
fixture: pages/node/bun/basic
verify_site: true
- action: pages
runtime: bun
pm: bun
type: basic
fixture: pages/bun/bun/basic
verify_site: true
- action: pages
runtime: bun
pm: bun
type: minimal
fixture: pages/bun/bun/minimal
verify_site: true
- action: pages
runtime: bun
pm: pnpm
type: basic
fixture: pages/bun/pnpm/basic
verify_site: true

# JS Autofix action
Expand Down Expand Up @@ -136,7 +126,6 @@ jobs:
runtime: node
pm: npm
type: python-uv
fixture: autofix/python/uv
has_js_project: "false"
has_python_source: "true"
python_pm: uv
Expand All @@ -147,7 +136,6 @@ jobs:
runtime: node
pm: npm
type: consumer-integration
fixture: consumer-project
has_js_project: "true"
has_python_source: "true"
python_pm: pip
Expand All @@ -158,7 +146,6 @@ jobs:
runtime: node
pm: npm
type: python-pip
fixture: autofix/python/pip
has_js_project: "false"
has_python_source: "true"
python_pm: pip
Expand All @@ -169,7 +156,6 @@ jobs:
runtime: node
pm: npm
type: python-conflicting
fixture: autofix/python/conflicting
has_js_project: "false"
has_python_source: "true"
python_pm: uv
Expand All @@ -180,7 +166,6 @@ jobs:
runtime: node
pm: npm
type: python-none
fixture: autofix/python/none
has_js_project: "false"
has_python_source: "false"
python_pm: ""
Expand All @@ -191,7 +176,6 @@ jobs:
runtime: node
pm: npm
type: mixed
fixture: autofix/python/mixed
has_js_project: "true"
has_python_source: "true"
python_pm: pip
Expand All @@ -202,7 +186,6 @@ jobs:
runtime: bun
pm: bun
type: mixed
fixture: autofix/python/mixed-bun
has_js_project: "true"
has_python_source: "true"
python_pm: pip
Expand All @@ -219,9 +202,8 @@ jobs:
RUNTIME: ${{ matrix.runtime }}
PM: ${{ matrix.pm }}
TYPE: ${{ matrix.type }}
FIXTURE: ${{ matrix.fixture }}
run: |
bash .github/scripts/test-workspace-cleanup.sh setup "$ACTION" "$RUNTIME" "$PM" "$TYPE" "$FIXTURE"
bash .github/scripts/test-workspace-cleanup.sh setup "$ACTION" "$RUNTIME" "$PM" "$TYPE"

- name: Test Pages Action
if: matrix.action == 'pages'
Expand All @@ -243,14 +225,14 @@ jobs:
RUNTIME: ${{ matrix.runtime }}
PM: ${{ matrix.pm }}
TYPE: ${{ matrix.type }}
FIXTURE: ${{ matrix.fixture }}
PAGES_PM: ${{ steps.pages.outputs.package-manager }}
AUTOFIX_PM: ${{ steps.autofix.outputs.package-manager }}
EXPECTED_PM: ${{ matrix.pm }}
PAGES_RUNTIME: ${{ steps.pages.outputs.runtime }}
AUTOFIX_RUNTIME: ${{ steps.autofix.outputs.runtime }}
EXPECTED_RUNTIME: ${{ matrix.runtime }}
PAGES_TOOLCHAIN: ${{ steps.pages.outputs.toolchain }}
EXPECTED_TOOLCHAIN_INPUT: ${{ matrix.toolchain }}
VERIFY_SITE: ${{ matrix.verify_site }}
AUTOFIX_HAS_JS: ${{ steps.autofix.outputs.has-js-project }}
AUTOFIX_HAS_PYTHON: ${{ steps.autofix.outputs.has-python-source }}
Expand All @@ -263,46 +245,32 @@ jobs:
EXPECTED_PYTHON_VER: ${{ matrix.python_version }}
EXPECTED_RUFF_VER: ${{ matrix.ruff_version }}
run: |
if [ -d .test_workspace_state ] && [ -f .test_workspace_state/stash.info ]; then
STASH_DIR=$(grep "^stash_tests_path=" .test_workspace_state/stash.info 2>/dev/null | cut -d'=' -f2- || true)
TESTS_ROOT="${STASH_DIR}/__tests__"
else
TESTS_ROOT="__tests__"
fi
SCENARIO_NAME="${ACTION} (${RUNTIME}, ${PM}, ${TYPE})"

if [ -n "$FIXTURE" ]; then
if [[ "$FIXTURE" == /* ]]; then
FIXTURE_PATH="$FIXTURE"
else
FIXTURE_PATH="${TESTS_ROOT}/fixtures/${FIXTURE}"
fi
else
FIXTURE_PATH="${TESTS_ROOT}/fixtures/${ACTION}/${RUNTIME}/${PM}/${TYPE}"
fi
DETECTED_PM="${PAGES_PM}${AUTOFIX_PM}"
if [[ "$DETECTED_PM" != "$EXPECTED_PM" ]]; then
echo "Error: [${ACTION}] Package manager mismatch stage failed for fixture '${FIXTURE_PATH}'."
echo "Error: [${ACTION}] Package manager mismatch stage failed for scenario '${SCENARIO_NAME}'."
echo " Expected package manager: ${EXPECTED_PM}"
echo " Detected package manager: ${DETECTED_PM}"
exit 1
fi

DETECTED_RUNTIME="${PAGES_RUNTIME}${AUTOFIX_RUNTIME}"
if [[ "$DETECTED_RUNTIME" != "$EXPECTED_RUNTIME" ]]; then
echo "Error: [${ACTION}] Runtime mismatch stage failed for fixture '${FIXTURE_PATH}'."
echo "Error: [${ACTION}] Runtime mismatch stage failed for scenario '${SCENARIO_NAME}'."
echo " Expected runtime: ${EXPECTED_RUNTIME}"
echo " Detected runtime: ${DETECTED_RUNTIME}"
exit 1
fi

if [[ "$ACTION" == "pages" ]]; then
EXPECTED_TOOLCHAIN="vite"
if [[ "$FIXTURE" == "vite-plus/node/pnpm/minimal" ]]; then
if [[ "$TYPE" == "vite-plus" || "$EXPECTED_TOOLCHAIN_INPUT" == "vite-plus" ]]; then
EXPECTED_TOOLCHAIN="vite-plus"
fi
DETECTED_TOOLCHAIN="${PAGES_TOOLCHAIN}"
if [[ "$DETECTED_TOOLCHAIN" != "$EXPECTED_TOOLCHAIN" ]]; then
echo "Error: [${ACTION}] Toolchain mismatch stage failed for fixture '${FIXTURE_PATH}'."
echo "Error: [${ACTION}] Toolchain mismatch stage failed for scenario '${SCENARIO_NAME}'."
echo " Expected toolchain: ${EXPECTED_TOOLCHAIN}"
echo " Detected toolchain: ${DETECTED_TOOLCHAIN}"
exit 1
Expand All @@ -312,23 +280,23 @@ jobs:
if [[ "$ACTION" == "autofix" ]]; then
EXPECTED_HAS_JS="${EXPECTED_HAS_JS_PROJECT:-true}"
if [[ "$AUTOFIX_HAS_JS" != "$EXPECTED_HAS_JS" ]]; then
echo "Error: [${ACTION}] Has JS project mismatch stage failed for fixture '${FIXTURE_PATH}'."
echo "Error: [${ACTION}] Has JS project mismatch stage failed for scenario '${SCENARIO_NAME}'."
echo " Expected has-js-project: ${EXPECTED_HAS_JS}"
echo " Actual has-js-project: ${AUTOFIX_HAS_JS}"
exit 1
fi

EXPECTED_HAS_PY="${EXPECTED_HAS_PYTHON_SOURCE:-false}"
if [[ "$AUTOFIX_HAS_PYTHON" != "$EXPECTED_HAS_PY" ]]; then
echo "Error: [${ACTION}] Has Python source mismatch stage failed for fixture '${FIXTURE_PATH}'."
echo "Error: [${ACTION}] Has Python source mismatch stage failed for scenario '${SCENARIO_NAME}'."
echo " Expected has-python-source: ${EXPECTED_HAS_PY}"
echo " Actual has-python-source: ${AUTOFIX_HAS_PYTHON}"
exit 1
fi

EXPECTED_PY_PM="${EXPECTED_PYTHON_PM:-}"
if [[ "$AUTOFIX_PYTHON_PM" != "$EXPECTED_PY_PM" ]]; then
echo "Error: [${ACTION}] Python package manager mismatch stage failed for fixture '${FIXTURE_PATH}'."
echo "Error: [${ACTION}] Python package manager mismatch stage failed for scenario '${SCENARIO_NAME}'."
echo " Expected python-package-manager: ${EXPECTED_PY_PM}"
echo " Actual python-package-manager: ${AUTOFIX_PYTHON_PM}"
exit 1
Expand All @@ -337,7 +305,7 @@ jobs:
if [[ "$EXPECTED_PYTHON_VER" != "" || "$TYPE" == "python-none" ]]; then
EXPECTED_PY_VER="${EXPECTED_PYTHON_VER:-}"
if [[ "$AUTOFIX_PYTHON_VER" != "$EXPECTED_PY_VER" ]]; then
echo "Error: [${ACTION}] Python version mismatch stage failed for fixture '${FIXTURE_PATH}'."
echo "Error: [${ACTION}] Python version mismatch stage failed for scenario '${SCENARIO_NAME}'."
echo " Expected python-version: '${EXPECTED_PY_VER}'"
echo " Actual python-version: '${AUTOFIX_PYTHON_VER}'"
exit 1
Expand All @@ -346,14 +314,14 @@ jobs:

EXPECTED_RUFF="${EXPECTED_RUFF_VER:-}"
if [[ "$AUTOFIX_RUFF_VER" != "$EXPECTED_RUFF" ]]; then
echo "Error: [${ACTION}] Ruff version mismatch stage failed for fixture '${FIXTURE_PATH}'."
echo "Error: [${ACTION}] Ruff version mismatch stage failed for scenario '${SCENARIO_NAME}'."
echo " Expected ruff-version: ${EXPECTED_RUFF}"
echo " Actual ruff-version: ${AUTOFIX_RUFF_VER}"
exit 1
fi
fi

echo "Verified fixture execution root for '${FIXTURE_PATH}'."
echo "Verified scenario execution root for '${SCENARIO_NAME}'."

if [[ "$VERIFY_SITE" == "true" ]]; then
REPO_NAME="${GITHUB_REPOSITORY#*/}"
Expand All @@ -364,27 +332,27 @@ jobs:
EXPECTED_BASE="/${REPO_NAME}/"
fi
if [[ "$SITE" != "$EXPECTED_SITE" ]]; then
echo "Error: [${ACTION}] Site URL mismatch stage failed for fixture '${FIXTURE_PATH}'."
echo "Error: [${ACTION}] Site URL mismatch stage failed for scenario '${SCENARIO_NAME}'."
echo " Expected SITE: ${EXPECTED_SITE}"
echo " Actual SITE: ${SITE}"
exit 1
fi
if [[ "$BASE" != "$EXPECTED_BASE" ]]; then
echo "Error: [${ACTION}] Base URL mismatch stage failed for fixture '${FIXTURE_PATH}'."
echo "Error: [${ACTION}] Base URL mismatch stage failed for scenario '${SCENARIO_NAME}'."
echo " Expected BASE: ${EXPECTED_BASE}"
echo " Actual BASE: ${BASE}"
exit 1
fi

if [[ ! -f "dist/index.html" ]]; then
echo "Error: [${ACTION}] Artifact verification stage failed for fixture '${FIXTURE_PATH}'."
echo "Error: [${ACTION}] Artifact verification stage failed for scenario '${SCENARIO_NAME}'."
echo " Expected build artifact 'dist/index.html' was not produced by action execution."
exit 1
fi

if [[ "$TYPE" == "consumer-integration" ]]; then
if ! grep -q "AREA44 Workflows Consumer Project" "dist/index.html"; then
echo "Error: [${ACTION}] Consumer artifact content verification failed for fixture '${FIXTURE_PATH}'."
echo "Error: [${ACTION}] Consumer artifact content verification failed for scenario '${SCENARIO_NAME}'."
echo " 'dist/index.html' did not contain expected consumer fixture content 'AREA44 Workflows Consumer Project'."
exit 1
fi
Expand Down
Loading
Loading