Skip to content

Commit

Permalink
Merge pull request #8 from funidata/trunk
Browse files Browse the repository at this point in the history
Test database migrations in CI
  • Loading branch information
joonashak authored Sep 12, 2024
2 parents abc7e77 + 730a9cc commit 50c8483
Show file tree
Hide file tree
Showing 6 changed files with 58 additions and 2 deletions.
19 changes: 19 additions & 0 deletions .github/workflows/run-tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -34,3 +34,22 @@ jobs:
run: npm ci
- name: Run prettier
run: npm run format:check

migrations:
name: Check database migrations
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version-file: .nvmrc
- name: Build Docker image
run: npm run build
- name: Start Postgres
run: docker compose up -d db
- name: Run migrations
run: docker compose run app npm run migration:run
- name: Stop Postgres
run: npm stop
1 change: 1 addition & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
app/dist
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,4 @@ revolves around easily sharing information about when and where from you are wor

- [Requirements](./docs/requirements.md)
- [Configuration](./docs/configuration.md)
- [Testing](./docs/testing.md)
3 changes: 2 additions & 1 deletion compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ services:
context: app
dockerfile: Dockerfile.dev
env_file:
- .env
- path: .env
required: false
environment:
NODE_ENV: development
DATABASE_NAME: kaiku_dev
Expand Down
32 changes: 32 additions & 0 deletions docs/testing.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# Testing

Currently, Kaiku's test suite includes only linting, formatting, and database migration checks. The
plan is to utilize integration tests as the primary tool once the project matures slightly more.

Passing all tests is required for code to be merged into `main`.

## Local Development

Run all local tests with `npm test`. (Does not include migration tests.)

### Linting

Linting is configured only for the `app/` folder and uses ESLint.

```bash
npm run lint
```

### Formatting

Prettier is used to format all code in the repository. The formatting test passes if formatting
results in an empty diff. Prettier is configured in repository root.

```bash
npm run format:check
```

## CI/CD

GitHub Actions is used for CI/CD. In addition to linting and formatting, also database migrations
are run on CI. This test simply requires the migration run to result in the zero exit code.
4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@
"build": "docker compose build",
"logs": "docker compose logs -f app",
"postinstall": "cd app && npm ci",
"format:check": "prettier --check ."
"format:check": "prettier --check .",
"lint": "cd app && npm run lint",
"test": "npm run format:check && npm run lint"
},
"author": "Joonas Häkkinen <[email protected]>",
"license": "GPL-3.0",
Expand Down

0 comments on commit 50c8483

Please sign in to comment.