Skip to content

Commit

Permalink
Merge branch 'master' into setup_steps_updated
Browse files Browse the repository at this point in the history
  • Loading branch information
gc authored Aug 6, 2024
2 parents eaa3f13 + bdc6f78 commit 68d0b76
Show file tree
Hide file tree
Showing 193 changed files with 4,130 additions and 3,494 deletions.
6 changes: 5 additions & 1 deletion .dockerignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
.env
icon_cache
logs
dist
dist
node_modules
coverage
.yarn
.tests
5 changes: 4 additions & 1 deletion .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,10 @@ BOT_TOKEN=PUT_YOUR_TOKEN_HERE
# You may need to change these:
ROBOCHIMP_DATABASE_URL=postgresql://postgres:postgres@localhost:5436/robochimp_test
DATABASE_URL=postgresql://postgres:postgres@localhost:5435/osb_test
#REDIS_PORT=6379 #OPTIONAL

# Optional
#REDIS_PORT=6379
#TESTING_SERVER_ID=123456789012345678

# Dont change these:
TZ="UTC"
3 changes: 2 additions & 1 deletion .env.test
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@ TZ="UTC"
CLIENT_ID=111398433321891634
BOT_TOKEN=AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
TEST=true
CI=true
CI=true
YARN_ENABLE_HARDENED_MODE=0
2 changes: 1 addition & 1 deletion .github/workflows/integration_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,4 @@ jobs:
uses: docker/setup-buildx-action@v3

- name: Run Integration Tests
run: docker-compose up --build --abort-on-container-exit
run: docker compose up --build --abort-on-container-exit --remove-orphans && docker compose down --volumes --remove-orphans
8 changes: 2 additions & 6 deletions .github/workflows/unit_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:
test:
name: Node v${{ matrix.node_version }} - ${{ matrix.os }}
runs-on: ${{ matrix.os }}
timeout-minutes: 10
timeout-minutes: 5
strategy:
matrix:
node_version: [20.15.0]
Expand Down Expand Up @@ -43,8 +43,4 @@ jobs:
- name: Build
run: yarn build:tsc
- name: Test
run: |
yarn test:unit
yarn test:lint
tsc -p tests/integration && tsc -p tests/unit
npm i -g dpdm && dpdm --exit-code circular:1 --progress=false --warning=false --tree=false ./dist/index.js
run: yarn test:ci:unit
1 change: 1 addition & 0 deletions .yarnrc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@ nodeLinker: node-modules
telemetryInterval: 999999999999
enableTelemetry: false
checksumBehavior: "update"
enableHardenedMode: false
4 changes: 2 additions & 2 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ services:
depends_on:
- db
environment:
ROBOCHIMP_DATABASE_URL: postgresql://postgres:postgres@db:5435/robochimp_integration_test?connection_limit=500&pool_timeout=0&schema=public
DATABASE_URL: postgresql://postgres:postgres@db:5435/osb_integration_test?connection_limit=500&pool_timeout=0&schema=public
ROBOCHIMP_DATABASE_URL: postgresql://postgres:postgres@db:5435/robochimp_integration_test?connection_limit=10&pool_timeout=0&schema=public
DATABASE_URL: postgresql://postgres:postgres@db:5435/osb_integration_test?connection_limit=10&pool_timeout=0&schema=public
WAIT_HOSTS: db:5435

volumes:
Expand Down
36 changes: 22 additions & 14 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,47 +1,54 @@
{
"scripts": {
"watch": "nodemon -e ts -w src --exec 'yarn buildandrun'",
"watch": "nodemon --delay 1ms -e ts -w src --exec 'yarn buildandrun'",
"build": "tsx ./src/scripts/build.ts",
"fix": "tsx ./src/scripts/troubleshooter.ts",
"start": "yarn build && node --enable-source-maps dist/",
"gen": "concurrently --raw \"prisma generate --no-hints\" \"prisma generate --no-hints --schema prisma/robochimp.prisma\" && echo \"Generated Prisma Client\"",
"prettify": "prettier --use-tabs \"./**/*.{md,yml}\" --write",
"lint": "concurrently --raw --kill-others-on-fail \"biome check --write --unsafe --diagnostic-level=error\" \"yarn prettify\"",
"lint": "concurrently --raw --kill-others-on-fail \"biome check --write --unsafe --diagnostic-level=error\" \"yarn prettify\" \"prisma format --schema ./prisma/robochimp.prisma\" \"prisma format --schema ./prisma/schema.prisma\"",
"build:tsc": "tsc -p src",
"watch:tsc": "tsc -w -p src",
"wipedist": "node -e \"try { require('fs').rmSync('dist', { recursive: true }) } catch(_){}\"",
"dev": "yarn && yarn wipedist && yarn lint && yarn build && yarn test && npm i -g dpdm && dpdm --exit-code circular:1 --progress=false --warning=false --tree=false ./dist/index.js",
"test": "concurrently --raw --kill-others-on-fail \"tsc -p src\" \"yarn test:lint\" \"yarn test:unit\" \"tsc -p tests/integration\" \"tsc -p tests/unit\"",
"dev": "concurrently --raw --kill-others-on-fail \"yarn\" \"yarn wipedist\" \"yarn lint\" && yarn build && yarn test",
"test": "concurrently --raw --kill-others-on-fail \"tsc -p src && yarn test:circular\" \"yarn test:lint\" \"yarn test:unit\" \"tsc -p tests/integration --noEmit\" \"tsc -p tests/unit --noEmit\"",
"test:lint": "biome check --diagnostic-level=error",
"test:unit": "vitest run --coverage --config vitest.unit.config.mts",
"test:docker": "docker-compose up --build --abort-on-container-exit --remove-orphans && docker-compose down --volumes --remove-orphans",
"test:watch": "vitest --config vitest.unit.config.mts --coverage",
"test:integration": "tsx ./src/scripts/integration-tests.ts",
"buildandrun": "yarn build:esbuild && node dist",
"buildandrun": "yarn build:esbuild && node --enable-source-maps dist",
"build:esbuild": "concurrently --raw \"yarn build:main\" \"yarn build:workers\"",
"build:main": "esbuild src/index.ts src/lib/workers/index.ts --minify --legal-comments=none --outdir=./dist --log-level=error --bundle --platform=node --loader:.node=file --external:@napi-rs/canvas --external:@prisma/robochimp --external:@prisma/client --external:zlib-sync --external:bufferutil --external:oldschooljs --external:discord.js --external:node-fetch --external:piscina",
"build:workers": "esbuild src/lib/workers/kill.worker.ts src/lib/workers/finish.worker.ts src/lib/workers/casket.worker.ts --log-level=error --bundle --minify --legal-comments=none --outdir=./dist/lib/workers --platform=node --loader:.node=file --external:@napi-rs/canvas --external:@prisma/robochimp --external:@prisma/client --external:zlib-sync --external:bufferutil --external:oldschooljs --external:discord.js --external:node-fetch --external:piscina"
"build:main": "esbuild src/index.ts src/lib/workers/index.ts --sourcemap=inline --minify --legal-comments=none --outdir=./dist --log-level=error --bundle --platform=node --loader:.node=file --external:@napi-rs/canvas --external:@prisma/robochimp --external:@prisma/client --external:zlib-sync --external:bufferutil --external:oldschooljs --external:discord.js --external:node-fetch --external:piscina",
"build:workers": "esbuild src/lib/workers/kill.worker.ts src/lib/workers/finish.worker.ts src/lib/workers/casket.worker.ts --sourcemap=inline --log-level=error --bundle --minify --legal-comments=none --outdir=./dist/lib/workers --platform=node --loader:.node=file --external:@napi-rs/canvas --external:@prisma/robochimp --external:@prisma/client --external:zlib-sync --external:bufferutil --external:oldschooljs --external:discord.js --external:node-fetch --external:piscina",
"test:circular": "dpdm --exit-code circular:1 --progress=false --warning=false --tree=false ./dist/index.js",
"test:ci:unit": "concurrently --raw --kill-others-on-fail \"yarn test:unit\" \"yarn test:lint\" \"tsc -p tests/integration\" \"tsc -p tests/unit\" \"yarn test:circular\""
},
"dependencies": {
"@napi-rs/canvas": "^0.1.53",
"@oldschoolgg/toolkit": "git+https://github.com/oldschoolgg/toolkit.git#62f9f71274c6d36db6c56a2228ae3df9ab090dbd",
"@prisma/client": "^5.16.1",
"@oldschoolgg/toolkit": "git+https://github.com/oldschoolgg/toolkit.git#cd7c6865229ca7dc4a66b3816586f2d3f4a4fbed",
"@prisma/client": "^5.17.0",
"@sapphire/ratelimits": "^2.4.9",
"@sapphire/snowflake": "^3.5.3",
"@sapphire/time-utilities": "^1.6.0",
"@sapphire/timer-manager": "^1.0.2",
"@sentry/node": "^8.15.0",
"ascii-table3": "^0.9.0",
"bufferutil": "^4.0.8",
"discord.js": "^14.15.3",
"dotenv": "^16.4.5",
"e": "0.2.33",
"exit-hook": "^4.0.0",
"fast-deep-equal": "^3.1.3",
"lodash": "^4.17.21",
"lru-cache": "^10.3.0",
"murmurhash": "^2.0.1",
"node-cron": "^3.0.3",
"node-fetch": "^2.6.7",
"oldschooljs": "^2.5.9",
"oldschooljs": "^2.5.10",
"p-queue": "^6.6.2",
"piscina": "^4.6.1",
"random-js": "^2.1.0",
"remeda": "^2.7.0",
"simple-statistics": "^7.8.3",
"sonic-boom": "^4.0.1",
"zlib-sync": "^0.1.9",
Expand All @@ -53,16 +60,17 @@
"@types/node": "^20.14.9",
"@types/node-cron": "^3.0.7",
"@types/node-fetch": "^2.6.1",
"@vitest/coverage-v8": "^1.6.0",
"@vitest/coverage-v8": "^2.0.3",
"concurrently": "^8.2.2",
"dpdm": "^3.14.0",
"esbuild": "0.21.5",
"fast-glob": "^3.3.2",
"nodemon": "^3.1.4",
"prettier": "^3.3.2",
"prisma": "^5.16.1",
"prisma": "^5.17.0",
"tsx": "^4.16.2",
"typescript": "^5.5.3",
"vitest": "^1.6.0"
"vitest": "^2.0.3"
},
"engines": {
"node": "20.15.0"
Expand Down
122 changes: 69 additions & 53 deletions prisma/robochimp.prisma
Original file line number Diff line number Diff line change
@@ -1,93 +1,109 @@
generator client {
provider = "prisma-client-js"
previewFeatures = ["fullTextSearch"]
output = "../node_modules/@prisma/robochimp"
provider = "prisma-client-js"
previewFeatures = ["fullTextSearch"]
output = "../node_modules/@prisma/robochimp"
}

datasource db {
provider = "postgresql"
url = env("ROBOCHIMP_DATABASE_URL")
provider = "postgresql"
url = env("ROBOCHIMP_DATABASE_URL")
}

model TriviaQuestion {
id Int @id @unique @default(autoincrement())
question String @db.VarChar()
answers String[] @db.VarChar()
id Int @id @unique @default(autoincrement())
question String @db.VarChar()
answers String[] @db.VarChar()
@@map("trivia_question")
@@map("trivia_question")
}

enum BlacklistedEntityType {
guild
user
guild
user
}

model BlacklistedEntity {
id BigInt @id @unique
type BlacklistedEntityType
reason String?
date DateTime @default(now()) @db.Timestamp(6)
id BigInt @id @unique
type BlacklistedEntityType
reason String?
date DateTime @default(now()) @db.Timestamp(6)
@@map("blacklisted_entity")
@@map("blacklisted_entity")
}

model User {
id BigInt @id @unique
bits Int[]
github_id Int?
patreon_id String?
migrated_user_id BigInt?
id BigInt @id @unique
bits Int[]
github_id Int?
patreon_id String?
leagues_completed_tasks_ids Int[]
leagues_points_balance_osb Int @default(0)
leagues_points_balance_bso Int @default(0)
leagues_points_total Int @default(0)
migrated_user_id BigInt?
react_emoji_id String?
leagues_completed_tasks_ids Int[]
leagues_points_balance_osb Int @default(0)
leagues_points_balance_bso Int @default(0)
leagues_points_total Int @default(0)
osb_total_level Int?
bso_total_level Int?
osb_total_xp BigInt?
bso_total_xp BigInt?
osb_cl_percent Float?
bso_cl_percent Float?
osb_mastery Float?
bso_mastery Float?
react_emoji_id String?
tag Tag[]
osb_total_level Int?
bso_total_level Int?
osb_total_xp BigInt?
bso_total_xp BigInt?
osb_cl_percent Float?
bso_cl_percent Float?
osb_mastery Float?
bso_mastery Float?
store_bitfield Int[]
store_bitfield Int[]
testing_points Float @default(0)
testing_points_balance Float @default(0)
testing_points Float @default(0)
testing_points_balance Float @default(0)
@@map("user")
perk_tier Int @default(0)
premium_balance_tier Int?
premium_balance_expiry_date BigInt?
user_group_id String? @db.Uuid
userGroup UserGroup? @relation(fields: [user_group_id], references: [id])
tag Tag[]
@@map("user")
}

model PingableRole {
role_id String @id
name String @unique @db.VarChar(32)
role_id String @id
name String @unique @db.VarChar(32)
@@map("pingable_role")
@@map("pingable_role")
}

model Tag {
id Int @id @unique @default(autoincrement())
name String @unique @db.VarChar(32)
content String @db.VarChar(2000)
id Int @id @unique @default(autoincrement())
name String @unique @db.VarChar(32)
content String @db.VarChar(2000)
user_id BigInt
creator User @relation(fields: [user_id], references: [id])
user_id BigInt
creator User @relation(fields: [user_id], references: [id])
@@map("tag")
@@map("tag")
}

model StoreCode {
product_id Int
code String @id @unique
product_id Int
code String @id @unique
redeemed_at DateTime?
redeemed_by_user_id String? @db.VarChar(19)
@@map("store_code")
}

model UserGroup {
id String @id @default(uuid()) @db.Uuid
redeemed_at DateTime?
redeemed_by_user_id String? @db.VarChar(19)
users User[]
@@map("store_code")
@@map("user_group")
}
Loading

0 comments on commit 68d0b76

Please sign in to comment.