Skip to content

Commit 5ba8f5d

Browse files
authored
Merge pull request #1457 from o1-labs/dw/run-prettify-web-code
Frontend: set standard for code formatting with `prettier`
2 parents 5dd9e36 + 9a8ea47 commit 5ba8f5d

File tree

550 files changed

+18774
-10204
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

550 files changed

+18774
-10204
lines changed
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
name: 'Frontend Build'
2+
description: 'Build and test frontend application'
3+
inputs:
4+
run-prettier-check:
5+
description: 'Whether to run prettier check'
6+
required: false
7+
default: 'false'
8+
run-tests:
9+
description: 'Whether to run Cypress tests'
10+
required: false
11+
default: 'false'
12+
node-version:
13+
description: 'Node.js version to use'
14+
required: false
15+
default: '23'
16+
17+
runs:
18+
using: 'composite'
19+
steps:
20+
- name: Setup Node.js
21+
uses: actions/setup-node@v4
22+
with:
23+
node-version: ${{ inputs.node-version }}
24+
25+
- name: Install dependencies
26+
run: npm ci
27+
working-directory: frontend
28+
shell: bash
29+
30+
- name: Verify prettier installation
31+
if: inputs.run-prettier-check == 'true'
32+
run: npx prettier --version
33+
working-directory: frontend
34+
shell: bash
35+
36+
- name: Check code formatting with Prettier
37+
if: inputs.run-prettier-check == 'true'
38+
run: make check-prettify
39+
working-directory: frontend
40+
shell: bash
41+
42+
- name: Build frontend
43+
run: npm run build
44+
working-directory: frontend
45+
shell: bash
46+
47+
- name: Run tests
48+
if: inputs.run-tests == 'true'
49+
uses: cypress-io/github-action@v6
50+
with:
51+
working-directory: frontend
52+
start: npm start
53+
wait-on: http://localhost:4200
54+
wait-on-timeout: 180s
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
name: Frontend macOS 13
2+
3+
on:
4+
push:
5+
branches: [main, develop]
6+
workflow_dispatch:
7+
8+
concurrency:
9+
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
10+
cancel-in-progress: true
11+
12+
jobs:
13+
frontend:
14+
runs-on: macos-13
15+
steps:
16+
- name: Git checkout
17+
uses: actions/checkout@v5
18+
19+
- name: Frontend build
20+
uses: ./.github/actions/frontend-build
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
name: Frontend macOS 14
2+
3+
on:
4+
push:
5+
branches: [main, develop]
6+
workflow_dispatch:
7+
8+
concurrency:
9+
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
10+
cancel-in-progress: true
11+
12+
jobs:
13+
frontend:
14+
runs-on: macos-14
15+
steps:
16+
- name: Git checkout
17+
uses: actions/checkout@v5
18+
19+
- name: Frontend build
20+
uses: ./.github/actions/frontend-build
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
name: Frontend macOS 15
2+
3+
on:
4+
push:
5+
branches: [main, develop]
6+
workflow_dispatch:
7+
8+
concurrency:
9+
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
10+
cancel-in-progress: true
11+
12+
jobs:
13+
frontend:
14+
runs-on: macos-15
15+
steps:
16+
- name: Git checkout
17+
uses: actions/checkout@v5
18+
19+
- name: Frontend build
20+
uses: ./.github/actions/frontend-build
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
name: Frontend macOS latest
2+
3+
on:
4+
push:
5+
branches: [main, develop]
6+
workflow_dispatch:
7+
8+
concurrency:
9+
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
10+
cancel-in-progress: true
11+
12+
jobs:
13+
frontend:
14+
runs-on: macos-latest
15+
steps:
16+
- name: Git checkout
17+
uses: actions/checkout@v5
18+
19+
- name: Frontend build
20+
uses: ./.github/actions/frontend-build
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
name: Frontend Ubuntu 22.04
2+
3+
on:
4+
push:
5+
branches: [main, develop]
6+
workflow_dispatch:
7+
8+
concurrency:
9+
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
10+
cancel-in-progress: true
11+
12+
jobs:
13+
frontend:
14+
runs-on: ubuntu-22.04
15+
steps:
16+
- name: Git checkout
17+
uses: actions/checkout@v5
18+
19+
- name: Frontend build
20+
uses: ./.github/actions/frontend-build
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
name: Frontend Ubuntu 24.04 ARM
2+
3+
on:
4+
push:
5+
branches: [main, develop]
6+
workflow_dispatch:
7+
8+
concurrency:
9+
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
10+
cancel-in-progress: true
11+
12+
jobs:
13+
frontend:
14+
runs-on: ubuntu-24.04-arm
15+
steps:
16+
- name: Git checkout
17+
uses: actions/checkout@v5
18+
19+
- name: Frontend build
20+
uses: ./.github/actions/frontend-build

.github/workflows/frontend.yaml

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -11,19 +11,14 @@ concurrency:
1111
cancel-in-progress: true
1212

1313
jobs:
14-
frontend-test:
14+
frontend:
1515
runs-on: ubuntu-24.04
1616
steps:
1717
- name: Git checkout
1818
uses: actions/checkout@v5
19-
with:
20-
sparse-checkout: |
21-
frontend
2219

23-
- name: Run tests
24-
uses: cypress-io/github-action@v6
20+
- name: Frontend build and test
21+
uses: ./.github/actions/frontend-build
2522
with:
26-
working-directory: frontend
27-
start: npm start
28-
wait-on: http://localhost:4200
29-
wait-on-timeout: 180s
23+
run-prettier-check: 'true'
24+
run-tests: 'true'

frontend/.prettierrc.json

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
{
2+
"printWidth": 80,
3+
"tabWidth": 2,
4+
"useTabs": false,
5+
"semi": true,
6+
"singleQuote": true,
7+
"quoteProps": "as-needed",
8+
"jsxSingleQuote": false,
9+
"trailingComma": "all",
10+
"bracketSpacing": true,
11+
"bracketSameLine": false,
12+
"arrowParens": "avoid",
13+
"proseWrap": "preserve",
14+
"htmlWhitespaceSensitivity": "css",
15+
"endOfLine": "lf",
16+
"overrides": [
17+
{
18+
"files": "**/*.html",
19+
"options": {
20+
"parser": "angular",
21+
"printWidth": 80,
22+
"bracketSameLine": false,
23+
"htmlWhitespaceSensitivity": "ignore",
24+
"singleAttributePerLine": false
25+
}
26+
}
27+
]
28+
}

frontend/Makefile

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
# Frontend Makefile
2+
3+
.PHONY: help
4+
help: ## Display this help message
5+
@echo "Frontend Makefile - Available targets:"
6+
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-20s\033[0m %s\n", $$1, $$2}'
7+
8+
.PHONY: install
9+
install: ## Install npm dependencies
10+
npm install
11+
12+
.PHONY: prettify
13+
prettify: ## Format HTML, SCSS, TypeScript, and JavaScript files with Prettier
14+
npx prettier --write 'src/**/*.{ts,js,html,scss,css,json}'
15+
16+
.PHONY: check-prettify
17+
check-prettify: ## Check if files are formatted with Prettier
18+
npx prettier --check 'src/**/*.{ts,js,html,scss,css,json}'
19+
20+
.PHONY: start
21+
start: ## Start the development server
22+
npm start
23+
24+
.PHONY: build
25+
build: ## Build the frontend for production
26+
npm run build:prod
27+
28+
.PHONY: test
29+
test: ## Run Cypress tests
30+
npm run tests
31+
32+
.PHONY: test-headless
33+
test-headless: ## Run Cypress tests in headless mode
34+
npm run tests:headless
35+
36+
.PHONY: clean
37+
clean: ## Clean build artifacts and node_modules
38+
rm -rf dist node_modules
39+
40+
.PHONY: rebuild
41+
rebuild: clean install build ## Clean, reinstall dependencies, and rebuild

0 commit comments

Comments
 (0)