Skip to content

Commit

Permalink
Linter (#119)
Browse files Browse the repository at this point in the history
* chore: moving the compose up to the docker image

* ci: concurrent pre-commit

* lint: fixy fix

* ci: parallel

* tests: only .ts

* ci: ffs

* chore: remove typescript configs

* chore: setup env values

* chore: include the setup

* chore: adding prod compose and extra ignore

* ci: only build container on merged pr
  • Loading branch information
O-Mutt authored Feb 11, 2025
1 parent 4a304c9 commit 98e6eb9
Show file tree
Hide file tree
Showing 27 changed files with 1,151 additions and 248 deletions.
1 change: 1 addition & 0 deletions .github/workflows/deploy-docker-container.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ on:
jobs:
build:
runs-on: ubuntu-latest
if: (github.event_name == 'pull_request' && github.event.action == 'closed') || github.event_name == 'workflow_dispatch'
steps:
- uses: actions/checkout@v4

Expand Down
43 changes: 36 additions & 7 deletions .github/workflows/just_do_it.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ on:
workflow_dispatch:

jobs:
checkout_and_install:
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
Expand All @@ -16,9 +16,38 @@ jobs:
with:
node-version: lts/*

- name: Install dependencies
run: |
npm ci
npm run lint
npm run test
npm run build
- name: Clean Install
run: npm ci

- name: Lint
run: npm run lint

test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- uses: actions/setup-node@v4
with:
node-version: lts/*

- name: Clean Install
run: npm ci

- name: Test
run: npm run test

build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- uses: actions/setup-node@v4
with:
node-version: lts/*

- name: Clean Install
run: npm ci

- name: Build
run: npm run build
5 changes: 3 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ typings/
!.env.example
.env
.env.test
.*.env

# parcel-bundler cache (https://parceljs.org/)
.cache
Expand Down Expand Up @@ -109,9 +110,9 @@ nohup.out


src/config/*
!src/config/example.ts
!src/config/example.*
!src/config/index.ts
!src/config/config.schema.ts
!src/config/example.jsonreport.*
!src/config/example.json

report.*
3 changes: 3 additions & 0 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
npm run lint
npm run build
npm run test
2 changes: 1 addition & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@
"files.trimTrailingWhitespace": true,
"editor.formatOnSave": true,
"typescript.tsdk": "node_modules/typescript/lib",
"cSpell.words": ["Pointd", "pointdPal", "PointdPal", "samplesize", "Subdocument", "tselint", "Unobfuscated"]
"cSpell.words": ["Pointd", "pointdPal", "PointdPal", "porque", "samplesize", "Subdocument", "tselint", "Unobfuscated"]
}
19 changes: 9 additions & 10 deletions app.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
import { installStore } from '@/lib/services';

import { App } from '@slack/bolt';
import { LogLevel } from '@slack/logger';

import { config } from '@/config';
import { healthEndpoint } from '@/lib/routes/health';
import { logger as customLogger } from '@/logger';
import { withNamespace } from '@/logger';

import '@/lib/stringExtensions';
import '@/lib/dateExtensions';
Expand Down Expand Up @@ -36,6 +34,7 @@ import { register as shortcutsRegister } from '@/shortcuts';
import { installService } from '@/lib/services';
import { pointdPalInstallationStore } from '@/lib/installationStore';

const appLogger = withNamespace('pointd-pal');
const app = new App({
signingSecret: config.get('slack.signingSecret'),
clientId: config.get('slack.clientId'),
Expand Down Expand Up @@ -78,23 +77,23 @@ const app = new App({
logger: {
getLevel: () => config.get('logLevel') as LogLevel,
setLevel: (level: LogLevel) => config.set('logLevel', level),
debug: (...msg) => customLogger.debug(msg),
info: (...msg) => customLogger.info(msg),
warn: (...msg) => customLogger.warn(msg),
error: (...msg) => customLogger.error(msg),
setName: (name: string) => customLogger.label(name),
debug: (...msg) => appLogger.debug(msg),
info: (...msg) => appLogger.info(msg),
warn: (...msg) => appLogger.warn(msg),
error: (...msg) => appLogger.error(msg),
setName: (name: string) => appLogger.label(name),
},
});

void (async () => {
customLogger.info(
appLogger.info(
'Before we start the apps we will validate that all installations are up to date by running migrations. Please hold on...',
);
await installService.migrateAll();
// Start your app
await app.start({ port: config.get('port') });

customLogger.info(`⚡️ Bolt app is running at localhost:${config.get('port')}!`);
appLogger.info(`⚡️ Bolt app is running at localhost:${config.get('port')}!`);
})();

messagesCryptoRegister(app);
Expand Down
File renamed without changes.
66 changes: 66 additions & 0 deletions compose.prod.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
services:
pointd-pal:
container_name: pointd-pal
build:
context: .
dockerfile: Dockerfile
ports:
- 3000:3000
volumes:
- ./:/home/node/app
- /home/node/app/node_modules
env_file:
- .bot.env
depends_on:
- pointd-pal-db
- migration
healthcheck:
test: ["CMD", "curl", "-f", "http://localhost:3000/health"]
interval: 10s
timeout: 5s
retries: 5

pointd-pal-db:
container_name: pointd-pal-db
image: postgres:latest
env_file:
- .psql.env
ports:
- 5432:5432
volumes:
- pointdpal:/home/postgres/pgdata/data
healthcheck:
test: ["CMD-SHELL", "pg_isready -U pointdpal"]
interval: 10s
timeout: 5s
retries: 5

migration:
image: flyway/flyway:latest
volumes:
- ./migrations/sql/:/flyway/sql
env_file:
- .flyway.env
command: "migrate -X"
depends_on:
- pointd-pal-db

migration-info:
image: redgate/flyway:latest
volumes:
- ./migrations/sql/:/flyway/sql
environment:
- FLYWAY_URL=jdbc:postgresql://pointd-pal-db:5432/pointdpal
- FLYWAY_USER=pointdpal
- FLYWAY_PASSWORD=pointdpal
- FLYWAY_BASELINE_ON_MIGRATE=true
command: "info"
depends_on:
pointd-pal-db:
condition: service_started
migration:
condition: service_completed_successfully

volumes:
pointdpal:
driver: local
11 changes: 10 additions & 1 deletion eslint.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import eslintPluginPrettierRecommended from 'eslint-plugin-prettier/recommended'
import jestPlugin from 'eslint-plugin-jest';
import tseslint from 'typescript-eslint';
import eslint from '@eslint/js';
import globals from 'globals';

export default tseslint.config(
{
Expand Down Expand Up @@ -30,8 +31,16 @@ export default tseslint.config(
},
{
// enable jest rules on test files
files: ['test/**', '**/*.test.ts', '**/*.spec.ts'],
files: ['test/**', '**/*.test.*', '**/*.spec.*'],
extends: [jestPlugin.configs['flat/recommended']],
rules: {
'@typescript-eslint/no-floating-promises': 'off',
},
languageOptions: {
globals: {
...globals.node,
},
},
},
{
// ignore unused vars if they are prefixed with _
Expand Down
7 changes: 7 additions & 0 deletions lint-staged.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
const config = {
// eslint-disable-next-line @typescript-eslint/no-unsafe-call, @typescript-eslint/no-unsafe-member-access
'*': (stagedFiles) => `eslint ${stagedFiles.join(' ')}`,
'*.ts': 'npm run build',
};

export default config;
Loading

0 comments on commit 98e6eb9

Please sign in to comment.