Skip to content
This repository was archived by the owner on Oct 3, 2025. It is now read-only.

Commit 730f4fa

Browse files
Merge pull request #438 from platformsh/improvement/backend-frontend-build-time
Improve build time performance
2 parents daad1eb + dc34802 commit 730f4fa

File tree

18 files changed

+3980
-20236
lines changed

18 files changed

+3980
-20236
lines changed

.github/workflows/test.yaml

Lines changed: 29 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -3,95 +3,79 @@ name: Node.js CI
33
on:
44
pull_request:
55
branches:
6-
- main
6+
- main
77

88
env:
9-
MAX_HIGH: 0
10-
MAX_CRITICAL: 0
9+
MAX_HIGH: 0
10+
MAX_CRITICAL: 0
1111

1212
jobs:
1313
build:
14-
1514
runs-on: ubuntu-latest
1615

1716
strategy:
1817
matrix:
1918
# These versions match Upsun support
2019
# Node.js: https://docs.upsun.com/languages/nodejs.html#supported-versions
21-
node-version: [18.x, 20.x, 21.x]
20+
node-version: [22.x]
2221
# Python: https://docs.upsun.com/languages/python.html#supported-versions
23-
python-version: ['3.9', '3.10', '3.11', '3.12']
22+
python-version: ['3.12']
2423

2524
steps:
2625
################################################################################################
2726
# A. Setup workflow.
28-
- name: "1. Retrieve local files."
27+
- name: "Retrieve local files."
2928
uses: actions/checkout@v4
3029
with:
3130
ref: ${{ github.event.pull_request.head.sha }}
32-
- name: "2. Set up Node.js."
31+
- name: "Set up Node.js."
3332
uses: actions/setup-node@v3
3433
with:
3534
node-version: ${{ matrix.node-version }}
36-
- name: "3. Python."
35+
- name: "Python."
3736
uses: actions/setup-python@v4
3837
with:
3938
python-version: ${{ matrix.python-version }}
40-
cache: 'pip'
41-
42-
################################################################################################
43-
# B. Prettify, lint, and test repo.
44-
- name: "4. Preparing"
39+
cache: 'pip' # harmless even though we'll use uv
40+
- name: "Install uv"
41+
uses: astral-sh/setup-uv@v6
42+
with:
43+
version: latest
44+
- name: "Install bun"
45+
uses: oven-sh/setup-bun@v2
46+
with:
47+
bun-version: latest
48+
- name: "Install application dependencies"
4549
run: |
4650
echo "::notice::Running react-scripts tests."
4751
export CI=true
48-
npm install cross-env npm-run-all -g
49-
npm install
52+
bun install
5053
- name: "5. Verifying backend code is pretty"
51-
run: |
52-
npm run prettier:backend
54+
run: bun run prettier:backend
5355
- name: "6. Verifying frontend code is pretty"
54-
run: |
55-
npm run prettier:frontend
56+
run: bun run prettier:frontend
5657
- name: "7. Linting frontend"
57-
run: npm run lint:frontend
58+
run: bun run lint:frontend
5859
- name: "8. Run Frontend tests"
59-
run: npm run test:frontend
60+
run: bun run test:frontend
6061
- name: "9. Run Backend linting"
61-
run: |
62-
npm run lint:backend
62+
run: bun run lint:backend
6363

6464
################################################################################################
6565
# C. Ensure no vulnerabilities.
6666
- name: "10. Test: there should be no Python vulnerabilities."
6767
run: |
6868
echo "::notice::Checking for vulnerabilities in backend Python app dependencies."
69-
npm run test:backend
69+
bun run test:backend
7070
- name: "11. Test: there should be no HIGH Node.js vulnerabilities."
7171
run: |
72-
echo "::notice::Checking for high vulnerabilities in frontend Node.js app dependencies."
72+
echo "::notice::Checking HIGH vulnerabilities (bun audit)."
7373
cd frontend
7474
export CI=true
75-
HIGH_VULN_ALLOWED=${{ env.MAX_HIGH }}
76-
HIGH_VULN=$(npm audit --json | jq '.metadata.vulnerabilities.high')
77-
if [ "$HIGH_VULN" -gt "$HIGH_VULN_ALLOWED" ]; then
78-
echo "::error::NPM HIGH vulnerabilities exceed allowed budget."
79-
npm audit
80-
exit 1
81-
else
82-
echo "::notice::No HIGH vulnerabilities found on frontend app."
83-
fi
75+
bun audit --audit-level=high
8476
- name: "12. Test: there should be no CRITICAL Node.js vulnerabilities."
8577
run: |
86-
echo "::notice::Checking for critical vulnerabilities in frontend Node.js app dependencies."
78+
echo "::notice::Checking CRITICAL vulnerabilities (bun audit)."
8779
cd frontend
8880
export CI=true
89-
CRITICAL_VULN_ALLOWED=${{ env.MAX_CRITICAL }}
90-
CRITICAL_VULN=$(npm audit --json | jq '.metadata.vulnerabilities.high')
91-
if [ "$CRITICAL_VULN" -gt "$CRITICAL_VULN_ALLOWED" ]; then
92-
echo "::error::NPM CRITICAL vulnerabilities exceed allowed budget."
93-
npm audit
94-
exit 1
95-
else
96-
echo "::notice::No CRITICAL vulnerabilities found on frontend app."
97-
fi
81+
bun audit --audit-level=critical

.upsun/config.yaml

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ applications:
99
source:
1010
root: "frontend"
1111

12-
type: "nodejs:18"
12+
type: "nodejs:22"
1313

1414
build:
1515
flavor: none
@@ -23,9 +23,9 @@ applications:
2323
hooks:
2424
build: |
2525
set -eux
26-
npm install
26+
bun install
2727
export REACT_APP_PROJECT_ID=$PLATFORM_PROJECT
28-
npm run build
28+
bun run build
2929
3030
relationships:
3131
api: "backend:http"
@@ -51,16 +51,25 @@ applications:
5151

5252
type: "python:3.12"
5353

54+
dependencies:
55+
python3:
56+
uv: "*"
57+
5458
build:
5559
flavor: none
60+
61+
variables:
62+
env:
63+
UV_CACHE_DIR: .uv_cache
64+
5665
hooks:
5766
build: |
5867
set -eux
59-
pip install -r requirements.txt --disable-pip-version-check
68+
uv sync --frozen --no-dev --no-managed-python
6069
6170
web:
6271
commands:
63-
start: "gunicorn main:app"
72+
start: ".venv/bin/gunicorn main:app"
6473
upstream:
6574
socket_family: tcp
6675
locations:

backend/.python-version

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
3.12

backend/pyproject.toml

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
[project]
2+
name = "backend"
3+
version = "0.1.0"
4+
description = "Add your description here"
5+
readme = "README.md"
6+
requires-python = ">=3.12"
7+
dependencies = [
8+
"async-timeout==4.0.3",
9+
"black==24.4.0",
10+
"blinker==1.7.0",
11+
"boolean-py==4.0",
12+
"cachecontrol==0.13.1",
13+
"cachelib==0.13.0",
14+
"certifi>=2024.7.4",
15+
"charset-normalizer==3.3.2",
16+
"click==8.1.7",
17+
"cyclonedx-python-lib==6.4.4",
18+
"defusedxml==0.7.1",
19+
"filelock==3.13.3",
20+
"flask==3.0.0",
21+
"flask-cors>=4.0.2",
22+
"flask-session==0.5.0",
23+
"gunicorn>=23.0.0",
24+
"html5lib==1.1",
25+
"idna==3.7",
26+
"itsdangerous==2.1.2",
27+
"jinja2>=3.1.6",
28+
"license-expression==30.3.0",
29+
"markdown-it-py==3.0.0",
30+
"markupsafe==2.1.3",
31+
"mdurl==0.1.2",
32+
"msgpack==1.0.8",
33+
"packageurl-python==0.15.0",
34+
"packaging==23.2",
35+
"pip-api==0.0.30",
36+
"pip-audit==2.7.2",
37+
"pip-requirements-parser==32.0.1",
38+
"py-serializable==1.0.3",
39+
"pygments==2.17.2",
40+
"pylint==3.0.3",
41+
"pyparsing==3.1.1",
42+
"python-dotenv==1.0.1",
43+
"redis==4.5.4",
44+
"requests>=2.32.4",
45+
"rich==13.7.0",
46+
"six==1.16.0",
47+
"sortedcontainers==2.4.0",
48+
"toml==0.10.2",
49+
"urllib3>=2.5.0",
50+
"webencodings==0.5.1",
51+
"werkzeug>=3.0.6",
52+
]
53+
54+
[dependency-groups]
55+
dev = [
56+
"pip-audit>=2.7.2",
57+
"pylint>=3.0.3",
58+
]

backend/requirements.txt

Lines changed: 0 additions & 44 deletions
This file was deleted.

backend/scripts/build.sh

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,7 @@
11
#!/usr/bin/env bash
22

3-
# Setup a virtual environment
4-
python3 -m venv env
5-
source env/bin/activate
6-
73
# Install dependencies
8-
pip install --upgrade pip
9-
pip install -r requirements.txt
4+
uv sync --dev
105

116
# Test scenarios
127
cp .env.sample .env

backend/scripts/clean.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@
22

33
# Cleanup
44
rm -rf env
5-
rm .env
5+
rm -f .env

backend/scripts/lint_backend.sh

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,5 @@
11
#!/usr/bin/env bash
22

3-
python3 -m venv env
4-
source env/bin/activate
5-
pip install --upgrade pip
6-
pip install -r requirements.txt
3+
uv sync --dev
74

8-
pylint main.py app/**/*.py
5+
uv run pylint main.py app/**/*.py
Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,5 @@
11
#!/usr/bin/env bash
22

3-
python3 -m venv env
4-
source env/bin/activate
5-
pip install --upgrade pip
6-
pip install -r requirements.txt
3+
uv sync --dev
74

8-
black . --diff --color --check
5+
uv run black . --diff --color --check

backend/scripts/start.sh

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
11
#!/usr/bin/env bash
22

3-
source env/bin/activate
4-
gunicorn main:app
3+
uv run gunicorn main:app

0 commit comments

Comments
 (0)