From 3b5e556e1c2910c1ce234bd72ffa4995a5d5f315 Mon Sep 17 00:00:00 2001 From: Harrison Healey Date: Wed, 17 May 2023 13:59:34 -0400 Subject: [PATCH] MM-52438 Clean up web app CI and only run when web app code is changed (#23232) * MM-52438 Only run web app CI for PRs with web app changes * MM-52438 Don't wait to run web app tests in CI * MM-52438 Remove commented out caching * MM-52438 Reuse steps to set up webapp environment * MM-52438 Add test-ci script to root package.json * Simplify path filter --- .github/actions/webapp-setup/action.yml | 18 ++++ .github/workflows/webapp-ci-master.yml | 1 - .github/workflows/webapp-ci-pr.yml | 2 + .github/workflows/webapp-ci-template.yml | 124 +++-------------------- webapp/package.json | 1 + 5 files changed, 37 insertions(+), 109 deletions(-) create mode 100644 .github/actions/webapp-setup/action.yml diff --git a/.github/actions/webapp-setup/action.yml b/.github/actions/webapp-setup/action.yml new file mode 100644 index 000000000000..d9d304345c83 --- /dev/null +++ b/.github/actions/webapp-setup/action.yml @@ -0,0 +1,18 @@ +name: "Web app setup" +description: "Set up NPM and dependencies" + +runs: + using: "composite" + steps: + - name: ci/setup-node + uses: actions/setup-node@64ed1c7eab4cce3362f8c340dee64e5eaeef8f7c # v3.6.0 + id: setup_node + with: + node-version-file: ".nvmrc" + cache: npm + cache-dependency-path: 'webapp/package-lock.json' + - name: ci/get-node-modules + shell: bash + working-directory: webapp + run: | + make node_modules diff --git a/.github/workflows/webapp-ci-master.yml b/.github/workflows/webapp-ci-master.yml index 387663f60cff..b025c06135e0 100644 --- a/.github/workflows/webapp-ci-master.yml +++ b/.github/workflows/webapp-ci-master.yml @@ -5,7 +5,6 @@ on: - master - cloud - release-* - - mono-repo* jobs: master-ci: diff --git a/.github/workflows/webapp-ci-pr.yml b/.github/workflows/webapp-ci-pr.yml index 9aef2ff492c1..3f4c17340959 100644 --- a/.github/workflows/webapp-ci-pr.yml +++ b/.github/workflows/webapp-ci-pr.yml @@ -1,6 +1,8 @@ name: Web App CI PR on: pull_request: + paths: + - 'webapp/**' concurrency: group: ${{ github.workflow }}-${{ github.ref }} diff --git a/.github/workflows/webapp-ci-template.yml b/.github/workflows/webapp-ci-template.yml index b303bcb908a0..a533a29f98f5 100644 --- a/.github/workflows/webapp-ci-template.yml +++ b/.github/workflows/webapp-ci-template.yml @@ -5,9 +5,6 @@ name: Web App CI Template on: workflow_call: -defaults: - run: - shell: bash jobs: check-lint: runs-on: ubuntu-22.04 @@ -17,29 +14,12 @@ jobs: steps: - name: ci/checkout-repo uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # v3.3.0 - - name: ci/setup-node - uses: actions/setup-node@64ed1c7eab4cce3362f8c340dee64e5eaeef8f7c # v3.6.0 - id: setup_node - with: - node-version-file: ".nvmrc" - cache: npm - cache-dependency-path: 'webapp/package-lock.json' - # - uses: actions/cache@2b8105bdae4b746666ee225970c4a281bbd9d51f # v3.2.4 - # id: npm-cache - # with: - # path: | - # '**/node_modules' - # 'e2e-tests/playwright/node_modules' - # 'e2e-tests/cypress/node_modules' - # key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}-${{ hashFiles('e2e-tests/cypress/package-lock.json') }}-${{ hashFiles('e2e-tests/playwright/package-lock.json') }} - - name: ci/get-node-modules - # if: steps.npm-cache.outputs.cache-hit != 'true' - run: | - make node_modules - # make channels/e2e-tests/playwright/node_modules + - name: ci/setup + uses: ./.github/actions/webapp-setup - name: ci/lint run: | npm run check + check-i18n: runs-on: ubuntu-22.04 defaults: @@ -48,26 +28,8 @@ jobs: steps: - name: ci/checkout-repo uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # v3.3.0 - - name: ci/setup-node - uses: actions/setup-node@64ed1c7eab4cce3362f8c340dee64e5eaeef8f7c # v3.6.0 - id: setup_node - with: - node-version-file: ".nvmrc" - cache: npm - cache-dependency-path: 'webapp/package-lock.json' - # - uses: actions/cache@2b8105bdae4b746666ee225970c4a281bbd9d51f # v3.2.4 - # id: npm-cache - # with: - # path: | - # '**/node_modules' - # 'e2e-tests/playwright/node_modules' - # 'e2e-tests/cypress/node_modules' - # key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}-${{ hashFiles('e2e-tests/cypress/package-lock.json') }}-${{ hashFiles('e2e-tests/playwright/package-lock.json') }} - - name: ci/get-node-modules - # if: steps.npm-cache.outputs.cache-hit != 'true' - run: | - make node_modules - # make channels/e2e-tests/playwright/node_modules + - name: ci/setup + uses: ./.github/actions/webapp-setup - name: ci/lint working-directory: webapp/channels run: | @@ -90,6 +52,7 @@ jobs: run: | npm run i18n-extract git --no-pager diff --exit-code i18n/en.json || (echo "Please run \"cd webapp/playbooks && npm run i18n-extract\" and commit the changes in webapp/playbooks/i18n/en.json." && exit 1) + check-types: runs-on: ubuntu-22.04 defaults: @@ -98,32 +61,14 @@ jobs: steps: - name: ci/checkout-repo uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # v3.3.0 - - name: ci/setup-node - uses: actions/setup-node@64ed1c7eab4cce3362f8c340dee64e5eaeef8f7c # v3.6.0 - id: setup_node - with: - node-version-file: ".nvmrc" - cache: npm - cache-dependency-path: 'webapp/package-lock.json' - # - uses: actions/cache@2b8105bdae4b746666ee225970c4a281bbd9d51f # v3.2.4 - # id: npm-cache - # with: - # path: | - # '**/node_modules' - # 'e2e-tests/playwright/node_modules' - # 'e2e-tests/cypress/node_modules' - # key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}-${{ hashFiles('e2e-tests/cypress/package-lock.json') }}-${{ hashFiles('e2e-tests/playwright/package-lock.json') }} - - name: ci/get-node-modules - # if: steps.npm-cache.outputs.cache-hit != 'true' - run: | - make node_modules - # make channels/e2e-tests/playwright/node_modules + - name: ci/setup + uses: ./.github/actions/webapp-setup - name: ci/lint run: | npm run check-types + test: runs-on: ubuntu-22.04 - needs: [check-types, check-i18n, check-lint] permissions: checks: write pull-requests: write @@ -133,34 +78,14 @@ jobs: steps: - name: ci/checkout-repo uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # v3.3.0 - - name: ci/setup-node - uses: actions/setup-node@64ed1c7eab4cce3362f8c340dee64e5eaeef8f7c # v3.6.0 - id: setup_node - with: - node-version-file: ".nvmrc" - cache: npm - cache-dependency-path: 'webapp/package-lock.json' - # - uses: actions/cache@2b8105bdae4b746666ee225970c4a281bbd9d51f # v3.2.4 - # id: npm-cache - # with: - # path: | - # '**/node_modules' - # 'e2e-tests/playwright/node_modules' - # 'e2e-tests/cypress/node_modules' - # key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}-${{ hashFiles('e2e-tests/cypress/package-lock.json') }}-${{ hashFiles('e2e-tests/playwright/package-lock.json') }} - - name: ci/get-node-modules - # if: steps.npm-cache.outputs.cache-hit != 'true' - run: | - make node_modules - # make channels/e2e-tests/playwright/node_modules + - name: ci/setup + uses: ./.github/actions/webapp-setup - name: ci/test env: NODE_OPTIONS: --max_old_space_size=5120 run: | - npm run test-ci --workspace=boards - npm run test-ci --workspace=channels - npm run test-ci --workspace=platform/client - npm run test-ci --workspace=playbooks + npm run test-ci + build: runs-on: ubuntu-22.04 defaults: @@ -169,29 +94,12 @@ jobs: steps: - name: ci/checkout-repo uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # v3.3.0 - - name: ci/setup-node - uses: actions/setup-node@64ed1c7eab4cce3362f8c340dee64e5eaeef8f7c # v3.6.0 - id: setup_node - with: - node-version-file: ".nvmrc" - cache: npm - cache-dependency-path: 'webapp/package-lock.json' - # - uses: actions/cache@2b8105bdae4b746666ee225970c4a281bbd9d51f # v3.2.4 - # id: npm-cache - # with: - # path: | - # '**/node_modules' - # 'e2e-tests/playwright/node_modules' - # 'e2e-tests/cypress/node_modules' - # key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}-${{ hashFiles('e2e-tests/cypress/package-lock.json') }}-${{ hashFiles('e2e-tests/playwright/package-lock.json') }} - - name: ci/get-node-modules - # if: steps.npm-cache.outputs.cache-hit != 'true' - run: | - make node_modules - # make channels/e2e-tests/playwright/node_modules + - name: ci/setup + uses: ./.github/actions/webapp-setup - name: ci/build run: | npm run build + # run-performance-bechmarks: # uses: ./.github/workflows/performance-benchmarks.yml # needs: build diff --git a/webapp/package.json b/webapp/package.json index 2deee4b4b8dc..cb88f1f9d265 100644 --- a/webapp/package.json +++ b/webapp/package.json @@ -11,6 +11,7 @@ "run": "node scripts/run.js", "dev-server": "node scripts/dev-server.js", "test": "npm run test --workspaces --if-present", + "test-ci": "npm run test-ci --workspaces --if-present", "check": "npm run check --workspaces --if-present", "fix": "npm run fix --workspaces --if-present", "check-types": "npm run check-types --workspaces --if-present",