Skip to content

Commit

Permalink
MM-52438 Clean up web app CI and only run when web app code is changed (
Browse files Browse the repository at this point in the history
mattermost#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
  • Loading branch information
hmhealey authored May 17, 2023
1 parent f48f979 commit 3b5e556
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 109 deletions.
18 changes: 18 additions & 0 deletions .github/actions/webapp-setup/action.yml
Original file line number Diff line number Diff line change
@@ -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
1 change: 0 additions & 1 deletion .github/workflows/webapp-ci-master.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ on:
- master
- cloud
- release-*
- mono-repo*

jobs:
master-ci:
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/webapp-ci-pr.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
name: Web App CI PR
on:
pull_request:
paths:
- 'webapp/**'

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
Expand Down
124 changes: 16 additions & 108 deletions .github/workflows/webapp-ci-template.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,6 @@ name: Web App CI Template
on:
workflow_call:

defaults:
run:
shell: bash
jobs:
check-lint:
runs-on: ubuntu-22.04
Expand All @@ -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:
Expand All @@ -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: |
Expand All @@ -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:
Expand All @@ -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
Expand All @@ -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:
Expand All @@ -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
1 change: 1 addition & 0 deletions webapp/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down

0 comments on commit 3b5e556

Please sign in to comment.