-
-
Notifications
You must be signed in to change notification settings - Fork 76
ci(commerce): Build @daffodil/commerce schematics
#4342
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
base: develop
Are you sure you want to change the base?
Changes from all commits
462a47c
0a98e79
6a190d5
658cf92
420b752
fd09716
74e3a1a
4a741be
ccb5a25
aacf045
2cad316
039861e
4ede2da
3e1ce5b
8a9638a
1ac2151
d43d0d7
157f2a4
db75a59
d3c99f6
5ff6897
589e430
29d7776
56728b9
2010004
98edaf9
5e9f478
ec7698a
cc93fbc
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| 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" |
| 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 | ||
| with: | ||
| fetch-depth: 1 | ||
|
|
||
| - uses: graycoreio/github-actions/setup-node@main | ||
| with: | ||
| node-version: 22.21.x | ||
| use-stamp-cache: true | ||
|
|
||
| - name: Start Verdaccio | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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/
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 |
||
| 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 | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We need some way to describe these as dependencies of |
||
| 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 | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. similarly to the build task, I think this should just be a |
||
| 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 | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Use the graycore action. |
||
| with: | ||
| node-version: 22.21.x | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 }} | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This should be done with |
||
| 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 | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 |
||
| 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 | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Instead of complex bash conditionals, I would just do |
||
| 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 | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,52 @@ | ||
| #!/usr/bin/env bash | ||
| set -euo pipefail | ||
|
|
||
| # ============================================================ | ||
damienwebdev marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| # 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 ===" | ||
| 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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
use latest action version.