Skip to content

Commit

Permalink
Merge pull request #11 from hirosystems/develop
Browse files Browse the repository at this point in the history
release to master
  • Loading branch information
rafaelcr authored Oct 26, 2023
2 parents 5492206 + 79a08a4 commit d6755a3
Show file tree
Hide file tree
Showing 27 changed files with 8,241 additions and 11,010 deletions.
1 change: 1 addition & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
node_modules/
dist/
.eslintrc.js
2 changes: 1 addition & 1 deletion .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ module.exports = {
ecmaVersion: 2020,
sourceType: 'module',
},
ignorePatterns: ['*.config.js', 'config/*', '*.mjs', 'tests/*.js', 'client/*'],
ignorePatterns: ['*.config.js', 'bin/*.js'],
plugins: ['@typescript-eslint', 'eslint-plugin-tsdoc', 'prettier'],
rules: {
'prettier/prettier': 'error',
Expand Down
103 changes: 103 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
name: CI

on:
push:
branches:
- master
- develop
tags-ignore:
- '**'
paths-ignore:
- '**/CHANGELOG.md'
- '**/package.json'
pull_request:
workflow_dispatch:

jobs:
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2

- name: Use Node.js
uses: actions/setup-node@v2
with:
node-version-file: '.nvmrc'

- name: Cache node modules
uses: actions/cache@v2
env:
cache-name: cache-node-modules
with:
path: |
~/.npm
**/node_modules
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-build-${{ env.cache-name }}-
${{ runner.os }}-build-
${{ runner.os }}-
- name: Install deps
run: npm ci --audit=false

- name: Lint ESLint
run: npm run lint:eslint

- name: Lint Prettier
run: npm run lint:prettier

test:
runs-on: ubuntu-latest
env:
PGHOST: 127.0.0.1
PGPORT: 5432
PGUSER: postgres
PGPASSWORD: postgres
PGDATABASE: postgres
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0

- name: Use Node.js
uses: actions/setup-node@v2
with:
node-version-file: '.nvmrc'

- name: Cache node modules
uses: actions/cache@v2
env:
cache-name: cache-node-modules
with:
path: |
~/.npm
**/node_modules
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-build-${{ env.cache-name }}-
${{ runner.os }}-build-
${{ runner.os }}-
- name: Install deps
run: npm ci --audit=false

- name: Setup integration environment
run: |
sudo ufw disable
npm run testenv:run -- -d
npm run testenv:logs -- --no-color &> docker-compose-logs.txt &
- name: Run tests
run: npm run test -- --coverage

- name: Upload coverage to Codecov
uses: codecov/codecov-action@v3

- name: Print integration environment logs
run: cat docker-compose-logs.txt
if: failure()

- name: Teardown integration environment
run: npm run testenv:stop
if: always()
26 changes: 26 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
{
"version": "0.2.0",
"configurations": [
{
"type": "node",
"request": "launch",
"name": "Jest",
"program": "${workspaceFolder}/node_modules/jest/bin/jest",
"args": [
"--testTimeout=3600000",
"--runInBand",
"--no-cache",
],
"outputCapture": "std",
"console": "integratedTerminal",
"preLaunchTask": "npm: testenv:run",
"postDebugTask": "npm: testenv:stop",
"env": {
"PGHOST": "localhost",
"PGDATABASE": "postgres",
"PGUSER": "postgres",
"PGPASSWORD": "postgres",
},
},
]
}
37 changes: 37 additions & 0 deletions .vscode/tasks.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
{
"version": "2.0.0",
"tasks": [
{
"label": "npm: testenv:run",
"type": "shell",
"command": "npm run testenv:run -- -d",
"isBackground": true,
"problemMatcher": {
"pattern": {
"regexp": ".",
"file": 1,
"location": 2,
"message": 3
},
"background": {
"activeOnStart": true,
"beginsPattern": ".",
"endsPattern": "."
}
}
},
{
"label": "npm: testenv:stop",
"type": "shell",
"command": "npm run testenv:stop",
"presentation": {
"echo": true,
"reveal": "silent",
"focus": false,
"panel": "shared",
"showReuseMessage": true,
"clear": false
}
}
]
}
13 changes: 12 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@ Please see each tool's source directory for additional documentation

### Postgres

* Superclass for connection support and SQL transaction management using [postgres.js](https://github.com/porsager/postgres)
* Superclass for connection support and SQL transaction management using
[postgres.js](https://github.com/porsager/postgres)
* Connection helpers with automatic retry logic, using the standard postgres ENV variables
* Migration tools for migration apply and rollback using
[node-pg-migrate](https://github.com/salsita/node-pg-migrate)
Expand All @@ -47,6 +48,16 @@ gracefully on unhandled exceptions or interrupt signals.
tag, and latest commit
* Helpers to extract version info to display at runtime or on documentation

### Fastify

* API server creation with CORS, Typebox and Pino logging
* OpenAPI generator plugin with YAML and JSON exports

### Helpers

* Value conversion functions (hex strings, hashes, etc.)
* Timer tools (stopwatch, waiters, etc.)

## License

The API Toolkit Library is released under the Apache 2.0 License. See the LICENSE file for more
Expand Down
11 changes: 11 additions & 0 deletions docker/docker-compose.dev.postgres.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
version: '3.7'
services:
postgres:
image: "postgres:15"
ports:
- "5432:5432"
environment:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgres
POSTGRES_DB: postgres
POSTGRES_PORT: 5432
Loading

0 comments on commit d6755a3

Please sign in to comment.