Skip to content

Improve developer experience (ci, tests, linter) #3

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

Merged
merged 12 commits into from
Dec 1, 2024
52 changes: 52 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
name: CI

on:
push:
branches:
- main
pull_request:
branches:
- main

jobs:
build:
runs-on: ubuntu-latest

services:
postgres:
image: postgres:17.2
env:
POSTGRES_DB: dashboard
POSTGRES_USER: openjs
POSTGRES_PASSWORD: password
ports:
- 5432:5432
options: >-
--health-cmd="pg_isready -U openjs"
--health-interval=10s
--health-timeout=5s
--health-retries=5

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

- name: Set up Node.js
uses: actions/setup-node@v3
with:
node-version: '22'

- name: Install dependencies
run: npm install

- name: Lint files
run: npm run lint

- name: Run migrations
run: npm run db:migrate

- name: Seed database
run: npm run db:seed

- name: Run tests
run: npm test
1 change: 1 addition & 0 deletions .nvmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
22
28 changes: 28 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,34 @@ To seed the database with initial data, use the following command:
npm run db:seed
```

## Linting

To lint the files, use the following command:

```bash
npm run lint
```

To automatically fix linting issues, use the following command:

```bash
npm run lint:fix
```

## Running Tests

To run the tests, use the following command:

```bash
npm test
```

To run the tests with coverage, use the following command:

```bash
npm run test:coverage
```

## License

This project is licensed under the MIT License. See the [LICENSE](/LICENSE) file for details.
5 changes: 5 additions & 0 deletions __tests__/index.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
describe('Demo test', () => {
it('should pass', () => {
expect(1 + 1).toBe(2)
})
})
42 changes: 21 additions & 21 deletions knexfile.js
Original file line number Diff line number Diff line change
@@ -1,25 +1,25 @@
const { normalizeBoolean } = require("@ulisesgascon/normalize-boolean");
const { normalizeBoolean } = require('@ulisesgascon/normalize-boolean')
const dbSettings = {
client: 'pg',
connection: {
host: process.env.DB_HOST || '0.0.0.0',
user: process.env.DB_USER || 'openjs',
password: process.env.DB_PASSWORD || 'password',
database: process.env.DB_NAME || 'dashboard',
},
ssl: normalizeBoolean(process.env.DB_SSL),
pool: {
min: 2,
max: 10
},
migrations: {
directory: './src/database/migrations'
},
seeds: {
directory: './src/database/seeds'
}
client: 'pg',
connection: {
host: process.env.DB_HOST || '0.0.0.0',
user: process.env.DB_USER || 'openjs',
password: process.env.DB_PASSWORD || 'password',
database: process.env.DB_NAME || 'dashboard'
},
ssl: normalizeBoolean(process.env.DB_SSL),
pool: {
min: 2,
max: 10
},
migrations: {
directory: './src/database/migrations'
},
seeds: {
directory: './src/database/seeds'
}
}

module.exports = {
development: dbSettings
}
development: dbSettings
}
Loading