Skip to content

Commit bfb3ad1

Browse files
Merge branch 'fastapi:master' into refactor-status-code
2 parents 067169e + 3aad3fb commit bfb3ad1

14 files changed

+139
-32
lines changed

.github/workflows/issue-manager.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,5 +39,9 @@ jobs:
3939
"waiting": {
4040
"delay": 2628000,
4141
"message": "As this PR has been waiting for the original user for a while but seems to be inactive, it's now going to be closed. But if there's anyone interested, feel free to create a new PR."
42+
},
43+
"invalid": {
44+
"delay": 0,
45+
"message": "This was marked as invalid and will be closed now. If this is an error, please provide additional details."
4246
}
4347
}

.github/workflows/playwright.yml

Lines changed: 68 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,36 @@ on:
1616
default: 'false'
1717

1818
jobs:
19+
changes:
20+
runs-on: ubuntu-latest
21+
# Set job outputs to values from filter step
22+
outputs:
23+
changed: ${{ steps.filter.outputs.changed }}
24+
steps:
25+
- uses: actions/checkout@v4
26+
# For pull requests it's not necessary to checkout the code but for the main branch it is
27+
- uses: dorny/paths-filter@v3
28+
id: filter
29+
with:
30+
filters: |
31+
changed:
32+
- backend/**
33+
- frontend/**
34+
- .env
35+
- docker-compose*.yml
36+
- .github/workflows/playwright.yml
1937
20-
test:
38+
test-playwright:
39+
needs:
40+
- changes
41+
if: ${{ needs.changes.outputs.changed == 'true' }}
2142
timeout-minutes: 60
2243
runs-on: ubuntu-latest
44+
strategy:
45+
matrix:
46+
shardIndex: [1, 2, 3, 4]
47+
shardTotal: [4]
48+
fail-fast: false
2349
steps:
2450
- uses: actions/checkout@v4
2551
- uses: actions/setup-node@v4
@@ -33,35 +59,61 @@ jobs:
3359
if: ${{ github.event_name == 'workflow_dispatch' && github.event.inputs.debug_enabled == 'true' }}
3460
with:
3561
limit-access-to-actor: true
36-
- name: Install dependencies
37-
run: npm ci
38-
working-directory: frontend
39-
- name: Install Playwright Browsers
40-
run: npx playwright install --with-deps
41-
working-directory: frontend
4262
- run: docker compose build
4363
- run: docker compose down -v --remove-orphans
44-
- run: docker compose up -d --wait backend mailcatcher
4564
- name: Run Playwright tests
46-
run: npx playwright test --fail-on-flaky-tests --trace=retain-on-failure
47-
working-directory: frontend
65+
run: docker compose run --rm playwright npx playwright test --fail-on-flaky-tests --trace=retain-on-failure --shard=${{ matrix.shardIndex }}/${{ matrix.shardTotal }}
4866
- run: docker compose down -v --remove-orphans
49-
- uses: actions/upload-artifact@v4
50-
if: always()
67+
- name: Upload blob report to GitHub Actions Artifacts
68+
if: ${{ !cancelled() }}
69+
uses: actions/upload-artifact@v4
70+
with:
71+
name: blob-report-${{ matrix.shardIndex }}
72+
path: frontend/blob-report
73+
include-hidden-files: true
74+
retention-days: 1
75+
76+
merge-playwright-reports:
77+
needs:
78+
- test-playwright
79+
- changes
80+
# Merge reports after playwright-tests, even if some shards have failed
81+
if: ${{ !cancelled() && needs.changes.outputs.changed == 'true' }}
82+
runs-on: ubuntu-latest
83+
steps:
84+
- uses: actions/checkout@v4
85+
- uses: actions/setup-node@v4
86+
with:
87+
node-version: 20
88+
- name: Install dependencies
89+
run: npm ci
90+
working-directory: frontend
91+
- name: Download blob reports from GitHub Actions Artifacts
92+
uses: actions/download-artifact@v4
93+
with:
94+
path: frontend/all-blob-reports
95+
pattern: blob-report-*
96+
merge-multiple: true
97+
- name: Merge into HTML Report
98+
run: npx playwright merge-reports --reporter html ./all-blob-reports
99+
working-directory: frontend
100+
- name: Upload HTML report
101+
uses: actions/upload-artifact@v4
51102
with:
52-
name: playwright-report
53-
path: frontend/playwright-report/
103+
name: html-report--attempt-${{ github.run_attempt }}
104+
path: frontend/playwright-report
54105
retention-days: 30
55106
include-hidden-files: true
56107

57108
# https://github.com/marketplace/actions/alls-green#why
58-
e2e-alls-green: # This job does nothing and is only used for the branch protection
109+
alls-green-playwright: # This job does nothing and is only used for the branch protection
59110
if: always()
60111
needs:
61-
- test
112+
- test-playwright
62113
runs-on: ubuntu-latest
63114
steps:
64115
- name: Decide whether the needed jobs succeeded or failed
65116
uses: re-actors/alls-green@release/v1
66117
with:
67118
jobs: ${{ toJSON(needs) }}
119+
allowed-skips: test-playwright

.github/workflows/test-docker-compose.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ jobs:
1818
uses: actions/checkout@v4
1919
- run: docker compose build
2020
- run: docker compose down -v --remove-orphans
21-
- run: docker compose up -d --wait
21+
- run: docker compose up -d --wait backend frontend adminer
2222
- name: Test backend is up
2323
run: curl http://localhost:8000/api/v1/utils/health-check
2424
- name: Test frontend is up

deployment.md

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -183,22 +183,22 @@ There are already two environments configured, `staging` and `production`. 🚀
183183

184184
### Install GitHub Actions Runner
185185

186-
* On your remote server, if you are running as the `root` user, create a user for your GitHub Actions:
186+
* On your remote server, create a user for your GitHub Actions:
187187

188188
```bash
189-
adduser github
189+
sudo adduser github
190190
```
191191

192192
* Add Docker permissions to the `github` user:
193193

194194
```bash
195-
usermod -aG docker github
195+
sudo usermod -aG docker github
196196
```
197197

198198
* Temporarily switch to the `github` user:
199199

200200
```bash
201-
su - github
201+
sudo su - github
202202
```
203203

204204
* Go to the `github` user's home directory:
@@ -219,9 +219,15 @@ To make sure it runs on startup and continues running, you can install it as a s
219219
exit
220220
```
221221

222-
After you do it, you would be on the `root` user again. And you will be on the previous directory, belonging to the `root` user.
222+
After you do it, you will be on the previous user again. And you will be on the previous directory, belonging to that user.
223223

224-
* Go to the `actions-runner` directory inside of the `github` user's home directory:
224+
Before being able to go the `github` user directory, you need to become the `root` user (you might already be):
225+
226+
```bash
227+
sudo su
228+
```
229+
230+
* As the `root` user, go to the `actions-runner` directory inside of the `github` user's home directory:
225231

226232
```bash
227233
cd /home/github/actions-runner

docker-compose.override.yml

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,31 @@ services:
102102
- VITE_API_URL=http://localhost:8000
103103
- NODE_ENV=development
104104

105+
playwright:
106+
build:
107+
context: ./frontend
108+
dockerfile: Dockerfile.playwright
109+
args:
110+
- VITE_API_URL=http://backend:8000
111+
- NODE_ENV=production
112+
ipc: host
113+
depends_on:
114+
- backend
115+
- mailcatcher
116+
env_file:
117+
- .env
118+
environment:
119+
- VITE_API_URL=http://backend:8000
120+
- MAILCATCHER_HOST=http://mailcatcher:1080
121+
# For the reports when run locally
122+
- PLAYWRIGHT_HTML_HOST=0.0.0.0
123+
- CI=${CI}
124+
volumes:
125+
- ./frontend/blob-report:/app/blob-report
126+
- ./frontend/test-results:/app/test-results
127+
ports:
128+
- 9323:9323
129+
105130
networks:
106131
traefik-public:
107132
# For local dev, don't expect an external Traefik network

frontend/.env

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
VITE_API_URL=http://localhost:8000
2+
MAILCATCHER_HOST=http://localhost:1080

frontend/Dockerfile.playwright

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
FROM node:20
2+
3+
WORKDIR /app
4+
5+
COPY package*.json /app/
6+
7+
RUN npm install
8+
9+
RUN npx -y playwright install --with-deps
10+
11+
COPY ./ /app/
12+
13+
ARG VITE_API_URL=${VITE_API_URL}

frontend/playwright.config.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
11
import { defineConfig, devices } from '@playwright/test';
2-
2+
import 'dotenv/config'
33

44
/**
55
* Read environment variables from file.
66
* https://github.com/motdotla/dotenv
77
*/
8-
// require('dotenv').config();
98

109
/**
1110
* See https://playwright.dev/docs/test-configuration.
@@ -21,7 +20,7 @@ export default defineConfig({
2120
/* Opt out of parallel tests on CI. */
2221
workers: process.env.CI ? 1 : undefined,
2322
/* Reporter to use. See https://playwright.dev/docs/test-reporters */
24-
reporter: 'html',
23+
reporter: process.env.CI ? 'blob' : 'html',
2524
/* Shared settings for all the projects below. See https://playwright.dev/docs/api/class-testoptions. */
2625
use: {
2726
/* Base URL to use in actions like `await page.goto('/')`. */

frontend/src/routes/_layout/admin.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ function UsersTable() {
4949
const { page } = Route.useSearch()
5050
const navigate = useNavigate({ from: Route.fullPath })
5151
const setPage = (page: number) =>
52-
navigate({ search: (prev) => ({ ...prev, page }) })
52+
navigate({ search: (prev: {[key: string]: string}) => ({ ...prev, page }) })
5353

5454
const {
5555
data: users,

frontend/src/routes/_layout/items.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ function ItemsTable() {
4545
const { page } = Route.useSearch()
4646
const navigate = useNavigate({ from: Route.fullPath })
4747
const setPage = (page: number) =>
48-
navigate({ search: (prev) => ({ ...prev, page }) })
48+
navigate({ search: (prev: {[key: string]: string}) => ({ ...prev, page }) })
4949

5050
const {
5151
data: items,

0 commit comments

Comments
 (0)