From 8cdd68914e752b6f10c01801882935526753af80 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gast=C3=B3n=20Fournier?= Date: Wed, 15 Mar 2023 13:17:32 +0100 Subject: [PATCH] chore: avoid building frontend when possible (#3278) ## About the changes This is based on @nunogois suggestion to split the build in two, so we don't build the frontend every time we run `yarn` e2e frontend tests were forced to run by modifying frontend/README.md ### Important files Some github actions had to be updated to also build the frontend. The Dockerfile building our docker image was also looked into but it should work as is ## Discussion points This is a potentially risky operation as we might overlook something that requires building the frontend which might lead to invalid builds. We need to make sure when we do this we don't have any release planned. --- .github/workflows/build.yaml | 1 + .github/workflows/build_coverage.yaml | 1 + .github/workflows/build_prs.yaml | 1 + .github/workflows/release.yaml | 1 + frontend/README.md | 4 ++-- package.json | 4 +++- 6 files changed, 9 insertions(+), 3 deletions(-) diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index 989a8314cb..0a8a82aa5a 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -38,6 +38,7 @@ jobs: node-version: ${{ matrix.node-version }} cache: 'yarn' - run: yarn + # - run: yarn build:frontend # not needed - run: yarn lint - run: yarn run test env: diff --git a/.github/workflows/build_coverage.yaml b/.github/workflows/build_coverage.yaml index 90d2066ee6..de56352655 100644 --- a/.github/workflows/build_coverage.yaml +++ b/.github/workflows/build_coverage.yaml @@ -39,6 +39,7 @@ jobs: node-version: ${{ matrix.node-version }} cache: 'yarn' - run: yarn + - run: yarn build:frontend - run: yarn run test:coverage env: CI: true diff --git a/.github/workflows/build_prs.yaml b/.github/workflows/build_prs.yaml index 24b108ad93..1a5b641e84 100644 --- a/.github/workflows/build_prs.yaml +++ b/.github/workflows/build_prs.yaml @@ -20,3 +20,4 @@ jobs: - run: yarn install --frozen-lockfile --ignore-scripts - run: yarn lint - run: yarn build + #- run: yarn build:frontend # not needed diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index cf264e3d24..562dbf884e 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -22,6 +22,7 @@ jobs: cache: 'yarn' - run: | yarn install --frozen-lockfile + yarn --cwd ./frontend install --frozen-lockfile - run: | LATEST=$(npm show unleash-server version) TAG=$(node scripts/npm-tag.js $LATEST) diff --git a/frontend/README.md b/frontend/README.md index a19aa77df3..a951b0e088 100644 --- a/frontend/README.md +++ b/frontend/README.md @@ -8,7 +8,7 @@ First, start the unleash-api backend on port 4242. Then, start the frontend dev server: ``` -cd ~/frontend +cd ./frontend yarn install yarn run start ``` @@ -18,7 +18,7 @@ yarn run start Alternatively, instead of running unleash-api on localhost, you can use a remote instance: ``` -cd ~/frontend +cd ./frontend yarn install yarn run start:sandbox ``` diff --git a/package.json b/package.json index 14e8f54ff7..3c00dd4328 100644 --- a/package.json +++ b/package.json @@ -38,13 +38,15 @@ "build:watch": "tsc -w --strictNullChecks false", "prebuild": "yarn run clean", "build": "yarn run copy-templates && tsc --pretty --strictNullChecks false", - "prepare": "node scripts/husky-install && cd frontend && yarn && cd .. && yarn run build", + "build:frontend": "yarn --cwd ./frontend", + "prepare": "node scripts/husky-install && yarn run build", "test": "NODE_ENV=test PORT=4243 jest", "test:unit": "NODE_ENV=test PORT=4243 jest --testPathIgnorePatterns=src/test/e2e --testPathIgnorePatterns=dist", "test:docker": "./scripts/docker-postgres.sh", "test:docker:cleanup": "docker rm -f unleash-postgres", "test:watch": "yarn test --watch", "test:coverage": "NODE_ENV=test PORT=4243 jest --coverage --testLocationInResults --outputFile=\"coverage/report.json\" --forceExit --testTimeout=10000", + "pretest:coverage:jest": "yarn build:frontend", "test:coverage:jest": "NODE_ENV=test PORT=4243 jest --silent --ci --json --coverage --testLocationInResults --outputFile=\"report.json\" --forceExit --testTimeout=10000", "seed:setup": "ts-node src/test/e2e/seed/segment.seed.ts", "seed:serve": "UNLEASH_DATABASE_NAME=unleash_test UNLEASH_DATABASE_SCHEMA=seed yarn run start:dev",