Skip to content

Commit

Permalink
Merge pull request #279 from TaloDev/develop
Browse files Browse the repository at this point in the history
Release 0.31.0
  • Loading branch information
tudddorrr authored Apr 27, 2024
2 parents 2fbefbe + 35b99b0 commit b583def
Show file tree
Hide file tree
Showing 205 changed files with 9,106 additions and 5,054 deletions.
38 changes: 19 additions & 19 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,65 +7,65 @@ jobs:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 20

- uses: actions/cache@v3
- uses: actions/cache@v4
with:
path: '**/node_modules'
key: ${{ runner.os }}-modules-${{ hashFiles('**/yarn.lock') }}
key: ${{ runner.os }}-modules-${{ hashFiles('**/package-lock.json') }}

- name: Install deps
run: yarn --prefer-offline
run: npm ci --prefer-offline

- name: Setup environment
run: cp envs/.env.dev .env

- name: Run tests
run: yarn test --coverage
run: npm test -- --coverage

- uses: codecov/codecov-action@v3
- uses: codecov/codecov-action@v4
with:
token: ${{ secrets.CODECOV_TOKEN }}

build-check:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 20

- uses: actions/cache@v3
- uses: actions/cache@v4
with:
path: '**/node_modules'
key: ${{ runner.os }}-modules-${{ hashFiles('**/yarn.lock') }}
key: ${{ runner.os }}-modules-${{ hashFiles('**/package-lock.json') }}

- name: Install deps
run: yarn --prefer-offline
run: npm ci --prefer-offline

- name: Build
run: yarn build
run: npm run build

lint:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 20

- uses: actions/cache@v3
- uses: actions/cache@v4
with:
path: '**/node_modules'
key: ${{ runner.os }}-modules-${{ hashFiles('**/yarn.lock') }}
key: ${{ runner.os }}-modules-${{ hashFiles('**/package-lock.json') }}

- name: Install deps
run: yarn --prefer-offline
run: npm ci --prefer-offline

- name: Lint
run: yarn eslint
run: npx eslint
13 changes: 6 additions & 7 deletions .github/workflows/create-release.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

name: Release

on:
Expand All @@ -8,24 +7,24 @@ jobs:
release:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
fetch-depth: 0

- uses: actions/setup-node@v3
- uses: actions/setup-node@v4
with:
node-version: 20

- uses: actions/cache@v3
- uses: actions/cache@v4
with:
path: '**/node_modules'
key: ${{ runner.os }}-modules-${{ hashFiles('**/yarn.lock') }}
key: ${{ runner.os }}-modules-${{ hashFiles('**/package-lock.json') }}

- name: Install deps
run: yarn --prefer-offline
run: npm ci --prefer-offline

- name: Build
run: yarn build
run: npm run build

- name: Create GitHub release
uses: softprops/action-gh-release@v1
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/tag.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ jobs:
tag:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4

- name: Check version change
id: check
Expand All @@ -23,7 +23,7 @@ jobs:

- name: Trigger Docker workflow
if: steps.check.outputs.changed == 'true'
uses: actions/github-script@v6
uses: actions/github-script@v7
with:
script: |
github.rest.actions.createWorkflowDispatch({
Expand All @@ -35,7 +35,7 @@ jobs:
- name: Trigger Release workflow
if: steps.check.outputs.changed == 'true'
uses: actions/github-script@v6
uses: actions/github-script@v7
with:
script: |
github.rest.actions.createWorkflowDispatch({
Expand Down
14 changes: 7 additions & 7 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,20 @@ Want to add a new system? Are the docs not clear enough? We're always accepting

## Installation

1. Clone the repo and run `yarn` or `npm install`.
1. Clone the repo and run `npm install`.
2. Copy `envs/.env.dev` to the project root and rename it to `.env`.
3. Run `yarn up` (or `npm run up`) to spin up the Docker Compose containers.
3. Run `npm run up` to spin up the Docker Compose containers.
4. The backend will be accessible via `http://localhost:3000`.

## Seeding data

Run `yarn seed` to seed your database with some fake data like users, events, games and players.
Run `npm run seed` to seed your database with some fake data like users, events, games and players.

The seed command will create two users: `[email protected]` (an admin user) and `[email protected]` (a dev user with less permissions), both can be logged in with using the password `password`.

## Testing

Run `yarn test` to run the unit tests.
Run `npm test` to run the unit tests.

The tests run against your database container. They'll automatically backup and restore the current state of your database before executing the tests.

Expand All @@ -27,15 +27,15 @@ Please make sure to include tests with all pull requests.

## Creating new services

You can create a new service using the `yarn service:create` command. You need to pass in the name of the entity you want the service to interact with.
You can create a new service using the `npm run service:create` command. You need to pass in the name of the entity you want the service to interact with.

For example, if you are adding a "Global Stats" service, you would run: `yarn service:create global-stat` (note that the entity name is singular and not a plural).
For example, if you are adding a "Global Stats" service, you would run: `npm run service:create global-stat` (note that the entity name is singular and not a plural).

This will create a policy, entity and REST API for your new entity. If you want to expose API endpoints (so that it can be used by the Unity SDK), add `--api` to the end of the command.

## Migrations

To create a migration, use `yarn migration:create`. This will create a migration class in the `migrations` folder.
To create a migration, use `npm run migration:create`. This will create a migration class in the `migrations` folder.

Modify the default name of the file from `Migration[Timestamp].ts` to `[Timestamp][PascalCaseDescriptionOfTheMigration].ts`.

Expand Down
12 changes: 6 additions & 6 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,21 @@ FROM node:lts AS base
WORKDIR /usr/backend
COPY tsconfig.json .
COPY package.json .
COPY yarn.lock .
COPY package-lock.json .
EXPOSE 80

FROM base AS dev
RUN yarn
CMD [ "yarn", "watch" ]
RUN npm install
CMD [ "npm", "run", "watch" ]

FROM base AS build
COPY tsconfig.build.json .
RUN yarn
RUN npm install
COPY src ./src
RUN yarn build
RUN npm run build

FROM base AS prod
ENV NODE_ENV production
RUN yarn
RUN npm install
COPY --from=build /usr/backend/dist .
CMD [ "node", "index.js" ]
2 changes: 1 addition & 1 deletion _templates/service/new/api-service-test.ejs.t
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
to: "<%= (typeof api !== 'undefined') ? `tests/services/_api/${name}-api/post.test.ts` : null %>"
---
import { EntityManager } from '@mikro-orm/core'
import { EntityManager } from '@mikro-orm/mysql'
import request from 'supertest'
import { APIKeyScope } from '../../../../src/entities/api-key'
import createAPIKeyAndToken from '../../../utils/createAPIKeyAndToken'
Expand Down
2 changes: 1 addition & 1 deletion _templates/service/new/entity.ejs.t
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
to: src/entities/<%= name %>.ts
---
import { Entity, PrimaryKey, Property } from '@mikro-orm/core'
import { Entity, PrimaryKey, Property } from '@mikro-orm/mysql'

@Entity()
export default class <%= h.changeCase.pascal(name) %> {
Expand Down
2 changes: 1 addition & 1 deletion _templates/service/new/service.ejs.t
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
to: src/services/<%= name %>.service.ts
---
import { EntityManager } from '@mikro-orm/core'
import { EntityManager } from '@mikro-orm/mysql'
import { HasPermission, Service, Request, Response, Validate } from 'koa-clay'
import <%= h.changeCase.pascal(name) %> from '../entities/<%= name %>'
import <%= h.changeCase.pascal(name) %>Policy from '../policies/<%= name %>.policy'
Expand Down
47 changes: 47 additions & 0 deletions docker-compose.ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
version: '3.9'

services:
test-db:
image: mysql:8
command: --default-authentication-plugin=mysql_native_password --sql_mode=
environment:
- MYSQL_DATABASE=${DB_NAME}
- MYSQL_ROOT_PASSWORD=${DB_PASS}
restart: always
healthcheck:
test: ["CMD", "mysqladmin", "ping", "-h", "127.0.0.1"]
interval: 2s
timeout: 2s
retries: 10
ports:
- ${DB_PORT}:3306
volumes:
- test-data:/var/lib/mysql
networks:
- test-network

test-redis:
image: bitnami/redis:7.2
environment:
- REDIS_PASSWORD=${REDIS_PASSWORD}
ports:
- ${REDIS_PORT}:6379
depends_on:
test-db:
condition: service_healthy
networks:
- test-network

stripe-api:
image: stripe/stripe-mock:latest
ports:
- 12111:12111
- 12112:12112
networks:
- test-network

volumes:
test-data:

networks:
test-network:
7 changes: 3 additions & 4 deletions docker-compose.test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,8 @@ services:
- test-network

test-redis:
image: bitnami/redis:7.0
environment:
- REDIS_PASSWORD=${REDIS_PASSWORD}
image: arm64v8/redis:7-alpine
command: redis-server --requirepass ${REDIS_PASSWORD}
ports:
- ${REDIS_PORT}:6379
depends_on:
Expand All @@ -33,7 +32,7 @@ services:
- test-network

stripe-api:
image: stripe/stripe-mock:latest
image: stripe/stripe-mock:latest-arm64
ports:
- 12111:12111
- 12112:12112
Expand Down
3 changes: 1 addition & 2 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,7 @@ services:

redis:
image: arm64v8/redis:7-alpine
environment:
- REDIS_PASSWORD=${REDIS_PASSWORD}
command: redis-server --requirepass ${REDIS_PASSWORD}
ports:
- 6379:6379

Expand Down
2 changes: 2 additions & 0 deletions envs/.env.test
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,5 @@ STRIPE_WEBHOOK_SECRET=whsec_abc123
REDIS_HOST=127.0.0.1
REDIS_PORT=6380
REDIS_PASSWORD=password

COMPOSE_IGNORE_ORPHANS=1
Loading

0 comments on commit b583def

Please sign in to comment.