Skip to content

Commit 8a4ac6e

Browse files
Merge pull request #2 from refactorfirst/migrate-to-nextjs
Migrate to NextJS static page app
2 parents 1fbda6d + 932563c commit 8a4ac6e

120 files changed

Lines changed: 7365 additions & 495 deletions

File tree

Some content is hidden

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

‎.eslintrc.json‎

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,25 @@
66
},
77
"parserOptions": {
88
"ecmaVersion": 2022,
9-
"sourceType": "module"
9+
"sourceType": "module",
10+
"ecmaFeatures": { "jsx": true }
11+
},
12+
"extends": [
13+
"eslint:recommended",
14+
"plugin:react/recommended",
15+
"plugin:react/jsx-runtime",
16+
"plugin:react-hooks/recommended"
17+
],
18+
"settings": {
19+
"react": { "version": "detect" }
20+
},
21+
"globals": {
22+
"process": "readonly"
1023
},
11-
"extends": "eslint:recommended",
1224
"rules": {
1325
"no-unused-vars": ["error", { "argsIgnorePattern": "^_" }],
14-
"no-console": ["warn", { "allow": ["warn", "error"] }]
26+
"no-console": ["warn", { "allow": ["warn", "error"] }],
27+
"react/prop-types": "off"
1528
},
16-
"ignorePatterns": ["node_modules/", "playwright-report/", "test-results/"]
29+
"ignorePatterns": ["node_modules/", "playwright-report/", "test-results/", ".next/", "out/", "public/widgets/"]
1730
}
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
name: Deploy Repositories Fast Path
2+
3+
# Fast feedback loop for submissions (Technical Appendix §5 Option 3):
4+
# runs right after the Add Repository workflow, uploads repositories.txt
5+
# as an artifact and comments the expected availability time on the issue.
6+
7+
on:
8+
workflow_run:
9+
workflows: ["Add Repository"]
10+
types: [completed]
11+
workflow_dispatch:
12+
13+
permissions:
14+
contents: read
15+
issues: write
16+
17+
concurrency:
18+
group: "repositories-fast-path"
19+
cancel-in-progress: false
20+
21+
jobs:
22+
notify-fast-path:
23+
runs-on: ubuntu-latest
24+
steps:
25+
- name: Checkout repository
26+
uses: actions/checkout@v4
27+
28+
- name: Upload repositories.txt snapshot
29+
uses: actions/upload-artifact@v4
30+
with:
31+
name: current-listing
32+
path: repositories.txt
33+
retention-days: 5
34+
35+
- name: Log availability message
36+
run: |
37+
echo "repositories.txt snapshot uploaded."
38+
echo "Report pages are generated by the cached Pages deployment; the newly"
39+
echo "submitted repository renders client-side from raw content immediately,"
40+
echo "and its static shell appears once the Pages build completes."

‎.github/workflows/redeploy.yml‎

Lines changed: 37 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,13 @@ permissions:
99
pages: write
1010
id-token: write
1111

12+
# Redeployment when repositories.txt changed recently. The build is cached
13+
# (actions/cache on .next/cache) to hit the <6 minute target.
1214
jobs:
13-
check-and-deploy:
15+
check:
1416
runs-on: ubuntu-latest
17+
outputs:
18+
changed: ${{ steps.check-changes.outputs.changed }}
1519
steps:
1620
- name: Checkout repository
1721
uses: actions/checkout@v4
@@ -36,17 +40,41 @@ jobs:
3640
echo "No recent changes, skipping deployment"
3741
fi
3842
39-
- name: Setup Pages
40-
if: steps.check-changes.outputs.changed == 'true'
41-
uses: actions/configure-pages@v4
42-
43+
build:
44+
needs: check
45+
if: needs.check.outputs.changed == 'true'
46+
runs-on: ubuntu-latest
47+
steps:
48+
- uses: actions/checkout@v4
49+
- uses: oven-sh/setup-bun@v1
50+
with:
51+
bun-version: latest
52+
- uses: actions/setup-node@v4
53+
with:
54+
node-version: 22
55+
- name: Cache .next build cache
56+
uses: actions/cache@v4
57+
with:
58+
path: .next/cache
59+
key: ${{ runner.os }}-nextjs-${{ hashFiles('**/bun.lock', '**/package.json') }}-${{ github.run_id }}
60+
restore-keys: ${{ runner.os }}-nextjs-${{ hashFiles('**/bun.lock', '**/package.json') }}-
61+
- run: bun install
62+
- name: Build static export
63+
run: bun run build
64+
env:
65+
NEXT_PUBLIC_HOSTING_ENVIRONMENT: github
4366
- name: Upload artifact
44-
if: steps.check-changes.outputs.changed == 'true'
4567
uses: actions/upload-pages-artifact@v3
4668
with:
47-
path: '.'
69+
path: 'out'
4870

71+
deploy:
72+
needs: build
73+
environment:
74+
name: github-pages
75+
url: ${{ steps.deployment.outputs.page_url }}
76+
runs-on: ubuntu-latest
77+
steps:
4978
- name: Deploy to GitHub Pages
50-
if: steps.check-changes.outputs.changed == 'true'
5179
id: deployment
52-
uses: actions/deploy-pages@v4
80+
uses: actions/deploy-pages@v5

‎.github/workflows/static.yml‎

Lines changed: 32 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
# Simple workflow for deploying static content to GitHub Pages
2-
name: Deploy static content to Pages
1+
# Build the Next.js static export and deploy out/ to GitHub Pages
2+
name: Build and deploy Next.js export to Pages
33

44
on:
55
# Runs on pushes targeting the default branch
@@ -22,22 +22,43 @@ concurrency:
2222
cancel-in-progress: false
2323

2424
jobs:
25-
# Single deploy job since we're just deploying
26-
deploy:
27-
environment:
28-
name: github-pages
29-
url: ${{ steps.deployment.outputs.page_url }}
25+
build:
3026
runs-on: ubuntu-latest
27+
outputs:
28+
artifact-path: out
3129
steps:
3230
- name: Checkout
3331
uses: actions/checkout@v4
34-
- name: Setup Pages
35-
uses: actions/configure-pages@v5
32+
- uses: oven-sh/setup-bun@v1
33+
with:
34+
bun-version: latest
35+
- uses: actions/setup-node@v4
36+
with:
37+
node-version: 22
38+
- name: Cache .next build cache
39+
uses: actions/cache@v4
40+
with:
41+
path: .next/cache
42+
key: ${{ runner.os }}-nextjs-${{ hashFiles('**/bun.lock', '**/package.json') }}-${{ github.run_id }}
43+
restore-keys: ${{ runner.os }}-nextjs-${{ hashFiles('**/bun.lock', '**/package.json') }}-
44+
- name: Install dependencies
45+
run: bun install
46+
- name: Build static export
47+
run: bun run build
48+
env:
49+
NEXT_PUBLIC_HOSTING_ENVIRONMENT: github
3650
- name: Upload artifact
3751
uses: actions/upload-pages-artifact@v3
3852
with:
39-
# Upload entire repository
40-
path: '.'
53+
path: 'out'
54+
55+
deploy:
56+
needs: build
57+
environment:
58+
name: github-pages
59+
url: ${{ steps.deployment.outputs.page_url }}
60+
runs-on: ubuntu-latest
61+
steps:
4162
- name: Deploy to GitHub Pages
4263
id: deployment
4364
uses: actions/deploy-pages@v5

‎.github/workflows/test.yml‎

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,13 @@ jobs:
1111
bun-version: latest
1212
- run: bun install
1313
- run: bun test tests/unit tests/integration
14-
- run: bunx eslint "js/**/*.js" "tests/**/*.js"
14+
- run: bunx eslint "lib/**/*.js" "app/**/*.{js,jsx}" "components/**/*.{js,jsx}" "tests/**/*.{js,jsx}"
1515
- run: shellcheck ci/process-submissions.sh
1616

1717
e2e-tests:
1818
# Matrix execution: one runner per browser so the suites run in parallel.
19+
# The Playwright webServer builds the static export (bun run build) and
20+
# serves ./out with GitHub Pages semantics (scripts/serve-out.py).
1921
strategy:
2022
fail-fast: false
2123
matrix:
@@ -35,3 +37,21 @@ jobs:
3537
name: playwright-report-${{ matrix.browser }}
3638
path: playwright-report/
3739
retention-days: 7
40+
41+
e2e-basepath:
42+
# Sub-path deployment leg (GitHub Pages project sites): NEXT_PUBLIC_BASE_PATH
43+
runs-on: ubuntu-latest
44+
steps:
45+
- uses: actions/checkout@v4
46+
- uses: oven-sh/setup-bun@v1
47+
with:
48+
bun-version: latest
49+
- run: bun install
50+
- run: bunx playwright install --with-deps chromium
51+
- run: bunx playwright test --config playwright.basepath.config.js
52+
- uses: actions/upload-artifact@v4
53+
if: failure()
54+
with:
55+
name: playwright-report-basepath
56+
path: playwright-report/
57+
retention-days: 7

‎.gitignore‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ pnpm-lock.yaml
1717
dist/
1818
build/
1919
out/
20+
.next/
2021
*.tsbuildinfo
2122

2223
# Test coverage and reports

‎.gitlab-ci.yml‎

Lines changed: 30 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -1,49 +1,40 @@
1-
# GitLab CI configuration for this RefactorFirst Pages site.
2-
#
3-
# Deploys the static files to GitLab Pages. A copy of index.html is published as
4-
# 404.html so client-side routes like /user/repo serve the application instead of
5-
# GitLab's generic 404 page.
1+
# GitLab Pages deployment for the RefactorFirst Pages app.
2+
# Deploys the Next.js static export (out/) as public/ for GitLab Pages.
63

74
stages:
8-
- test
9-
- process
10-
- deploy
11-
12-
validate-site:
13-
stage: test
14-
image: alpine:3.20
15-
script:
16-
- test -f index.html
17-
- test -f repositories.txt
18-
- sort -c repositories.txt
19-
- '! grep -Ev "^[A-Za-z0-9][A-Za-z0-9_.-]*/[A-Za-z0-9][A-Za-z0-9_.-]*$" repositories.txt'
20-
rules:
21-
- if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH
22-
23-
# Processes open "Add repository: owner/repo" issues: validates the issue
24-
# author has write access to the project, checks the report file exists,
25-
# commits repositories.txt and closes the issue with the outcome.
26-
# GitLab has no issue-triggered pipelines, so create a pipeline schedule
27-
# (e.g. every 10 minutes) in Settings -> CI/CD -> Schedules.
28-
process-submissions:
29-
stage: process
30-
image: alpine:3.20
31-
before_script:
32-
- apk add --no-cache curl jq
33-
script:
34-
- sh ci/process-submissions.sh gitlab
35-
rules:
36-
- if: $CI_PIPELINE_SOURCE == "schedule"
5+
- build
376

387
pages:
39-
stage: deploy
40-
image: alpine:3.20
8+
stage: build
9+
image: node:22
10+
before_script:
11+
- npm install -g bun
4112
script:
42-
- mkdir -p public
43-
- cp -r index.html repositories.txt css js templates assets public/
44-
- cp index.html public/404.html # client-side routing for deep links
13+
- bun install
14+
- NEXT_PUBLIC_HOSTING_ENVIRONMENT=gitlab bun run build
15+
- rm -rf public
16+
- mkdir public
17+
- cp -r out/. public/
4518
artifacts:
4619
paths:
4720
- public
21+
cache:
22+
key:
23+
files:
24+
- bun.lock
25+
paths:
26+
- .next/cache
4827
rules:
4928
- if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH
29+
30+
test:
31+
stage: build
32+
image: node:22
33+
before_script:
34+
- npm install -g bun
35+
script:
36+
- bun install
37+
- bun test tests/unit tests/integration
38+
rules:
39+
- if: $CI_PIPELINE_SOURCE == 'merge_request_event'
40+
- if: $CI_COMMIT_BRANCH != $CI_DEFAULT_BRANCH

0 commit comments

Comments
 (0)