Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat/rules via database #600

Merged
merged 14 commits into from
Jul 31, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 14 additions & 9 deletions .github/workflows/ci-v2.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,17 +21,22 @@ jobs:
with:
fetch-depth: 0

# - name: set SHAs
# run: |
# # run code only on main branch
# TAG_VERSION=$(git describe --first-parent --match 'v*' --abbrev=0 --tags)
- name: Derive appropriate SHAs for base and head for `nx affected` commands
uses: nrwl/nx-set-shas@v4

- name: Ovverride Base to be last release
run: |
# run code only on main branch
TAG_VERSION=$(git describe --first-parent --match 'v*' --abbrev=0 --tags)

echo "Found tag: $TAG_VERSION"
LAST_TAG_HASH=$(git rev-list -n 1 $TAG_VERSION)
echo "Found hash: $LAST_TAG_HASH"

# Set NX_BASE to the last tag
echo "NX_BASE=$LAST_TAG_HASH" >> $GITHUB_ENV

# echo "Found tag: $TAG_VERSION"
# LAST_TAG_HASH=$(git rev-list -n 1 $TAG_VERSION)
# echo "Found hash: $LAST_TAG_HASH"

# # Set NX_BASE to the last tag
# echo "NX_BASE=$LAST_TAG_HASH" >> $GITHUB_ENV

- uses: oven-sh/setup-bun@v2
with:
Expand Down
5 changes: 4 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
{
"githubPullRequests.ignoredPullRequestBranches": ["develop"],
"github-actions.workflows.pinned.workflows": [".github/workflows/main.yml"]
"github-actions.workflows.pinned.workflows": [
".github/workflows/main.yml"
],
"exportall.config.folderListener": []
}
2 changes: 0 additions & 2 deletions apps/api/jest.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@ export default {
// displayName:api,
preset: '../../jest.preset.js',
testEnvironment: 'node',
passWithNoTests: true,
testTimeout: 1000 * 60 * 10,
transform: {
'^.+\\.[tj]s$': ['ts-jest', { tsconfig: '<rootDir>/tsconfig.spec.json' }],
},
Expand Down
4 changes: 1 addition & 3 deletions apps/badman/jest.config.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
/* eslint-disable */
export default {
// displayName: badman,
preset: '../../jest.preset.js',
setupFilesAfterEnv: ['<rootDir>/src/test-setup.ts'],
passWithNoTests: true,
testTimeout: 1000 * 60 * 10,
coverageDirectory: '../../coverage/apps/badman',
transform: {
'^.+\\.(ts|mjs|js|html)$': [
Expand Down
4 changes: 4 additions & 0 deletions apps/badman/src/app/app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,10 @@ const APP_ROUTES: Routes = [
path: 'jobs',
loadChildren: () => import('@badman/frontend-jobs').then((m) => m.JobModule),
},
{
path: 'rules',
loadChildren: () => import('@badman/frontend-rules').then((m) => m.RuleModule),
},
{
path: 'transfers',
loadChildren: () => import('@badman/frontend-transfers').then((m) => m.TransferModule),
Expand Down
2 changes: 0 additions & 2 deletions apps/scripts/jest.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@ export default {
// displayName: scripts,
preset: '../../jest.preset.js',
testEnvironment: 'node',
passWithNoTests: true,
testTimeout: 1000 * 60 * 10,
transform: {
'^.+\\.[tj]s$': ['ts-jest', { tsconfig: '<rootDir>/tsconfig.spec.json' }],
},
Expand Down
2 changes: 0 additions & 2 deletions apps/worker/belgium/flanders/games/jest.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@ export default {
// displayName: 'worker-belgium-flanders-games',
preset: '../../../../../jest.preset.js',
testEnvironment: 'node',
passWithNoTests: true,
testTimeout: 1000 * 60 * 10,
transform: {
'^.+\\.[tj]s$': ['ts-jest', { tsconfig: '<rootDir>/tsconfig.spec.json' }],
},
Expand Down
2 changes: 0 additions & 2 deletions apps/worker/belgium/flanders/places/jest.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@ export default {
// displayName: 'worker-belgium-flanders-places',
preset: '../../../../../jest.preset.js',
testEnvironment: 'node',
passWithNoTests: true,
testTimeout: 1000 * 60 * 10,
transform: {
'^.+\\.[tj]s$': ['ts-jest', { tsconfig: '<rootDir>/tsconfig.spec.json' }],
},
Expand Down
2 changes: 0 additions & 2 deletions apps/worker/belgium/flanders/points/jest.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@ export default {
// displayName: 'worker-belgium-flanders-points',
preset: '../../../../../jest.preset.js',
testEnvironment: 'node',
passWithNoTests: true,
testTimeout: 1000 * 60 * 10,
transform: {
'^.+\\.[tj]s$': ['ts-jest', { tsconfig: '<rootDir>/tsconfig.spec.json' }],
},
Expand Down
2 changes: 0 additions & 2 deletions apps/worker/ranking/jest.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@ export default {
// displayName: 'worker-ranking',
preset: '../../../jest.preset.js',
testEnvironment: 'node',
passWithNoTests: true,
testTimeout: 1000 * 60 * 10,
transform: {
'^.+\\.[tj]s$': ['ts-jest', { tsconfig: '<rootDir>/tsconfig.spec.json' }],
},
Expand Down
2 changes: 0 additions & 2 deletions apps/worker/sync/jest.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@ export default {
// displayName: 'worker-sync',
preset: '../../../jest.preset.js',
testEnvironment: 'node',
passWithNoTests: true,
testTimeout: 1000 * 60 * 10,
transform: {
'^.+\\.[tj]s$': ['ts-jest', { tsconfig: '<rootDir>/tsconfig.spec.json' }],
},
Expand Down
2 changes: 2 additions & 0 deletions database/migrations/20220531163325-empty.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ module.exports = {
up: async (queryInterface, sequelize) => {
return queryInterface.sequelize.transaction(async (t) => {
try {
//
} catch (err) {
console.error('We errored with', err?.message ?? err);
t.rollback();
Expand All @@ -16,6 +17,7 @@ module.exports = {
down: async (queryInterface) => {
return queryInterface.sequelize.transaction(async (t) => {
try {
//
} catch (err) {
console.error('We errored with', err);
t.rollback();
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
/* eslint-disable @typescript-eslint/no-var-requires */
'use strict';

/** @type {import('sequelize-cli').Migration} */
module.exports = {
up: async (queryInterface, Sequelize) => {
return queryInterface.sequelize.transaction(async (t) => {
try {
await queryInterface.bulkInsert(
{
tableName: 'Claims',
schema: 'security',
},
[
{
name: 'change:rules',
description: 'Allow chaning ruless',
category: 'rules',
type: 'global',
createdAt: new Date(),
updatedAt: new Date(),
},
],
{ transaction: t },
);

// create Rule table
await queryInterface.createTable(
{
tableName: 'Rules',
schema: 'system',
},
{
id: {
type: Sequelize.UUID,
defaultValue: Sequelize.UUIDV4,
primaryKey: true,
},
name: {
type: Sequelize.STRING,
allowNull: false,
},
group: {
type: Sequelize.STRING,
allowNull: false,
},
description: {
type: Sequelize.STRING,
allowNull: true,
},
meta: {
type: Sequelize.JSON,
allowNull: true,
},
activated: {
type: Sequelize.BOOLEAN,
allowNull: false,
},
createdAt: {
type: Sequelize.DATE,
allowNull: false,
},
updatedAt: {
type: Sequelize.DATE,
allowNull: false,
},
},
{ transaction: t },
);
} catch (err) {
console.error('We errored with', err?.message ?? err);
t.rollback();
}
});
},

down: async (queryInterface) => {
return queryInterface.sequelize.transaction(async (t) => {
try {
// remove enlist-any-event:team claim
await queryInterface.sequelize.query(
`DELETE FROM "security"."Claims" WHERE name = 'change:rules'`,
{ transaction: t },
);

// drop Rule table
await queryInterface.dropTable(
{
tableName: 'Rules',
schema: 'system',
},
{ transaction: t },
);
} catch (err) {
console.error('We errored with', err);
t.rollback();
}
});
},
};
56 changes: 28 additions & 28 deletions docker-compose.dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ services:
environment:
POSTGRES_PASSWORD: ${DB_PASSWORD}
POSTGRES_USER: ${DB_USER}
POSTGRES_DB: ${DB_DATABASE}
POSTGRES_DB: postgres
POSTGRES_MAX_CONNECTIONS: 500
ports:
- '0.0.0.0:5432:5432'
Expand All @@ -55,33 +55,33 @@ services:
- api
restart: unless-stopped

# # Tools
# pgadmin:
# container_name: pgadmin
# image: dpage/pgadmin4
# environment:
# PGADMIN_DEFAULT_EMAIL: ${PGADMIN_DEFAULT_EMAIL:-pgadmin4@pgadmin.org}
# PGADMIN_DEFAULT_PASSWORD: ${PGADMIN_DEFAULT_PASSWORD:-admin}
# GUNICORN_ACCESS_LOGFILE: '/dev/null'
# PGADMIN_CONFIG_SERVER_MODE: 'False'
# POSTGRES_USER: ${DB_USER}
# POSTGRES_PASSWORD: ${DB_PASSWORD}
# PGADMIN_CONFIG_UPGRADE_CHECK_ENABLED: 'False'
# volumes:
# - db-admin:/var/lib/pgadmin
# - ./database/backup:/home/backup
# - ./database/scripts:/home/scripts
# ports:
# - '${PGADMIN_PORT:-5050}:80'
# links:
# - postgres:postgres
# depends_on:
# - postgres
# networks:
# - postgres
# restart: unless-stopped
# logging:
# driver: 'none'
# Tools
pgadmin:
container_name: pgadmin
image: dpage/pgadmin4:8.9
environment:
PGADMIN_DEFAULT_EMAIL: ${PGADMIN_DEFAULT_EMAIL:-pgadmin4@pgadmin.org}
PGADMIN_DEFAULT_PASSWORD: ${PGADMIN_DEFAULT_PASSWORD:-admin}
GUNICORN_ACCESS_LOGFILE: '/dev/null'
PGADMIN_CONFIG_SERVER_MODE: 'False'
POSTGRES_USER: ${DB_USER}
POSTGRES_PASSWORD: ${DB_PASSWORD}
PGADMIN_CONFIG_UPGRADE_CHECK_ENABLED: 'False'
volumes:
- db-admin:/var/lib/pgadmin
- ./database/backup:/home/backup
- ./database/scripts:/home/scripts
ports:
- '${PGADMIN_PORT:-5050}:80'
links:
- postgres:postgres
depends_on:
- postgres
networks:
- postgres
restart: unless-stopped
logging:
driver: 'none'

networks:
api:
Expand Down
2 changes: 0 additions & 2 deletions libs/backend/authorization/jest.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@ export default {
// displayName: 'backend-authorization',
preset: '../../../jest.preset.js',
testEnvironment: 'node',
passWithNoTests: true,
testTimeout: 1000 * 60 * 10,
transform: {
'^.+\\.[tj]s$': ['ts-jest', { tsconfig: '<rootDir>/tsconfig.spec.json' }],
},
Expand Down
2 changes: 0 additions & 2 deletions libs/backend/belgium/flanders/games/jest.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@ export default {
// displayName: 'belgium-flanders-game',
preset: '../../../../../jest.preset.js',
testEnvironment: 'node',
passWithNoTests: true,
testTimeout: 1000 * 60 * 10,
transform: {
'^.+\\.[tj]s$': ['ts-jest', { tsconfig: '<rootDir>/tsconfig.spec.json' }],
},
Expand Down
2 changes: 0 additions & 2 deletions libs/backend/belgium/flanders/places/jest.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@ export default {
// displayName: 'belgium-flanders-place',
preset: '../../../../../jest.preset.js',
testEnvironment: 'node',
passWithNoTests: true,
testTimeout: 1000 * 60 * 10,
transform: {
'^.+\\.[tj]s$': ['ts-jest', { tsconfig: '<rootDir>/tsconfig.spec.json' }],
},
Expand Down
2 changes: 0 additions & 2 deletions libs/backend/belgium/flanders/points/jest.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@ export default {
// displayName: 'belgium-flanders-point',
preset: '../../../../../jest.preset.js',
testEnvironment: 'node',
passWithNoTests: true,
testTimeout: 1000 * 60 * 10,
transform: {
'^.+\\.[tj]s$': ['ts-jest', { tsconfig: '<rootDir>/tsconfig.spec.json' }],
},
Expand Down
2 changes: 0 additions & 2 deletions libs/backend/cache/jest.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@ export default {
// displayName: 'backend-cache',
preset: '../../../jest.preset.js',
testEnvironment: 'node',
passWithNoTests: true,
testTimeout: 1000 * 60 * 10,
transform: {
'^.+\\.[tj]s$': ['ts-jest', { tsconfig: '<rootDir>/tsconfig.spec.json' }],
},
Expand Down
2 changes: 0 additions & 2 deletions libs/backend/cluster/jest.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@ export default {
// displayName: 'backend-cluster',
preset: '../../../jest.preset.js',
testEnvironment: 'node',
passWithNoTests: true,
testTimeout: 1000 * 60 * 10,
transform: {
'^.+\\.[tj]s$': ['ts-jest', { tsconfig: '<rootDir>/tsconfig.spec.json' }],
},
Expand Down
2 changes: 0 additions & 2 deletions libs/backend/competition/assembly/jest.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@ export default {
// displayName: 'backend-assembly',
preset: '../../../../jest.preset.js',
testEnvironment: 'node',
passWithNoTests: true,
testTimeout: 1000 * 60 * 10,
transform: {
'^.+\\.[tj]s$': ['ts-jest', { tsconfig: '<rootDir>/tsconfig.spec.json' }],
},
Expand Down
3 changes: 2 additions & 1 deletion libs/backend/competition/assembly/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@
"graphql-type-json": "^0.3.2",
"moment": "^2.30.1",
"sequelize": "^6.37.3",
"tslib": "^2.6.2"
"tslib": "^2.6.2",
"@badman/backend-validation": "6.161.2"
},
"type": "commonjs",
"main": "./src/index.js",
Expand Down
2 changes: 1 addition & 1 deletion libs/backend/competition/assembly/src/assembly.module.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { CompileModule } from '@badman/backend-compile';
import { DatabaseModule } from '@badman/backend-database';
import { ConfigType } from '@badman/utils';
import { Module } from '@nestjs/common';
import { ConfigModule, ConfigService } from '@nestjs/config';
import { join } from 'path';
import { AssemblyController } from './controllers';
import { AssemblyExportService, AssemblyValidationService } from './services';
import { ConfigType } from '@badman/utils';

@Module({
imports: [
Expand Down
Loading
Loading