Skip to content

Commit

Permalink
chore: avoid building frontend when possible (#3278)
Browse files Browse the repository at this point in the history
## 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.
  • Loading branch information
gastonfournier committed Mar 15, 2023
1 parent c2d51e4 commit 8cdd689
Show file tree
Hide file tree
Showing 6 changed files with 9 additions and 3 deletions.
1 change: 1 addition & 0 deletions .github/workflows/build.yaml
Expand Up @@ -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:
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/build_coverage.yaml
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/build_prs.yaml
Expand Up @@ -20,3 +20,4 @@ jobs:
- run: yarn install --frozen-lockfile --ignore-scripts
- run: yarn lint
- run: yarn build
#- run: yarn build:frontend # not needed
1 change: 1 addition & 0 deletions .github/workflows/release.yaml
Expand Up @@ -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)
Expand Down
4 changes: 2 additions & 2 deletions frontend/README.md
Expand Up @@ -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
```
Expand All @@ -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
```
Expand Down
4 changes: 3 additions & 1 deletion package.json
Expand Up @@ -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",
Expand Down

0 comments on commit 8cdd689

Please sign in to comment.