Skip to content

Commit

Permalink
feat: ci updates (#5)
Browse files Browse the repository at this point in the history
* docs: readme update

* perf: move some packages to devdeps

* chore: format

* chore: add prettier to lint script

* chore: add vscode settings

* ci: add lighthouse and lint build workflows

* ci: setup husky and lint staged

* ci: add gh codeowners file

* ci: setup commitlint
  • Loading branch information
secondl1ght authored Jul 3, 2024
1 parent 6445ebf commit 5f305bc
Show file tree
Hide file tree
Showing 20 changed files with 1,436 additions and 79 deletions.
3 changes: 2 additions & 1 deletion .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@ node_modules
.git
.next
.env
.github
.github
.husky
2 changes: 2 additions & 0 deletions .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Global rule:
* @apotdevin @secondl1ght
18 changes: 18 additions & 0 deletions .github/workflows/lighthouse-audit.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
name: Lighthouse audit

on: [push]

jobs:
lighthouseci:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 20
- run: npm install && npm install -g @lhci/cli
- run: npm run build
- run: lhci collect
- run: lhci upload
env:
LHCI_GITHUB_APP_TOKEN: ${{ secrets.LHCI_GITHUB_APP_TOKEN }}
61 changes: 61 additions & 0 deletions .github/workflows/lint-build-check.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
name: Lint and build check

on:
pull_request:
types: [opened, reopened, synchronize]

jobs:
lint_build:
runs-on: ubuntu-latest
steps:
- name: Checkout Code
uses: actions/checkout@v4

- name: Cache node modules
id: cache-npm
uses: actions/cache@v3
env:
cache-name: cache-node-modules
with:
path: ~/.npm
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-build-${{ env.cache-name }}-
${{ runner.os }}-build-
${{ runner.os }}-
- if: ${{ steps.cache-npm.outputs.cache-hit != 'true' }}
name: List the state of node modules
continue-on-error: true
run: npm list

- name: Install modules
run: npm install

- name: Run lint
run: npm run lint

- name: Run build
run: npm run build

docker_build:
if: github.head_ref != 'develop'
needs: lint_build
runs-on: ubuntu-latest
steps:
- name: Checkout Code
uses: actions/checkout@v4

- name: Setup Docker Buildx Driver
id: docker_driver_setup
uses: docker/setup-buildx-action@v3

- name: Run docker build
id: docker_build
uses: docker/build-push-action@v5
with:
context: ./
file: ./Dockerfile
push: false
cache-from: type=gha
cache-to: type=gha,mode=max
1 change: 1 addition & 0 deletions .husky/commit-msg
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
npx --no -- commitlint --edit $1
1 change: 1 addition & 0 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
npm run lint-staged
20 changes: 20 additions & 0 deletions .lighthouserc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"ci": {
"collect": {
"startServerCommand": "npm run start",
"startServerReadyPattern": "ready on",
"url": ["http://localhost:3000/"],
"numberOfRuns": 1,
"settings": {
"preset": "desktop"
}
},
"assert": {
"preset": "lighthouse:recommended"
},
"upload": {
"target": "temporary-public-storage"
},
"server": {}
}
}
10 changes: 10 additions & 0 deletions .lintstagedrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
const path = require('path');

const buildEslintCommand = filenames =>
`next lint --fix --file ${filenames
.map(f => path.relative(process.cwd(), f))
.join(' --file ')}`;

module.exports = {
'*.{js,jsx,ts,tsx}': [buildEslintCommand],
};
9 changes: 9 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"editor.quickSuggestions": {
"strings": "on"
},
"files.associations": {
"*.css": "tailwindcss"
},
"editor.formatOnSave": true
}
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,4 @@ This is a [Next.js](https://nextjs.org/docs/app/building-your-application/deploy

## Deployed apps

[https://mibanco.app/](https://mibanco.app/)
- [mibanco.app](https://mibanco.app/)
1 change: 1 addition & 0 deletions commitlint.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
module.exports = { extends: ['@commitlint/config-conventional'] };
2 changes: 1 addition & 1 deletion components.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,4 @@
"components": "@/components",
"utils": "@/lib/utils"
}
}
}
Loading

0 comments on commit 5f305bc

Please sign in to comment.