Skip to content

Commit 08d901c

Browse files
authored
Merge pull request #1469 from o1-labs/dw/define-build-commands-for-each-configuration
Frontend: define one build target per configuration
2 parents e3f0710 + d443260 commit 08d901c

File tree

11 files changed

+182
-35
lines changed

11 files changed

+182
-35
lines changed

.github/actions/frontend-build/action.yml

Lines changed: 80 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,10 @@ inputs:
99
description: 'Whether to run Cypress tests'
1010
required: false
1111
default: 'false'
12+
test-build-commands:
13+
description: 'Whether to test all build commands'
14+
required: false
15+
default: 'false'
1216
node-version:
1317
description: 'Node.js version to use'
1418
required: false
@@ -40,7 +44,81 @@ runs:
4044
shell: bash
4145

4246
- name: Build frontend
43-
run: npm run build
47+
run: make build
48+
working-directory: frontend
49+
shell: bash
50+
51+
# Test Makefile targets
52+
- name: Test make build
53+
if: inputs.test-build-commands == 'true'
54+
run: |
55+
rm -rf dist
56+
make build
57+
[ -d "dist/frontend" ] || { echo "Error: make build failed"; exit 1; }
58+
working-directory: frontend
59+
shell: bash
60+
61+
62+
- name: Test make build-development
63+
if: inputs.test-build-commands == 'true'
64+
run: |
65+
rm -rf dist
66+
make build-development
67+
[ -d "dist/frontend" ] || { echo "Error: make build-development failed"; exit 1; }
68+
working-directory: frontend
69+
shell: bash
70+
71+
- name: Test make build-fuzzing
72+
if: inputs.test-build-commands == 'true'
73+
run: |
74+
rm -rf dist
75+
make build-fuzzing
76+
[ -d "dist/frontend" ] || { echo "Error: make build-fuzzing failed"; exit 1; }
77+
working-directory: frontend
78+
shell: bash
79+
80+
- name: Test make build-local
81+
if: inputs.test-build-commands == 'true'
82+
run: |
83+
rm -rf dist
84+
make build-local
85+
[ -d "dist/frontend" ] || { echo "Error: make build-local failed"; exit 1; }
86+
working-directory: frontend
87+
shell: bash
88+
89+
- name: Test make build-prod
90+
if: inputs.test-build-commands == 'true'
91+
run: |
92+
rm -rf dist
93+
make build-prod
94+
[ -d "dist/frontend" ] || { echo "Error: make build-prod failed"; exit 1; }
95+
working-directory: frontend
96+
shell: bash
97+
98+
- name: Test make build-producer
99+
if: inputs.test-build-commands == 'true'
100+
run: |
101+
rm -rf dist
102+
make build-producer
103+
[ -d "dist/frontend" ] || { echo "Error: make build-producer failed"; exit 1; }
104+
working-directory: frontend
105+
shell: bash
106+
107+
- name: Test make build-production
108+
if: inputs.test-build-commands == 'true'
109+
run: |
110+
rm -rf dist
111+
make build-production
112+
[ -d "dist/frontend" ] || { echo "Error: make build-production failed"; exit 1; }
113+
working-directory: frontend
114+
shell: bash
115+
116+
- name: Test make build-webnodelocal
117+
if: inputs.test-build-commands == 'true'
118+
run: |
119+
rm -rf dist
120+
make build-webnodelocal
121+
[ -d "dist/frontend" ] || { echo "Error: make build-webnodelocal failed"; exit 1; }
44122
working-directory: frontend
45123
shell: bash
46124

@@ -51,4 +129,4 @@ runs:
51129
working-directory: frontend
52130
start: npm start
53131
wait-on: http://localhost:4200
54-
wait-on-timeout: 180s
132+
wait-on-timeout: 180s

.github/workflows/frontend-macos-13.yaml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,4 +17,6 @@ jobs:
1717
uses: actions/checkout@v5
1818

1919
- name: Frontend build
20-
uses: ./.github/actions/frontend-build
20+
uses: ./.github/actions/frontend-build
21+
with:
22+
test-build-commands: 'true'

.github/workflows/frontend-macos-14.yaml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,4 +17,6 @@ jobs:
1717
uses: actions/checkout@v5
1818

1919
- name: Frontend build
20-
uses: ./.github/actions/frontend-build
20+
uses: ./.github/actions/frontend-build
21+
with:
22+
test-build-commands: 'true'

.github/workflows/frontend-macos-15.yaml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,4 +17,6 @@ jobs:
1717
uses: actions/checkout@v5
1818

1919
- name: Frontend build
20-
uses: ./.github/actions/frontend-build
20+
uses: ./.github/actions/frontend-build
21+
with:
22+
test-build-commands: 'true'

.github/workflows/frontend-macos-latest.yaml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,4 +17,6 @@ jobs:
1717
uses: actions/checkout@v5
1818

1919
- name: Frontend build
20-
uses: ./.github/actions/frontend-build
20+
uses: ./.github/actions/frontend-build
21+
with:
22+
test-build-commands: 'true'

.github/workflows/frontend-ubuntu-22-04.yaml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,4 +17,6 @@ jobs:
1717
uses: actions/checkout@v5
1818

1919
- name: Frontend build
20-
uses: ./.github/actions/frontend-build
20+
uses: ./.github/actions/frontend-build
21+
with:
22+
test-build-commands: 'true'

.github/workflows/frontend-ubuntu-24-04-arm.yaml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,4 +17,6 @@ jobs:
1717
uses: actions/checkout@v5
1818

1919
- name: Frontend build
20-
uses: ./.github/actions/frontend-build
20+
uses: ./.github/actions/frontend-build
21+
with:
22+
test-build-commands: 'true'

.github/workflows/frontend.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,3 +22,4 @@ jobs:
2222
with:
2323
run-prettier-check: 'true'
2424
run-tests: 'true'
25+
test-build-commands: 'false'

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
2424
([#1486](https://github.com/o1-labs/mina-rust/pull/1466))
2525
- **Frontend**: use a Makefile for scripts in package.json
2626
([#1468](https://github.com/o1-labs/mina-rust/pull/1468))
27+
- **Frontend**: define one Makefile target per build configuration
28+
([#1469](https://github.com/o1-labs/mina-rust/pull/1469))
2729

2830
### Changed
2931

frontend/Makefile

Lines changed: 68 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,40 @@ help: ## Display this help message
99

1010
.PHONY: build
1111
build: ## Build the frontend
12-
ng build
12+
npx ng build
1313

14-
.PHONY: build-dev
15-
build-dev: ## Build the frontend for development
16-
ng build --configuration development
14+
.PHONY: build-development
15+
build-development: ## Build the frontend with development configuration
16+
npx ng build --configuration development
17+
18+
.PHONY: build-fuzzing
19+
build-fuzzing: ## Build the frontend with fuzzing configuration
20+
npx ng build --configuration fuzzing
21+
22+
.PHONY: build-local
23+
build-local: ## Build the frontend with local configuration
24+
npx ng build --configuration local
1725

1826
.PHONY: build-prod
1927
build-prod: ## Build the frontend for production
20-
ng build --configuration production && $(MAKE) sentry-sourcemaps
28+
npx ng build --configuration production
29+
30+
.PHONY: build-prod-sentry
31+
build-prod-sentry: ## Build the frontend for production with Sentry sourcemaps
32+
npx ng build --configuration production
33+
$(MAKE) sentry-sourcemaps
34+
35+
.PHONY: build-producer
36+
build-producer: ## Build the frontend with producer configuration
37+
npx ng build --configuration producer
38+
39+
.PHONY: build-production
40+
build-production: ## Build the frontend with production configuration
41+
npx ng build --configuration production
42+
43+
.PHONY: build-webnodelocal
44+
build-webnodelocal: ## Build the frontend with webnodelocal configuration
45+
npx ng build --configuration webnodelocal
2146

2247
.PHONY: check-prettify
2348
check-prettify: ## Check if files are formatted with Prettier
@@ -34,21 +59,24 @@ copy-env: ## Copy webnode.js to env.js
3459

3560
.PHONY: deploy
3661
deploy: ## Deploy the application
37-
$(MAKE) prebuild && $(MAKE) build-prod && $(MAKE) copy-env && \
38-
firebase deploy
62+
$(MAKE) prebuild
63+
$(MAKE) build-prod-sentry
64+
$(MAKE) copy-env
65+
firebase deploy
3966

4067
.PHONY: deploy-leaderboard
4168
deploy-leaderboard: ## Deploy the leaderboard application
42-
$(MAKE) prebuild && $(MAKE) build-prod && \
43-
cp dist/frontend/browser/assets/environments/leaderboard.js \
44-
dist/frontend/browser/assets/environments/env.js && \
45-
firebase deploy
69+
$(MAKE) prebuild
70+
$(MAKE) build-prod-sentry
71+
cp dist/frontend/browser/assets/environments/leaderboard.js \
72+
dist/frontend/browser/assets/environments/env.js
73+
firebase deploy
4674

4775
.PHONY: docker
4876
docker: ## Build and push Docker image
49-
$(MAKE) build-prod && \
50-
docker buildx build --platform linux/amd64 -t openmina/frontend:latest . && \
51-
docker push openmina/frontend:latest
77+
$(MAKE) build-prod-sentry
78+
docker buildx build --platform linux/amd64 -t openmina/frontend:latest .
79+
docker push openmina/frontend:latest
5280

5381
.PHONY: install
5482
install: ## Install npm dependencies
@@ -72,34 +100,49 @@ rebuild: clean install build ## Clean, reinstall dependencies, and rebuild
72100
.PHONY: sentry-sourcemaps
73101
sentry-sourcemaps: ## Upload sourcemaps to Sentry
74102
sentry-cli sourcemaps inject --org openmina-uv --project openmina \
75-
./dist/frontend/browser && \
76-
sentry-cli sourcemaps upload --org openmina-uv --project openmina \
103+
./dist/frontend/browser
104+
sentry-cli sourcemaps upload --org openmina-uv --project openmina \
77105
./dist/frontend/browser
78106

79107
.PHONY: start
80108
start: ## Start the development server
81-
npm install && ng serve --configuration local --open
109+
npm install
110+
npx ng serve --configuration local --open
82111

83112
.PHONY: start-bundle
84113
start-bundle: ## Serve the built bundle
85114
serve dist/frontend/browser -s -l 4200
86115

87-
.PHONY: start-dev
88-
start-dev: ## Start the development server (dev configuration)
89-
ng serve --configuration development
90-
91116
.PHONY: start-dev-mobile
92117
start-dev-mobile: ## Start the development server for mobile (accessible on network)
93-
ng serve --configuration development --host 0.0.0.0
118+
npx ng serve --configuration development --host 0.0.0.0
119+
120+
.PHONY: start-development
121+
start-development: ## Start the development server with development configuration
122+
npx ng serve --configuration development
94123

95124
.PHONY: start-fuzzing
96125
start-fuzzing: ## Start the fuzzing build and serve
97-
$(MAKE) install-deps && ng build --configuration fuzzing && \
98-
$(MAKE) start-bundle
126+
$(MAKE) install-deps
127+
npx ng build --configuration fuzzing
128+
$(MAKE) start-bundle
129+
130+
.PHONY: start-local
131+
start-local: ## Start the development server with local configuration
132+
npx ng serve --configuration local
133+
134+
.PHONY: start-production
135+
start-production: ## Start the development server with production configuration
136+
npx ng serve --configuration production
99137

100138
.PHONY: start-webnode
101139
start-webnode: ## Start the webnode development server
102-
npm install && ng serve --configuration webnodelocal --open
140+
npm install
141+
npx ng serve --configuration webnodelocal --open
142+
143+
.PHONY: start-webnodelocal
144+
start-webnodelocal: ## Start the development server with webnodelocal configuration
145+
npx ng serve --configuration webnodelocal
103146

104147
.PHONY: test
105148
test: ## Run Cypress tests

0 commit comments

Comments
 (0)