Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
462a47c
Fix detected codebase errors
joannalauu Feb 22, 2026
0a98e79
Local test script for commerce schematics
joannalauu Feb 22, 2026
6a190d5
Add github actions workflow for commerce test
joannalauu Feb 23, 2026
658cf92
Rename workflow
joannalauu Feb 23, 2026
420b752
Scaffold module app through standalone app and improve naming
joannalauu Feb 23, 2026
fd09716
Move test logic to workflow matrix
joannalauu Feb 27, 2026
74e3a1a
Move test logic to workflow matrix
joannalauu Feb 27, 2026
4a741be
write token to npmrc
joannalauu Feb 27, 2026
ccb5a25
add debuging statements
joannalauu Feb 27, 2026
aacf045
add additional debuging scripts
joannalauu Feb 27, 2026
2cad316
Testing fix
joannalauu Feb 27, 2026
039861e
more debugging statements
joannalauu Feb 27, 2026
4ede2da
more debugging scripts
joannalauu Feb 27, 2026
3e1ce5b
pass token directly into npm publish
joannalauu Feb 27, 2026
8a9638a
more debuging
joannalauu Feb 27, 2026
1ac2151
more debuging
joannalauu Feb 27, 2026
d43d0d7
fix debugging script
joannalauu Feb 27, 2026
157f2a4
more debugging
joannalauu Feb 27, 2026
db75a59
test connectivity
joannalauu Feb 27, 2026
d3c99f6
run npm publish in isolated dir
joannalauu Feb 27, 2026
5ff6897
add token to tmp
joannalauu Feb 27, 2026
589e430
fix writing permissions
joannalauu Feb 27, 2026
29d7776
ignore publish scripts
joannalauu Feb 27, 2026
56728b9
Remove debugging scripts and patch version.ts
joannalauu Feb 27, 2026
2010004
Fix potential indentation issue
joannalauu Feb 27, 2026
98edaf9
Remove leading spaces
joannalauu Feb 27, 2026
5e9f478
Add npmrc to HOME and use set-versions github actions
joannalauu Feb 27, 2026
ec7698a
Add start-verdaccio action and move variables to env
joannalauu Feb 27, 2026
cc93fbc
Improve naming
joannalauu Feb 27, 2026
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
35 changes: 35 additions & 0 deletions .github/actions/start-verdaccio/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
name: Start Verdaccio
description: Start a Verdaccio Docker container and configure npm authentication

inputs:
port:
description: Port to expose Verdaccio on
required: true
config:
description: Path to Verdaccio config file (relative to workspace)
required: true
storage:
description: Path to Verdaccio storage directory
required: true

runs:
using: composite
steps:
- shell: bash
run: |
REGISTRY_URL="http://localhost:${{ inputs.port }}"
mkdir -p ${{ inputs.storage }}
chmod 777 ${{ inputs.storage }}
docker run -d --name verdaccio \
-p ${{ inputs.port }}:${{ inputs.port }} \
-v ${{ github.workspace }}/${{ inputs.config }}:/verdaccio/conf/config.yaml \
-v ${{ inputs.storage }}:/tmp/verdaccio-storage \
verdaccio/verdaccio
npx wait-on ${REGISTRY_URL}/-/ping --timeout 30000
TOKEN=$(curl -s -X PUT ${REGISTRY_URL}/-/user/org.couchdb.user:ci \
-H "Content-Type: application/json" \
-d '{"name":"ci","password":"ci-password","type":"user"}' \
| node -e "process.stdin.resume();process.stdin.on('data',d=>console.log(JSON.parse(d).token))")

echo "@daffodil:registry=${REGISTRY_URL}" >> "$HOME/.npmrc"
echo "//localhost:${{ inputs.port }}/:_authToken=${TOKEN}" >> "$HOME/.npmrc"
275 changes: 275 additions & 0 deletions .github/workflows/build-commerce-schematic.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,275 @@
name: Daffodil Build Schematic

on:
pull_request:
branches:
- develop
paths:
- 'tools/schematics/**'

env:
WORK_DIR: /tmp/daffodil-commerce-test
VERDACCIO_STORAGE: /tmp/verdaccio-storage
TEST_VERSION: 0.0.0-test.${{ github.run_id }}
REGISTRY_PORT: 4873
VERDACCIO_CONFIG: tools/schematics/e2e/verdaccio-config.yml
DAFFODIL_PACKAGES: >-
core
driver
product
dev-tools
navigation
external-router

jobs:
setup:
name: Build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
Copy link
Member

Choose a reason for hiding this comment

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

use latest action version.

with:
fetch-depth: 1

- uses: graycoreio/github-actions/setup-node@main
with:
node-version: 22.21.x
use-stamp-cache: true

- name: Start Verdaccio
Copy link
Member

Choose a reason for hiding this comment

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

I think this can be replaced with a container running in the pipeline: https://www.verdaccio.org/docs/docker/

Copy link
Contributor Author

@joannalauu joannalauu Feb 28, 2026

Choose a reason for hiding this comment

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

I looked into this approach, and I believe that if we replace the existing composite action with service containers, we'll need to restart the container within setup job and test job. This is because the service starts before workflow steps, but the VERDACCIO_CONFIG repository file and the Verdaccio cache is only available during the workflow steps. These restarts seem wasteful - do you think it is still worth it to go forward with this change, or is there an existing approach that can prevent these restarts while using service containers?

uses: ./.github/actions/start-verdaccio
with:
port: ${{ env.REGISTRY_PORT }}
config: ${{ env.VERDACCIO_CONFIG }}
storage: ${{ env.VERDACCIO_STORAGE }}

- name: Set test version
run: |
npm version "${{ env.TEST_VERSION }}" --no-git-tag-version
sed -i "s/version = '.*'/version = '${{ env.TEST_VERSION }}'/" \
tools/schematics/ng-add/generators/version.ts

- name: Build @daffodil/* packages
Copy link
Member

Choose a reason for hiding this comment

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

We need some way to describe these as dependencies of @daffodil/commerce (perhaps devDependencies) so that we don't name them explicitly here.

run: |
npx nx run-many -t build \
--projects=@daffodil/core,@daffodil/driver,@daffodil/product,@daffodil/dev-tools,@daffodil/navigation,@daffodil/external-router
cd tools/schematics && npm run build

- uses: graycoreio/github-actions/set-versions-from-root@main

- name: Publish @daffodil/* packages to Verdaccio
run: |
for pkg in ${{ env.DAFFODIL_PACKAGES }}; do
Copy link
Member

Choose a reason for hiding this comment

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

similarly to the build task, I think this should just be a npx nx run @daffodil/commerce:publish

echo "--- Publishing @daffodil/$pkg ---"
cd "${{ github.workspace }}/dist/$pkg"
npm publish --ignore-scripts
done

echo "--- Publishing @daffodil/commerce ---"
cd "${{ github.workspace }}/dist/commerce"
npm publish --ignore-scripts

- name: Scaffold base apps
run: bash tools/schematics/e2e/test-commerce-schematics.sh

- name: Cache base apps and Verdaccio storage
uses: actions/cache/save@v4
with:
path: |
${{ env.WORK_DIR }}
${{ env.VERDACCIO_STORAGE }}
key: commerce-test-${{ github.run_id }}

test:
name: "${{ matrix.name }}"
needs: setup
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
include:
- name: demo-driver
driver: demo
base: scss
app_type: standalone
routing: true
skip_package_json: false
succeed: true
build: true

- name: magento-driver
driver: magento
base: scss
app_type: standalone
routing: true
skip_package_json: false
succeed: true
build: true

- name: shopify-driver
driver: shopify
base: scss
app_type: standalone
routing: true
skip_package_json: false
succeed: true
build: true

- name: in-memory-driver
driver: in-memory
base: scss
app_type: standalone
routing: true
skip_package_json: false
succeed: true
build: true

- name: skip-package-json
driver: in-memory
base: scss
app_type: standalone
routing: true
skip_package_json: true
succeed: true
build: false

- name: module-app-rejection
driver: in-memory
base: scss
app_type: module
routing: true
skip_package_json: false
succeed: false
build: false

- name: main-ts-fallback
driver: in-memory
base: scss
app_type: main-ts-fallback
routing: true
skip_package_json: false
succeed: true
build: true

- name: css-style-failure
driver: in-memory
base: css
app_type: standalone
routing: true
skip_package_json: false
succeed: false
build: true

- name: no-app-routes
driver: in-memory
base: scss
app_type: standalone
routing: false
skip_package_json: false
succeed: true
build: true

steps:
- uses: actions/checkout@v4
with:
fetch-depth: 1

- uses: actions/setup-node@v4
Copy link
Member

Choose a reason for hiding this comment

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

Use the graycore action.

with:
node-version: 22.21.x
Copy link
Member

Choose a reason for hiding this comment

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

Move to matrix.


- name: Restore base apps and Verdaccio storage
uses: actions/cache/restore@v4
with:
path: |
${{ env.WORK_DIR }}
${{ env.VERDACCIO_STORAGE }}
Copy link
Member

Choose a reason for hiding this comment

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

I don't think we should cache verdaccio. build / publish in the job should be fast.

key: commerce-test-${{ github.run_id }}

- name: Start Verdaccio
Copy link
Member

Choose a reason for hiding this comment

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

I think this can be replaced with a container running in the pipeline: https://www.verdaccio.org/docs/docker/

uses: ./.github/actions/start-verdaccio
with:
port: ${{ env.REGISTRY_PORT }}
config: ${{ env.VERDACCIO_CONFIG }}
storage: ${{ env.VERDACCIO_STORAGE }}

- name: Copy base app
run: |
BASE_APP="${{ env.WORK_DIR }}/test-daff-app"
if [ "${{ matrix.base }}" = "css" ]; then
BASE_APP="${{ env.WORK_DIR }}/test-daff-app-css"
fi
TEST_DIR="${{ env.WORK_DIR }}/test-${{ matrix.name }}"
rm -rf "$TEST_DIR"
cp -a "$BASE_APP" "$TEST_DIR"

- name: Apply app modifications
Copy link
Member

Choose a reason for hiding this comment

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

This should be done with --standalone=false during generation.

working-directory: ${{ env.WORK_DIR }}/test-${{ matrix.name }}
run: |
if [ "${{ matrix.app_type }}" = "module" ]; then
cat > "src/app/app-module.ts" <<'APPMOD'
import { NgModule } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
import { AppComponent } from './app.component';

@NgModule({
declarations: [AppComponent],
imports: [BrowserModule],
bootstrap: [AppComponent]
})
export class AppModule {}
APPMOD
fi

if [ "${{ matrix.app_type }}" = "main-ts-fallback" ]; then
cat > "src/main.ts" <<'MAIN'
import { bootstrapApplication } from '@angular/platform-browser';
import { App } from './app/app';

bootstrapApplication(App, {
providers: []
});
MAIN
rm -f "src/app/app.config.ts"
fi

if [ "${{ matrix.routing }}" = "false" ]; then
rm -f "src/app/app.routes.ts"
fi

- name: Generate schematic
Copy link
Member

Choose a reason for hiding this comment

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

To guarantee that users can do the exact command as we do in CI can you just do npx ng add @daffodil/commerce@$TEST_VERSION?

working-directory: ${{ env.WORK_DIR }}/test-${{ matrix.name }}
run: |
EXTRA_FLAGS=""
if [ "${{ matrix.skip_package_json }}" = "true" ]; then
EXTRA_FLAGS="--skip-package-json"
fi

if [ "${{ matrix.succeed }}" = "true" ] || [ "${{ matrix.build }}" = "true" ]; then
Copy link
Member

Choose a reason for hiding this comment

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

Instead of complex bash conditionals, I would just do continue-on-error: ${{ matrix.succeed }} for the tests we know are currently problematic.

CI=true npx ng generate @daffodil/commerce:ng-add \
--driver="${{ matrix.driver }}" \
--is-new-project \
--defaults \
$EXTRA_FLAGS
else
! CI=true npx ng generate @daffodil/commerce:ng-add \
--driver="${{ matrix.driver }}" \
--is-new-project \
--defaults \
$EXTRA_FLAGS
fi

- name: Raise budget
if: matrix.driver == 'demo'
working-directory: ${{ env.WORK_DIR }}/test-${{ matrix.name }}
run: |
sed -i 's/"maximumWarning": "[^"]*"/"maximumWarning": "2mb"/; s/"maximumError": "[^"]*"/"maximumError": "3mb"/' angular.json

- name: Run ng build
if: matrix.build
working-directory: ${{ env.WORK_DIR }}/test-${{ matrix.name }}
run: |
if [ "${{ matrix.succeed }}" = "true" ]; then
npx ng build
else
! npx ng build
fi
52 changes: 52 additions & 0 deletions tools/schematics/e2e/test-commerce-schematics.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
#!/usr/bin/env bash
set -euo pipefail

# ============================================================
# Scaffold base Angular apps for @daffodil/commerce e2e tests.
#
# Called by the GitHub Actions setup job. Creates 2 base apps
# (scss + css) with @daffodil/commerce installed from Verdaccio.
#
# Prerequisites:
# - Verdaccio running on localhost:4873
# - npm config set @daffodil:registry http://localhost:4873
# - @daffodil/commerce published to Verdaccio
#
# Output:
# $WORK_DIR/test-daff-app (scss base app)
# $WORK_DIR/test-daff-app-css (css base app)
# ============================================================

WORK_DIR="${WORK_DIR:-/tmp/daffodil-commerce-test}"
APP_NAME="test-daff-app"

rm -rf "$WORK_DIR"
mkdir -p "$WORK_DIR"

# --- SCSS Base App ---
echo "=== Creating scss base app ==="
cd "$WORK_DIR"
npx -y @angular/cli@20 new "$APP_NAME" \
--style=scss \
--skip-tests \
--defaults

echo "--- Installing @daffodil/commerce into scss base app ---"
cd "$WORK_DIR/$APP_NAME"
npm install @daffodil/commerce

# --- CSS Base App ---
echo ""
echo "=== Creating css base app ==="
cd "$WORK_DIR"
npx -y @angular/cli@20 new "${APP_NAME}-css" \
--style=css \
--skip-tests \
--defaults

echo "--- Installing @daffodil/commerce into css base app ---"
cd "$WORK_DIR/${APP_NAME}-css"
npm install @daffodil/commerce

echo ""
echo "=== Base apps scaffolded in $WORK_DIR ==="
21 changes: 21 additions & 0 deletions tools/schematics/e2e/verdaccio-config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
storage: /tmp/verdaccio-storage
auth:
htpasswd:
file: /tmp/verdaccio-htpasswd
max_users: 100
uplinks:
npmjs:
url: https://registry.npmjs.org/
packages:
'@daffodil/*':
access: $all
publish: $all
'**':
access: $all
proxy: npmjs
server:
keepAliveTimeout: 60
log:
type: stdout
format: pretty
level: warn
Loading