Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ci: add checks to actions and husky pre-commit #55

Merged
merged 5 commits into from
Oct 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
22 changes: 21 additions & 1 deletion .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,31 @@ name: ci

on:
pull_request:
types: [opened, reopened, synchronize, edited]
types: [opened, reopened, synchronize]
workflow_call:
workflow_dispatch:

jobs:
checks:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install pnpm
uses: pnpm/action-setup@v4
with:
version: 9
run_install: false
- name: Setup node
uses: actions/setup-node@v4
with:
node-version-file: ".nvmrc"
cache: "pnpm"
- name: Install dependencies
run: pnpm install
- name: Astro check
run: pnpm astro check
- name: Prettier check
run: pnpm exec prettier --check .
build-test:
runs-on: ubuntu-latest
steps:
Expand Down
1 change: 1 addition & 0 deletions .husky/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
_
2 changes: 2 additions & 0 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
npx lint-staged
niccofyren marked this conversation as resolved.
Show resolved Hide resolved
pnpm astro check
9 changes: 6 additions & 3 deletions DEVELOPMENT.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,11 @@ For basic installation of backend repo see [backend repo](https://github.com/gat
1. Clone this repo
2. Make sure you have the correct node version installed (`nvm use` then `nvm install`)
3. Run `pnpm install`
4. Run `pnpm dev`
5. Frontend should now be available on `localhost:4321` serving content from `https://dev.tg.no`
4. Run `pnpm prepare` # Setup Husky for pre-commit
5. Run `pnpm dev`
6. Frontend should now be available on `localhost:4321` serving content from `https://dev.tg.no`

We use [husky](https://typicode.github.io/husky/) pre-commit for making sure all code conforms to the same formatting. This happens automatically on commit after this first time setup, if it doesn't work try a fresh `pnpm install`

## Using local backend

Expand All @@ -24,7 +27,7 @@ Same procedure as above, but with a few extra steps:

## Using production backend

Identical to using local backend section above, but use `https://prod.tg.no/`/`https://tg.no/` instead of `http://localhost:8000/`
Identical to using local backend section above, but use `https://www.tg.no/` instead of `http://localhost:8000/`

## Common issues

Expand Down
3 changes: 2 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ ENV PATH="$PNPM_HOME:$PATH"
RUN corepack enable
COPY package.json pnpm-lock.yaml /app/
WORKDIR /app
RUN pnpm install --prod
# --ignore-scripts is used to prevent https://github.com/pnpm/pnpm/issues/7068
RUN pnpm install --prod --ignore-scripts
COPY . /app
RUN pnpm build

Expand Down
8 changes: 7 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@
"start": "astro dev",
"build": "astro check && export $(grep -v '^\\s*$\\|^\\s*\\#' .env.runtime) && astro build",
"preview": "astro preview",
"astro": "astro"
"astro": "astro",
"prepare": "husky"
},
"dependencies": {
"@astrojs/check": "^0.9.4",
Expand All @@ -22,7 +23,12 @@
},
"devDependencies": {
"@types/dompurify": "^3.0.5",
"husky": ">=7",
"lint-staged": ">=10",
"prettier": "^3.3.3",
"prettier-plugin-astro": "^0.14.1"
},
"lint-staged": {
"*.{js,ts,mjs,css,md,astro,yaml,json}": "prettier --write"
}
}
Loading