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

Super Linter & Github Action #116

Closed
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
35 changes: 14 additions & 21 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -1,22 +1,15 @@
module.exports = {
"env": {
"es2021": true,
"node": true
},
"extends": [
"eslint:recommended",
"plugin:@typescript-eslint/recommended"
],
"overrides": [
],
"parser": "@typescript-eslint/parser",
"parserOptions": {
"ecmaVersion": "latest",
"sourceType": "module"
},
"plugins": [
"@typescript-eslint"
],
"rules": {
}
}
env: {
es2021: true,
node: true
},
extends: ['eslint:recommended', 'plugin:@typescript-eslint/recommended'],
overrides: [],
parser: '@typescript-eslint/parser',
parserOptions: {
ecmaVersion: 'latest',
sourceType: 'module'
},
plugins: ['@typescript-eslint'],
rules: {}
}
38 changes: 15 additions & 23 deletions .eslintrc.json
Original file line number Diff line number Diff line change
@@ -1,24 +1,16 @@
{
"env": {
"ES2017": true,
"node": true
},
"extends": [
"eslint:recommended",
"plugin:@typescript-eslint/recommended",
"prettier",
"prettier/@typescript-eslint"
],
"plugins": [
"@typescript-eslint",
"prettier"
],
"parser": "@typescript-eslint/parser",
"parserOptions": {
"ecmaVersion": 2018,
"sourceType": "module"
},
"rules": {
"prettier/prettier": "error"
}
}
"env": {
"ES2017": true,
"node": true
},
"extends": ["eslint:recommended", "plugin:@typescript-eslint/recommended", "prettier", "prettier/@typescript-eslint"],
"plugins": ["@typescript-eslint", "prettier"],
"parser": "@typescript-eslint/parser",
"parserOptions": {
"ecmaVersion": 2018,
"sourceType": "module"
},
"rules": {
"prettier/prettier": "error"
}
}
44 changes: 6 additions & 38 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,41 +1,9 @@
name: tc-discordBot
name: Staging CI/CD Pipeline

on:
push:
pull_request:
on: pull_request

jobs:
test:
strategy:
matrix:
platform: [ubuntu-latest]
node: ['18.x']
name: test/node ${{ matrix.node }}/${{ matrix.platform }}
runs-on: ${{ matrix.platform }}
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v2
with:
node-version: ${{ matrix.node }}
- run: npm install
# - run: npm run test:ci
- run: npm run lint
- run: npm run format
- run: npm run build

# coverage:
# needs: [test]
# name: coverage
# runs-on: ubuntu-latest
# steps:
# - uses: actions/checkout@v2
# - uses: actions/setup-node@v2
# with:
# node-version: '18'
# - run: npm install
# - run: npm run build
# - uses: paambaati/codeclimate-action@v3.2.0
# env:
# CC_TEST_REPORTER_ID: ${{ secrets.CC_TEST_REPORTER_ID }}
# with:
# coverageCommand: npm run coverage
ci:
uses: TogetherCrew/operations/.github/workflows/ci.yml@main
secrets:
CC_TEST_REPORTER_ID: ${{ secrets.CC_TEST_REPORTER_ID }}
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# tc-discordBot

[![Maintainability](https://api.codeclimate.com/v1/badges/e1239b895f0ee2569b61/maintainability)](https://codeclimate.com/github/RnDAO/tc-discordBot/maintainability)
[![Test Coverage](https://api.codeclimate.com/v1/badges/e1239b895f0ee2569b61/test_coverage)](https://codeclimate.com/github/RnDAO/tc-discordBot/test_coverage)

# tc-discordBot
51 changes: 25 additions & 26 deletions __tests__/fixtures/channel.fixture.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,38 +2,37 @@ import { IChannel } from '@togethercrew.dev/db';
import { Connection } from 'mongoose';

export const channel1: IChannel = {
channelId: '987654321098765432',
name: 'Channel 1',
parentId: null,
permissionOverwrites: [
{
id: '1122334455', // example Snowflake ID for the role or member
type: 0,
allow: 'VIEW_CHANNEL',
deny: 'SEND_MESSAGES',
},
{
id: '9988776655', // another example Snowflake ID for the role or member
type: 1,
allow: 'VIEW_CHANNEL,SEND_MESSAGES',
deny: '',
},
],
channelId: '987654321098765432',
name: 'Channel 1',
parentId: null,
permissionOverwrites: [
{
id: '1122334455', // example Snowflake ID for the role or member
type: 0,
allow: 'VIEW_CHANNEL',
deny: 'SEND_MESSAGES',
},
{
id: '9988776655', // another example Snowflake ID for the role or member
type: 1,
allow: 'VIEW_CHANNEL,SEND_MESSAGES',
deny: '',
},
],
};

export const channel2: IChannel = {
channelId: '234567890123456789',
name: 'Channel 2',
parentId: '987654321098765432',

channelId: '234567890123456789',
name: 'Channel 2',
parentId: '987654321098765432',
};

export const channel3: IChannel = {
channelId: '345678901234567890',
name: 'Channel 3',
parentId: '987654321098765432'
channelId: '345678901234567890',
name: 'Channel 3',
parentId: '987654321098765432',
};

export const insertChannels = async function <Type>(channels: Array<Type>, connection: Connection) {
await connection.models.Channel.insertMany(channels.map((channel) => (channel)));
};
await connection.models.Channel.insertMany(channels.map(channel => channel));
};
2 changes: 1 addition & 1 deletion __tests__/fixtures/guid.fixture.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,5 +58,5 @@ export const guild3 = {
};

export const insertManyGuilds = async function <Type>(guilds: Array<Type>) {
await Guild.insertMany(guilds.map((guild) => guild));
await Guild.insertMany(guilds.map(guild => guild));
};
50 changes: 25 additions & 25 deletions __tests__/fixtures/guildMember.fixture.ts
Original file line number Diff line number Diff line change
@@ -1,34 +1,34 @@
import { IGuildMember } from '@togethercrew.dev/db';

export const guildMember1: IGuildMember = {
discordId: '123456789',
username: 'JohnDoe',
roles: ['role1Id', 'role2Id'],
joinedAt: new Date('2023-05-01'),
discriminator: '1',
isBot: false,
avatar: 'a1',
permissions: '137411140513358n',
discordId: '123456789',
username: 'JohnDoe',
roles: ['role1Id', 'role2Id'],
joinedAt: new Date('2023-05-01'),
discriminator: '1',
isBot: false,
avatar: 'a1',
permissions: '137411140513358n',
};

export const guildMember2: IGuildMember = {
discordId: '987654321',
username: 'JaneSmith',
roles: ['role1Id', 'role2Id'],
joinedAt: new Date('2023-05-01'),
discriminator: '2',
isBot: true,
avatar: 'a2',
permissions: '137411140513357n',
discordId: '987654321',
username: 'JaneSmith',
roles: ['role1Id', 'role2Id'],
joinedAt: new Date('2023-05-01'),
discriminator: '2',
isBot: true,
avatar: 'a2',
permissions: '137411140513357n',
};

export const guildMember3: IGuildMember = {
discordId: '555555555',
username: 'AliceJohnson',
roles: ['role2Id', 'role5Id'],
joinedAt: new Date('2023-05-03'),
discriminator: '3',
isBot: false,
avatar: 'a3',
permissions: '137411140513356n',
};
discordId: '555555555',
username: 'AliceJohnson',
roles: ['role2Id', 'role5Id'],
joinedAt: new Date('2023-05-03'),
discriminator: '3',
isBot: false,
avatar: 'a3',
permissions: '137411140513356n',
};
6 changes: 3 additions & 3 deletions __tests__/fixtures/rawInfo.fixture.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export const rawInfo1: IRawInfo = {
messageId: 'message123',
threadId: 'thread456',
threadName: 'thread789',
channelName: 'c1'
channelName: 'c1',
};

export const rawInfo2: IRawInfo = {
Expand All @@ -29,7 +29,7 @@ export const rawInfo2: IRawInfo = {
messageId: 'message012',
threadId: 'thread345',
threadName: 'Discussion Thread',
channelName: 'c2'
channelName: 'c2',
};

export const rawInfo3: IRawInfo = {
Expand All @@ -45,5 +45,5 @@ export const rawInfo3: IRawInfo = {
messageId: 'message654',
threadId: 'thread321',
threadName: 'Important Announcement',
channelName: 'c3'
channelName: 'c3',
};
22 changes: 11 additions & 11 deletions __tests__/fixtures/role.fixture.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,23 @@ import { IRole } from '@togethercrew.dev/db';
import { Connection } from 'mongoose';

export const role1: IRole = {
roleId: '234567890123456777',
name: 'Role 1',
color: 123456
roleId: '234567890123456777',
name: 'Role 1',
color: 123456,
};

export const role2: IRole = {
roleId: '234567890123456787',
name: 'Role 2',
color: 654321
roleId: '234567890123456787',
name: 'Role 2',
color: 654321,
};

export const role3: IRole = {
roleId: '234567890123456797',
name: 'Role 3',
color: 654321
roleId: '234567890123456797',
name: 'Role 3',
color: 654321,
};

export const insertRoles = async function <Type>(roles: Array<Type>, connection: Connection) {
await connection.models.Role.insertMany(roles.map((role) => (role)));
};
await connection.models.Role.insertMany(roles.map(role => role));
};
Loading
Loading