[App Extensibility] Bring back recently-commented-out Github actions (@W-18219092@) #8815
Workflow file for this run
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
| # WARNING! Conditionals are set as variables to minimize repetitive checks. | |
| # However, this results in the variables being the *string* values "true" or "false". | |
| # As a result, you must always explicitly check for those strings. For example, | |
| # ${{ env.DEVELOP }} will ALWAYS evaluate as true; to achieve the expected result | |
| # you must check ${{ env.DEVELOP == 'true' }}. There's probably a better way to DRY, | |
| # but this is what we have for now. | |
| name: SalesforceCommerceCloud/pwa-kit/test | |
| on: | |
| # PRs from forks trigger `pull_request`, but do NOT have access to secrets. | |
| # More info: | |
| # https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#workflows-in-forked-repositories-1 | |
| # https://securitylab.github.com/research/github-actions-preventing-pwn-requests/ | |
| # https://docs.github.com/en/actions/managing-workflow-runs/approving-workflow-runs-from-public-forks | |
| pull_request: # Default: opened, reopened, synchronize (head branch updated) | |
| merge_group: # Trigger GA workflow when a pull request is added to a merge queue. | |
| push: | |
| branches: | |
| - develop | |
| # TODO: Should we run on all pushes to release branches, or should we run on GitHub releases? | |
| - 'release-*' | |
| schedule: | |
| # Run every day at 12am (PST) - cron uses UTC times | |
| - cron: '0 8 * * *' | |
| env: | |
| IS_NOT_FORK: ${{ github.event_name == 'push' || github.event.pull_request.head.repo.full_name == github.repository }} | |
| DEVELOP: ${{ (github.event_name == 'push' || github.event.pull_request.head.repo.full_name == github.repository) && (github.head_ref || github.ref_name) == 'develop' }} | |
| RELEASE: ${{ (github.event_name == 'push' || github.event.pull_request.head.repo.full_name == github.repository) && startsWith(github.head_ref || github.ref_name, 'release-') }} | |
| # The current recommended version for Managed Runtime: | |
| # https://developer.salesforce.com/docs/commerce/pwa-kit-managed-runtime/guide/upgrade-node-version.html | |
| # NOTE: if you update these values, please also update `IS_MRT_NODE`. | |
| MRT_NODE: 22 | |
| MRT_NPM: 10 | |
| jobs: | |
| changelog-check: | |
| if: (github.event_name == 'push' || github.event.pull_request.head.repo.full_name == github.repository) | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Auto-pass for non-PR events | |
| if: env.DEVELOP == 'true' | |
| run: exit 0 | |
| - name: Checkout | |
| if: env.DEVELOP != 'true' | |
| uses: actions/checkout@v4 | |
| - name: Changelog Check | |
| if: env.DEVELOP != 'true' | |
| uses: ./.github/actions/changelog-check | |
| with: | |
| pr_number: ${{ github.event.pull_request.number }} | |
| pwa-kit: | |
| needs: changelog-check | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| node: [18, 20, 22] | |
| npm: [8, 9, 10, 11] | |
| exclude: # node 18 with npm 11 are not compatible | |
| - node: 18 | |
| npm: 11 | |
| runs-on: ubuntu-latest | |
| env: | |
| # The "default" npm is the one that ships with a given version of node. | |
| # For more: https://nodejs.org/en/download/releases/ | |
| # (We also use this env var for making sure a step runs once for the current node version) | |
| IS_DEFAULT_NPM: ${{ (matrix.node == 18 && matrix.npm == 10) || (matrix.node == 20 && matrix.npm == 10) || (matrix.node == 22 && matrix.npm == 10) }} | |
| IS_MRT_NODE: ${{ matrix.node == 22 && matrix.npm == 10 }} | |
| PROJECT_DIR: generated-retail-react-app-test-project | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| - name: Setup Node | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: ${{ matrix.node }} | |
| cache: npm | |
| - name: Update NPM version | |
| if: env.IS_DEFAULT_NPM == 'false' | |
| run: |- | |
| npm install -g npm@${{ matrix.npm }} | |
| - name: Setup Ubuntu Machine | |
| uses: "./.github/actions/setup_ubuntu" | |
| # TODO: repeat for the windows version | |
| - name: Generate retail-react-app-test-project | |
| run: |- | |
| node packages/pwa-kit-create-app/scripts/create-mobify-app-dev.js --outputDir ${{ env.PROJECT_DIR }} | |
| env: | |
| GENERATOR_PRESET: retail-react-app-test-project | |
| timeout-minutes: 8 | |
| - name: Smoke test the NPM scripts | |
| if: env.IS_DEFAULT_NPM == 'true' | |
| uses: "./.github/actions/npm_scripts" | |
| with: | |
| cwd: ${{ env.PROJECT_DIR }} | |
| - name: Run unit tests | |
| uses: "./.github/actions/unit_tests" | |
| # ------------------------------------------- | |
| # Now that all unit tests have passed, we're confident to run the following steps. | |
| - name: Create MRT credentials file | |
| if: env.IS_NOT_FORK == 'true' && env.IS_MRT_NODE == 'true' && ( env.DEVELOP == 'true' || env.RELEASE == 'true' ) | |
| uses: "./.github/actions/create_mrt" | |
| with: | |
| mobify_user: ${{ secrets.MOBIFY_CLIENT_USER }} | |
| mobify_api_key: ${{ secrets.MOBIFY_CLIENT_API_KEY }} | |
| # TODO - Do we still need this? | |
| - name: Push Bundle to MRT (Development) | |
| if: env.IS_NOT_FORK == 'true' && env.IS_MRT_NODE == 'true' && env.DEVELOP == 'true' | |
| uses: "./.github/actions/push_to_mrt" | |
| with: | |
| CWD: "./packages/template-retail-react-app" | |
| TARGET: staging | |
| - name: Push Bundle to MRT (Commerce SDK React) | |
| if: env.IS_NOT_FORK == 'true' && env.IS_MRT_NODE == 'true' && env.DEVELOP == 'true' | |
| uses: "./.github/actions/push_to_mrt" | |
| with: | |
| CWD: "./packages/test-commerce-sdk-react" | |
| TARGET: commerce-sdk-react | |
| - name: Check Repository Clean | |
| if: env.IS_NOT_FORK == 'true' && env.IS_DEFAULT_NPM == 'true' | |
| uses: "./.github/actions/check_clean" | |
| - name: Publish to NPM | |
| if: env.IS_NOT_FORK == 'true' && env.IS_MRT_NODE == 'true' && env.RELEASE == 'true' | |
| uses: "./.github/actions/publish_to_npm" | |
| with: | |
| NODE_AUTH_TOKEN: ${{ secrets.NODE_AUTH_TOKEN }} | |
| - name: Send GitHub Action data to Slack workflow (PWA Kit) | |
| id: slack | |
| if: env.IS_NOT_FORK == 'true' && env.IS_DEFAULT_NPM == 'true' && env.DEVELOP == 'true' && failure() | |
| uses: slackapi/slack-github-action@v1.23.0 | |
| with: | |
| payload: | | |
| { | |
| "test": "A 'testNode${{ matrix.node }}' task has failed." | |
| } | |
| env: | |
| SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }} | |
| pwa-kit-windows: | |
| needs: changelog-check | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| node: [18, 20, 22] | |
| npm: [8, 9, 10, 11] | |
| exclude: # node 18 with npm 11 is not compatible | |
| - node: 18 | |
| npm: 11 | |
| runs-on: windows-latest | |
| env: | |
| # The "default" npm is the one that ships with a given version of node. | |
| # For more: https://nodejs.org/en/download/releases/ | |
| # (We also use this env var for making sure a step runs once for the current node version) | |
| # Note: For node 18, the default was npm 9 until v18.19.0, when it became npm 10 | |
| IS_DEFAULT_NPM: ${{ (matrix.node == 18 && matrix.npm == 10) || (matrix.node == 20 && matrix.npm == 10) || (matrix.node == 22 && matrix.npm == 10) }} | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| - name: Setup Node | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: ${{ matrix.node }} | |
| cache: npm | |
| - name: Update NPM version | |
| if: env.IS_DEFAULT_NPM == 'false' | |
| run: |- | |
| npm install -g npm@${{ matrix.npm }} | |
| - name: Setup Windows Machine | |
| uses: "./.github/actions/setup_windows" | |
| - name: Run tests | |
| uses: "./.github/actions/unit_tests" | |
| # TODO: The generated workflow is identical to the generated-windows workflow, | |
| # with a few extra steps. Can the workflows be merged? (Add `os` to the matrix?) | |
| generated: | |
| needs: changelog-check | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| template: [retail-react-app-test-project, express-minimal-test-project, typescript-minimal-test-project] | |
| runs-on: ubuntu-latest | |
| env: | |
| IS_TEMPLATE_FROM_RETAIL_REACT_APP: ${{ matrix.template == 'retail-react-app-test-project' }} | |
| PROJECT_DIR: generated-${{ matrix.template }} | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| - name: Setup Node | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: ${{ env.MRT_NODE }} | |
| - name: Setup Ubuntu Machine | |
| uses: "./.github/actions/setup_ubuntu" | |
| - name: Generate ${{ matrix.template }} project | |
| run: |- | |
| node packages/pwa-kit-create-app/scripts/create-mobify-app-dev.js --outputDir ${{ env.PROJECT_DIR }} | |
| env: | |
| GENERATOR_PRESET: ${{ matrix.template }} | |
| timeout-minutes: 8 | |
| - name: Lint the generated project | |
| if: env.IS_TEMPLATE_FROM_RETAIL_REACT_APP == 'true' | |
| uses: "./.github/actions/linting" | |
| with: | |
| cwd: ${{ env.PROJECT_DIR }} | |
| - name: Run unit tests | |
| if: env.IS_TEMPLATE_FROM_RETAIL_REACT_APP == 'true' | |
| uses: "./.github/actions/unit_tests" | |
| with: | |
| cwd: ${{ env.PROJECT_DIR }} | |
| # - name: Run smoke tests | |
| # if: env.IS_TEMPLATE_FROM_RETAIL_REACT_APP == 'true' | |
| # uses: "./.github/actions/smoke_tests" | |
| # with: | |
| # dir: ${{ env.PROJECT_DIR }} | |
| - name: Count Generated Project Dependencies | |
| id: count_deps | |
| if: env.IS_TEMPLATE_FROM_RETAIL_REACT_APP == 'true' | |
| uses: "./.github/actions/count_deps" | |
| - name: Store Verdaccio logfile artifact | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: verdaccio-log-${{ matrix.template }} | |
| path: packages/pwa-kit-create-app/local-npm-repo/verdaccio-${{ matrix.template }}.log | |
| # TODO: Ticket W-12425059. Revisit Snyk CLI integration to monitor manifest files on generated projects. | |
| # TODO: Update the SNYK_TOKEN stored in GitHub with a token generated from the proper Snyk org. | |
| # - name: Audit Generated Project | |
| # if: env.IS_NOT_FORK == 'true' && env.IS_TEMPLATE_FROM_RETAIL_REACT_APP == 'true' && env.DEVELOP == 'true' | |
| # uses: "./.github/actions/snyk" | |
| # with: | |
| # snyk_token: ${{ secrets.SNYK_TOKEN }} | |
| - name: Send metrics to Datadog | |
| if: env.IS_NOT_FORK == 'true' && env.IS_TEMPLATE_FROM_RETAIL_REACT_APP == 'true' | |
| uses: "./.github/actions/datadog" | |
| with: | |
| datadog_api_key: ${{ secrets.DATADOG_API_KEY }} | |
| # TODO: The way this is set is a little bit magic - can it be cleaned up? | |
| TOTAL_PACKAGES: $TOTAL_PACKAGES | |
| - name: Create MRT credentials file | |
| if: env.IS_NOT_FORK == 'true' && env.IS_TEMPLATE_FROM_RETAIL_REACT_APP == 'true' && env.DEVELOP == 'true' | |
| uses: "./.github/actions/create_mrt" | |
| with: | |
| mobify_user: ${{ secrets.MOBIFY_CLIENT_USER }} | |
| mobify_api_key: ${{ secrets.MOBIFY_CLIENT_API_KEY }} | |
| - name: Push Bundle to MRT | |
| if: env.IS_NOT_FORK == 'true' && env.DEVELOP == 'true' && matrix.template == 'retail-react-app-test-project' | |
| uses: "./.github/actions/push_to_mrt" | |
| with: | |
| CWD: ${{ env.PROJECT_DIR }} | |
| TARGET: generated-pwa | |
| - name: Send GitHub Action data to Slack workflow (Generated) | |
| id: slack | |
| if: env.IS_NOT_FORK == 'true' && env.IS_TEMPLATE_FROM_RETAIL_REACT_APP == 'true' && env.DEVELOP == 'true' && failure() | |
| uses: slackapi/slack-github-action@v1.23.0 | |
| with: | |
| payload: | | |
| { | |
| "message": "A 'generated ${{ matrix.template }}' task has failed." | |
| } | |
| env: | |
| SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }} | |
| generated-windows: | |
| needs: changelog-check | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| template: [retail-react-app-test-project, express-minimal-test-project, typescript-minimal-test-project] | |
| runs-on: windows-latest | |
| env: | |
| IS_TEMPLATE_FROM_RETAIL_REACT_APP: ${{ matrix.template == 'retail-react-app-test-project' }} | |
| PROJECT_DIR: generated-${{ matrix.template }} | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| - name: Setup Node | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: ${{ env.MRT_NODE }} | |
| - name: Setup Windows Machine | |
| uses: "./.github/actions/setup_windows" | |
| - name: Generate ${{ matrix.template }} project | |
| run: |- | |
| node packages/pwa-kit-create-app/scripts/create-mobify-app-dev.js --outputDir ${{ env.PROJECT_DIR }} | |
| env: | |
| GENERATOR_PRESET: ${{ matrix.template }} | |
| timeout-minutes: 7 | |
| - name: Lint the generated project | |
| if: env.IS_TEMPLATE_FROM_RETAIL_REACT_APP == 'true' | |
| uses: "./.github/actions/linting" | |
| with: | |
| cwd: ${{ env.PROJECT_DIR }} | |
| - name: Run unit tests | |
| if: env.IS_TEMPLATE_FROM_RETAIL_REACT_APP == 'true' | |
| uses: "./.github/actions/unit_tests" | |
| with: | |
| cwd: ${{ env.PROJECT_DIR }} | |
| # - name: Run smoke tests | |
| # if: env.IS_TEMPLATE_FROM_RETAIL_REACT_APP == 'true' | |
| # uses: "./.github/actions/smoke_tests" | |
| # with: | |
| # dir: ${{ env.PROJECT_DIR }} | |
| - name: Count Generated Project Dependencies | |
| if: env.IS_TEMPLATE_FROM_RETAIL_REACT_APP == 'true' | |
| uses: "./.github/actions/count_deps" | |
| - name: Store Verdaccio logfile artifact | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: verdaccio-log-${{ matrix.template }} | |
| path: packages/pwa-kit-create-app/local-npm-repo/verdaccio-windows-${{ matrix.template }}.log | |
| bundle-sizes: | |
| needs: changelog-check | |
| strategy: | |
| fail-fast: false | |
| runs-on: ubuntu-latest | |
| env: | |
| PROJECT_DIR: generated-retail-react-app-test-project | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| - name: Setup Node | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: ${{ env.MRT_NODE }} | |
| cache: npm | |
| - name: Setup Ubuntu Machine | |
| uses: "./.github/actions/setup_ubuntu" | |
| - name: Generate retail-react-app-test-project | |
| run: |- | |
| node packages/pwa-kit-create-app/scripts/create-mobify-app-dev.js --outputDir ${{ env.PROJECT_DIR }} | |
| env: | |
| GENERATOR_PRESET: retail-react-app-test-project | |
| timeout-minutes: 8 | |
| - name: Check and report bundle sizes | |
| uses: "./.github/actions/bundle_size_test" | |
| with: | |
| cwd: ${{ env.PROJECT_DIR }} | |
| # NOTE: Commenting out this lighthouse test because it's run against a _local_ server that skews the performance metrics to be better than they really are. | |
| # TODO: perhaps run lighthouse in another workflow (e2e one) that deploys to MRT and test against that. | |
| # lighthouse: | |
| # needs: changelog-check | |
| # strategy: | |
| # fail-fast: false | |
| # runs-on: ubuntu-latest | |
| # env: | |
| # PROJECT_DIR: generated-retail-react-app-test-project | |
| # # This path is relative to PROJECT_DIR | |
| # LIGHTHOUSE_CONFIG_PATH: ../.github/actions/lighthouse_ci/lighthouserc.js | |
| # steps: | |
| # - name: Checkout | |
| # uses: actions/checkout@v4 | |
| # - name: Setup Node | |
| # uses: actions/setup-node@v4 | |
| # with: | |
| # node-version: ${{ env.MRT_NODE }} | |
| # cache: npm | |
| # - name: Setup Ubuntu Machine | |
| # uses: "./.github/actions/setup_ubuntu" | |
| # - name: Generate retail-react-app-test-project | |
| # run: |- | |
| # node packages/pwa-kit-create-app/scripts/create-mobify-app-dev.js --outputDir ${{ env.PROJECT_DIR }} | |
| # env: | |
| # GENERATOR_PRESET: retail-react-app-test-project | |
| # timeout-minutes: 8 | |
| # - name: Run Lighthouse CI on the generated project | |
| # uses: "./.github/actions/lighthouse_ci" | |
| # with: | |
| # project_dir: ${{ env.PROJECT_DIR }} | |
| # lighthouse_config_path: ${{ env.LIGHTHOUSE_CONFIG_PATH }} |