Skip to content

Commit

Permalink
Fix (#2037)
Browse files Browse the repository at this point in the history

<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->

## Summary by CodeRabbit

- **New Features**
	- Updated CI pipeline for improved clarity and structure.
	- Introduced structured command processing for game lobby commands.
	- Enhanced message handling for client connections and tracking.

- **Bug Fixes**
	- Improved error handling in message processing functions.

- **Documentation**
	- Added configuration files for testing setups across various packages.

- **Tests**
	- Created initial test suites to validate core functionalities.

- **Chores**
	- Updated package configurations for better dependency management.
	- Enhanced `.gitignore` to exclude unnecessary files from tracking.

<!-- end of auto-generated comment: release notes by coderabbit.ai -->
  • Loading branch information
drazisil authored Aug 26, 2024
2 parents 646aa88 + bf8bd2b commit d0bdb42
Show file tree
Hide file tree
Showing 318 changed files with 42,558 additions and 16,405 deletions.
10 changes: 10 additions & 0 deletions .deepsource.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
version = 1

[[analyzers]]
name = "javascript"

[analyzers.meta]
environment = [
"nodejs",
"vitest"
]
28 changes: 14 additions & 14 deletions .eslintrc.json
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
{
"extends": ["eslint:recommended", "plugin:prettier/recommended"],
"env": {
"node": true,
"es2021": true
},
"plugins": ["prettier"],
"parserOptions": {
"ecmaVersion": "latest",
"sourceType": "module"
},
"rules": {
"prettier/prettier": "error",
"no-undef": "error"
}
"extends": ["eslint:recommended", "plugin:prettier/recommended"],
"env": {
"node": true,
"es2021": true
},
"plugins": ["prettier"],
"parserOptions": {
"ecmaVersion": "latest",
"sourceType": "module"
},
"rules": {
"prettier/prettier": "error",
"no-undef": "error"
}
}
52 changes: 30 additions & 22 deletions .github/workflows/node.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Node.js CI
name: Node.js

on:
push:
Expand All @@ -7,45 +7,53 @@ on:

env:
MCO_LOG_LEVEL: warn
EXTERNAL_HOST: mcouniverse.com
PRIVATE_KEY_FILE: thebeast/data/private_key.pem # These secrets are stored in the repository and are safe to "leak"
CERTIFICATE_FILE: thebeast/data/mcouniverse.crt # These secrets are stored in the repository and are safe to "leak"
PUBLIC_KEY_FILE: thebeast/data/pub.key # These secrets are stored in the repository and are safe to "leak"

jobs:
build:
build-test:
runs-on: ubuntu-latest

strategy:
matrix:
node-version: [18.x, 20.x, 21.x]

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4
with:
fetch-depth: 0
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3
- name: Use Node.js 22.x
uses: actions/setup-node@60edb5dd545a775178f52524783378180af0d1f8 # v4
with:
node-version: ${{ matrix.node-version }}
- run: npm ci install
- name: Test
run: npm run test:only
node-version: 22.x
- name: Setup pnpm
uses: pnpm/action-setup@v4.0.0
- name: Install and test
run: |
pnpm install
make test
env:
CODECOV_UPLOAD_BUNDLE_TOKEN: ${{ secrets.CODECOV_UPLOAD_BUNDLE_TOKEN }}
- name: Codecov
env: # Or as an environment variable
if: ${{ always() }} # using always() to always run this step because i am uploading test results and coverage in one step
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
run: |
pip install --user pytest
pip install --user codecov-cli
codecovcli --verbose create-commit --fail-on-error
codecovcli --verbose create-report --fail-on-error
codecovcli --verbose create-commit --fail-on-error
codecovcli --verbose create-report --fail-on-error
codecovcli do-upload --report-type test_results --file mcos.junit.xml
codecovcli --verbose do-upload --fail-on-error --flag cli --name cli-${{ matrix.node-version }}
codecovcli --verbose do-upload --fail-on-error --flag connection --name connection-${{ matrix.node-version }}
codecovcli --verbose do-upload --fail-on-error --flag database --name database-${{ matrix.node-version }}
codecovcli --verbose do-upload --fail-on-error --flag gateway --name gateway-${{ matrix.node-version }}
codecovcli --verbose do-upload --fail-on-error --flag lobby --name lobby-${{ matrix.node-version }}
codecovcli --verbose do-upload --fail-on-error --flag login --name login-${{ matrix.node-version }}
codecovcli --verbose do-upload --fail-on-error --flag mcots --name mcots-${{ matrix.node-version }}
codecovcli --verbose do-upload --fail-on-error --flag nps --name nps-${{ matrix.node-version }}
codecovcli --verbose do-upload --fail-on-error --flag patch --name patch-${{ matrix.node-version }}
codecovcli --verbose do-upload --fail-on-error --flag persona --name persona-${{ matrix.node-version }}
codecovcli --verbose do-upload --fail-on-error --flag shard --name shard-${{ matrix.node-version }}
codecovcli --verbose do-upload --fail-on-error --flag transactions --name transactions-${{ matrix.node-version }}
codecovcli --verbose do-upload --fail-on-error --flag core --name core-${{ matrix.node-version }}
codecovcli --verbose do-upload --fail-on-error --flag shared --name shared-${{ matrix.node-version }}
codecovcli --verbose do-upload --fail-on-error --flag shared-packets --name shared-packets-${{ matrix.node-version }}
- uses: actions/upload-artifact@v3
- uses: actions/upload-artifact@0b2256b8c012f0828dc542b3febcab082c67f72b # v4
with:
name: coverage_${{ matrix.node-version }}
path: coverage
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,6 @@ dist
# Sentry Auth Token
.sentryclirc
*.map
out/*
out/*
*.junit.xml
mcos.junit.xml
2 changes: 2 additions & 0 deletions .npmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
node-options="--openssl-legacy-provider"
link-workspace-packages=true
2 changes: 1 addition & 1 deletion .nvmrc
Original file line number Diff line number Diff line change
@@ -1 +1 @@
v20.5.1
22.6.0
12 changes: 6 additions & 6 deletions .renovaterc.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{
"extends": ["config:base"],
"statusCheckVerify": true,
"automerge": true,
"automergeType": "branch",
"rangeStrategy": "bump",
"enabledManagers": ["npm"]
"extends": ["config:base"],
"statusCheckVerify": true,
"automerge": true,
"automergeType": "branch",
"rangeStrategy": "bump",
"enabledManagers": ["npm"]
}
16 changes: 8 additions & 8 deletions .vscode/extensions.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
{
"recommendations": [
"ms-azuretools.vscode-docker",
"dbaeumer.vscode-eslint",
"esbenp.prettier-vscode",
"ms-vscode.makefile-tools",
"usernamehw.errorlens"
]
}
"recommendations": [
"ms-azuretools.vscode-docker",
"esbenp.prettier-vscode",
"ms-vscode.makefile-tools",
"usernamehw.errorlens",
"biomejs.biome"
]
}
6 changes: 3 additions & 3 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"git.enableCommitSigning": true,
"typescript.tsdk": "node_modules/typescript/lib",
"js/ts.implicitProjectConfig.checkJs": true
"git.enableCommitSigning": true,
"typescript.tsdk": "node_modules/typescript/lib",
"js/ts.implicitProjectConfig.checkJs": true
}
30 changes: 25 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,3 +1,14 @@
# This will read from .env file and export all the variables
# to the environment. This is useful for running the tests
# and other commands that require the environment variables
# to be set.
#
# Warning: This will cause the makefile to fail if the .env
# file is not present. This is the desired behavior as we
# want to make sure that the environment variables are set
# before running the tests.
# include .env // Disabled for now

all:
@npm install

Expand All @@ -8,14 +19,23 @@ certs:
@echo "certs regenerated. remember to update pub.key for all clients"

test:
@clear
@npm test
# This will start a postgres server in the background and run the tests
# against it. The server will be stopped after the tests are done.
#
# Note the use of `$$` to escape the `$` character. This is required
# because the command is being run in a subshell. That the command
# is being run in a subshell is why we can't use `export` to set the
# DATABASE_URL environment variable.
@DATABASE_URL=$$(npx pg-test start) && \
echo "Testing with DATABASE_URL=$$DATABASE_URL" && \
DATABASE_URL=$$DATABASE_URL pnpm migrate && \
DATABASE_URL=$$DATABASE_URL pnpm test
@npx pg-test stop


build:
@npm run build:dev

start:
@EXTERNAL_HOST=mcouniverse.com PRIVATE_KEY_FILE=data/private_key.pem CERTIFICATE_FILE=data/mcouniverse.crt PUBLIC_KEY_FILE=data/pub.key LOG_LEVEL=trace npm run start:dev
@pnpx tsx --openssl-legacy-provider --env-file=.env server.ts

prod_node:
docker-compose --file docker-compose.yml up -d --build
Expand Down
70 changes: 70 additions & 0 deletions biome.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
{
"$schema": "https://biomejs.dev/schemas/1.8.3/schema.json",
"organizeImports": { "enabled": true },
"linter": {
"enabled": true,
"rules": {
"recommended": false,
"complexity": {
"noExtraBooleanCast": "error",
"noMultipleSpacesInRegularExpressionLiterals": "error",
"noUselessCatch": "error",
"noWith": "error",
"useArrowFunction": "off",
"useLiteralKeys":"off"
},
"correctness": {
"noConstAssign": "error",
"noConstantCondition": "error",
"noEmptyCharacterClassInRegex": "error",
"noEmptyPattern": "error",
"noGlobalObjectCalls": "error",
"noInnerDeclarations": "error",
"noInvalidConstructorSuper": "error",
"noNewSymbol": "error",
"noNonoctalDecimalEscape": "error",
"noPrecisionLoss": "error",
"noSelfAssign": "error",
"noSetterReturn": "error",
"noSwitchDeclarations": "error",
"noUndeclaredVariables": "error",
"noUnreachable": "error",
"noUnreachableSuper": "error",
"noUnsafeFinally": "error",
"noUnsafeOptionalChaining": "error",
"noUnusedLabels": "error",
"noUnusedVariables": "error",
"useIsNan": "error",
"useValidForDirection": "error",
"useYield": "error"
},
"style": { "useBlockStatements": "off" },
"suspicious": {
"noAssignInExpressions": "error",
"noAsyncPromiseExecutor": "error",
"noCatchAssign": "error",
"noClassAssign": "error",
"noCompareNegZero": "error",
"noControlCharactersInRegex": "error",
"noDebugger": "error",
"noDuplicateCase": "error",
"noDuplicateClassMembers": "error",
"noDuplicateObjectKeys": "error",
"noDuplicateParameters": "error",
"noEmptyBlockStatements": "error",
"noFallthroughSwitchClause": "error",
"noFunctionAssign": "error",
"noGlobalAssign": "error",
"noImportAssign": "error",
"noMisleadingCharacterClass": "error",
"noPrototypeBuiltins": "error",
"noRedeclare": "error",
"noShadowRestrictedNames": "error",
"noUnsafeNegation": "error",
"useGetterReturn": "error",
"useValidTypeof": "error"
}
},
"ignore": ["**/*.d.ts", "**/dist", "**/out"]
}
}
13 changes: 0 additions & 13 deletions jsconfig-old.json

This file was deleted.

Loading

0 comments on commit d0bdb42

Please sign in to comment.