Skip to content
This repository has been archived by the owner on Nov 26, 2024. It is now read-only.

CIの追加 #7

Merged
merged 47 commits into from
Aug 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
47 commits
Select commit Hold shift + click to select a range
cff92fe
deps: install biome
claustra01 Aug 9, 2024
7371f57
fix: biome check error
claustra01 Aug 9, 2024
68fd2da
add: lint and check ci
claustra01 Aug 9, 2024
3155ca9
fix: yaml format
claustra01 Aug 9, 2024
dc0be66
deps: install cspell
claustra01 Aug 9, 2024
ff90deb
add: spell and build ci
claustra01 Aug 9, 2024
285689a
chore: add job needs
claustra01 Aug 9, 2024
096469d
chore: add \n
claustra01 Aug 9, 2024
c16d724
add: lighthouse ci
claustra01 Aug 9, 2024
ed0ba0a
fix: firebase.json
claustra01 Aug 9, 2024
6955bf0
fix: lighthouse deploy ci
claustra01 Aug 9, 2024
0d516d9
add: lighthouse ci
claustra01 Aug 9, 2024
5c965cf
add: analyze ci
claustra01 Aug 9, 2024
f050a7e
chore: remove ci deps
claustra01 Aug 9, 2024
5ad07e3
fix: ci permissions
claustra01 Aug 9, 2024
f516a1c
fix: lighthouse check url
claustra01 Aug 9, 2024
b504238
fix: lighthouse ci
claustra01 Aug 9, 2024
32d999f
fix: ci permission
claustra01 Aug 9, 2024
949b42c
add: visualizer ci
claustra01 Aug 9, 2024
aac2ec0
chore: yaml padding
claustra01 Aug 9, 2024
a0a695a
fix: visualizer ci
claustra01 Aug 9, 2024
c3d2b01
fix: publish branch
claustra01 Aug 9, 2024
ab5b663
test
claustra01 Aug 9, 2024
c469887
test
claustra01 Aug 9, 2024
19d1cfd
test
claustra01 Aug 9, 2024
b63ab38
test
claustra01 Aug 9, 2024
ab80dc4
test
claustra01 Aug 9, 2024
c3c4673
test
claustra01 Aug 9, 2024
34a2f26
test
claustra01 Aug 9, 2024
3c48ea2
test
claustra01 Aug 9, 2024
e68e902
test
claustra01 Aug 9, 2024
d2b6707
test
claustra01 Aug 9, 2024
43a4861
test
claustra01 Aug 9, 2024
a1973a1
chore: ci update comment
claustra01 Aug 9, 2024
7137135
fix: lighthouse ci body
claustra01 Aug 9, 2024
7301d19
test
claustra01 Aug 9, 2024
0c4c2c1
fix: replace comment
claustra01 Aug 9, 2024
3b12cc6
test
claustra01 Aug 9, 2024
e0d89d5
test
claustra01 Aug 9, 2024
cbfe8d9
test
claustra01 Aug 9, 2024
3d46a2e
test
claustra01 Aug 9, 2024
03b77ce
test
claustra01 Aug 9, 2024
c77f122
add: update visualizer comment
claustra01 Aug 10, 2024
eb92680
fix: update comment issue number
claustra01 Aug 10, 2024
1c734a2
test
claustra01 Aug 10, 2024
0dc0cac
deps: pin node version
claustra01 Aug 10, 2024
c381971
add: ci condition
claustra01 Aug 10, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 33 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
name: ci

on:
push:

jobs:
check:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4
- run: |
npm install
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

pnpmのプロジェクトならCIでもnpm使うのが一般的では?
pnpmは依存の解決が他とちょっと違うから、そこまで担保できているか不安

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

pnpmに変えたら全部落ちたが
voltaでpnpm使ってる(voltaのpnpmはまだbeta)からだと思われ

npm run check:ci

spell:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4
- run: |
npm install
npm run spell

build:
needs: [check, spell]
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4
- run: |
npm install
npm run build
91 changes: 91 additions & 0 deletions .github/workflows/pr-lighthouse.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
name: pr-lighthouse

on:
pull_request:
types: [opened]
workflow_dispatch:

permissions:
checks: write
pull-requests: write

jobs:
deploy:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4
- run: |
npm install
npm run build

- uses: FirebaseExtended/action-hosting-deploy@v0
with:
repoToken: ${{ secrets.GITHUB_TOKEN }}
firebaseServiceAccount: ${{ secrets.FIREBASE_SERVICE_ACCOUNT_VIRTUAL_NATSUMATSURI }}
channelId: live
projectId: virtual-natsumatsuri

lighthouse:
needs: deploy
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4

- name: Lighthouse CI
uses: treosh/lighthouse-ci-action@v10
id: lighthouse
with:
uploadArtifacts: true
temporaryPublicStorage: true
urls: https://virtual-natsumatsuri.web.app/

- name: Get Comment Body
uses: actions/github-script@v5
id: get-comment-body
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
const results = ${{ steps.lighthouse.outputs.manifest }}
const links = ${{ steps.lighthouse.outputs.links }}
const mark = (value) => {
if (value >= 0.9) {
return '🟢';
} else if (value >= 0.5) {
return '🟡';
} else {
return '🔴';
}
};
const body = `
# Lighthouse Report
| URL | Performance | Accessibility | Best Practices | SEO | PWA | Details |
| --- | ----------- | ------------- | -------------- | --- | --- | ------- |
${results.map((result) => `| ${result.url} | ${mark(result.summary.performance)}${Math.trunc(result.summary.performance * 100)} | ${mark(result.summary.accessibility)}${Math.trunc(result.summary.accessibility * 100)} | ${mark(result.summary['best-practices'])}${Math.trunc(result.summary['best-practices'] * 100)} | ${mark(result.summary.seo)}${Math.trunc(result.summary.seo * 100)} | ${mark(result.summary.pwa)}${Math.trunc(result.summary.pwa * 100)} | :pencil: [result](${links[result.url]}) |`).join('\n')}
`;
core.setOutput("body", body)

- name: Find Comment
uses: peter-evans/find-comment@v2
if: success() && github.event.number
id: fc
with:
issue-number: ${{ github.event.number }}
includes-comment: "# Lighthouse Report"

- name: Create Comment
uses: peter-evans/create-or-update-comment@v2
if: success() && github.event.number && steps.fc.outputs.comment-id == 0
with:
issue-number: ${{ github.event.number }}
body: ${{ steps.get-comment-body.outputs.body }}

- name: Update Comment
uses: peter-evans/create-or-update-comment@v2
if: success() && github.event.number && steps.fc.outputs.comment-id != 0
with:
issue-number: ${{ github.event.number }}
comment-id: ${{ steps.fc.outputs.comment-id }}
body: ${{ steps.get-comment-body.outputs.body }}
edit-mode: replace
63 changes: 63 additions & 0 deletions .github/workflows/pr-visualizer.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
name: pr-visualizer

on:
pull_request:
types: [opened]
workflow_dispatch:

permissions:
pull-requests: write
contents: read
pages: write
id-token: write

jobs:
visualizer:
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Install and Build
run: |
npm install
npm run build

- name: Upload artifact
uses: actions/upload-pages-artifact@v3
with:
path: ./dist/visualizer/

- name: Deploy to GitHub Pages
uses: actions/deploy-pages@v4
id: deployment
with:
branch: ${{ github.head_ref }}

- name: Find existing comment
uses: peter-evans/find-comment@v2
id: fc
with:
issue-number: ${{ github.event.number }}
body-includes: '# Visualizer Report'

- name: Create comment
uses: peter-evans/create-or-update-comment@v2
if: success() && github.event.number && steps.fc.outputs.comment-id == 0
with:
issue-number: ${{ github.event.number }}
body: |
# Visualizer Report
You can view the results [here](${{ steps.deployment.outputs.page_url }}).

- name: Update comment
uses: peter-evans/create-or-update-comment@v2
if: success() && github.event.number && steps.fc.outputs.comment-id != 0
with:
issue-number: ${{ github.event.number }}
comment-id: ${{ steps.fc.outputs.comment-id }}
body: |
# Visualizer Report
You can view the results [here](${{ steps.deployment.outputs.page_url }}).
edit-mode: replace
12 changes: 12 additions & 0 deletions biome.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"$schema": "https://biomejs.dev/schemas/1.8.3/schema.json",
"organizeImports": {
"enabled": true
},
"linter": {
"enabled": true,
"rules": {
"recommended": true
}
}
}
3 changes: 3 additions & 0 deletions cspell.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"ignorePaths": ["node_modules/**", "*.svg"]
}
13 changes: 11 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,22 +7,31 @@
"dev": "vite",
"build": "tsc -b && vite build",
"lint": "eslint . --ext ts,tsx --report-unused-disable-directives --max-warnings 0",
"preview": "vite preview"
"preview": "vite preview",
"check": "biome check ./src --write",
"check:ci": "biome check ./src",
"spell": "cspell ./src"
},
"dependencies": {
"react": "^18.3.1",
"react-dom": "^18.3.1"
},
"devDependencies": {
"@biomejs/biome": "1.8.3",
"@types/react": "^18.3.3",
"@types/react-dom": "^18.3.0",
"@typescript-eslint/eslint-plugin": "^7.15.0",
"@typescript-eslint/parser": "^7.15.0",
"@vitejs/plugin-react-swc": "^3.5.0",
"cspell": "8.13.2",
"eslint": "^8.57.0",
"eslint-plugin-react-hooks": "^4.6.2",
"eslint-plugin-react-refresh": "^0.4.7",
"rollup-plugin-visualizer": "^5.12.0",
"typescript": "^5.2.2",
"vite": "^5.3.4"
},
"volta": {
"node": "22.5.1"
}
}
}
Loading