-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #69 from RnDAO/github-actions
GitHub actions
- Loading branch information
Showing
38 changed files
with
1,598 additions
and
449 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
.github/ | ||
coverage/ | ||
dist/ | ||
node_modules/ | ||
|
||
.env |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,16 @@ | ||
{ | ||
"env": { | ||
"browser": true, | ||
"es2021": 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": ["standard-with-typescript", "prettier"], | ||
"overrides": [], | ||
"parser": "@typescript-eslint/parser", | ||
"parserOptions": { | ||
"ecmaVersion": "latest", | ||
"sourceType": "module", | ||
"project": "./tsconfig.json" | ||
}, | ||
"rules": {}, | ||
"ignorePatterns": ["coverage", "dist"] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
name: CI Pipeline | ||
|
||
on: pull_request | ||
|
||
jobs: | ||
ci: | ||
uses: TogetherCrew/operations/.github/workflows/ci.yml@main | ||
secrets: | ||
CC_TEST_REPORTER_ID: ${{ secrets.CC_TEST_REPORTER_ID }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
name: Publish | ||
|
||
on: | ||
release: | ||
types: [published] | ||
|
||
jobs: | ||
ci: | ||
uses: TogetherCrew/operations/.github/workflows/publish.ts.yml@main | ||
secrets: | ||
NODE_AUTH_TOKEN: ${{ secrets.NODE_AUTH_TOKEN }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
dist | ||
coverage | ||
node_modules |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,4 +2,4 @@ | |
"printWidth": 120, | ||
"trailingComma": "all", | ||
"singleQuote": true | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
FROM node:18-alpine AS base | ||
WORKDIR /project | ||
COPY . . | ||
RUN npm ci | ||
|
||
FROM base AS test | ||
CMD [ "npx", "jest", "--coverage" ] | ||
|
||
FROM base AS build | ||
RUN npm run build | ||
|
||
FROM build AS prod | ||
RUN npm ci --omit=dev | ||
CMD ["npm", "run", "start"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,31 +1,36 @@ | ||
import { HeatMap } from '../../../src/models'; | ||
import { IHeatMap } from '../../../src/interfaces/HeatMap.interface' | ||
import { IHeatMap } from '../../../src/interfaces/HeatMap.interface'; | ||
|
||
describe('HeatMap model', () => { | ||
describe('heatMap validation', () => { | ||
let heatMap: IHeatMap; | ||
beforeEach(() => { | ||
heatMap = { | ||
date: "2022-02-01", | ||
thr_messages: [0, 1, 1, 1, 2, 0, 0, 1, 1, 0, 1, 0, 2, 0, 4, 3, 1, 2, 0, 1, 0, 1, 0, 2], | ||
lone_messages: [0, 1, 1, 1, 2, 0, 0, 1, 1, 0, 1, 0, 2, 0, 4, 3, 1, 2, 0, 1, 0, 1, 0, 2], | ||
replier: [0, 1, 1, 1, 2, 0, 0, 1, 1, 0, 1, 0, 2, 0, 4, 3, 1, 2, 0, 1, 0, 1, 0, 2], | ||
replied_per_acc: [{account: "Magic", count: 4}], | ||
replied: [0, 1, 1, 1, 2, 0, 0, 1, 1, 0, 1, 0, 2, 0, 4, 3, 1, 2, 0, 1, 0, 1, 0, 2], | ||
mentioner: [0, 1, 1, 1, 2, 0, 0, 1, 1, 0, 1, 0, 2, 0, 4, 3, 1, 2, 0, 1, 0, 1, 0, 2], | ||
mentioner_per_acc: [{account: "Behzad", count: 4}, {account: "Magic", count: 2}], | ||
mentioned: [0, 1, 1, 1, 2, 0, 0, 1, 1, 0, 1, 0, 2, 0, 4, 3, 1, 2, 0, 1, 0, 1, 0, 2], | ||
reacter: [0, 1, 1, 1, 2, 0, 0, 1, 1, 0, 1, 0, 2, 0, 4, 3, 1, 2, 0, 1, 0, 1, 0, 2], | ||
reacted_per_acc: [{account: "End", count: 2}, {account: "Magic", count: 2}], | ||
reacted: [0, 1, 1, 1, 2, 0, 0, 1, 1, 0, 1, 0, 2, 0, 4, 3, 1, 2, 0, 1, 0, 1, 0, 2], | ||
channelId: "123123123123", | ||
account_name: "MagicPalm" | ||
} | ||
}); | ||
|
||
test('should correctly validate a valid heatMap', async () => { | ||
await expect(new HeatMap(heatMap).validate()).resolves.toBeUndefined(); | ||
}); | ||
describe('heatMap validation', () => { | ||
let heatMap: IHeatMap; | ||
beforeEach(() => { | ||
heatMap = { | ||
date: '2022-02-01', | ||
thr_messages: [0, 1, 1, 1, 2, 0, 0, 1, 1, 0, 1, 0, 2, 0, 4, 3, 1, 2, 0, 1, 0, 1, 0, 2], | ||
lone_messages: [0, 1, 1, 1, 2, 0, 0, 1, 1, 0, 1, 0, 2, 0, 4, 3, 1, 2, 0, 1, 0, 1, 0, 2], | ||
replier: [0, 1, 1, 1, 2, 0, 0, 1, 1, 0, 1, 0, 2, 0, 4, 3, 1, 2, 0, 1, 0, 1, 0, 2], | ||
replied_per_acc: [{ account: 'Magic', count: 4 }], | ||
replied: [0, 1, 1, 1, 2, 0, 0, 1, 1, 0, 1, 0, 2, 0, 4, 3, 1, 2, 0, 1, 0, 1, 0, 2], | ||
mentioner: [0, 1, 1, 1, 2, 0, 0, 1, 1, 0, 1, 0, 2, 0, 4, 3, 1, 2, 0, 1, 0, 1, 0, 2], | ||
mentioner_per_acc: [ | ||
{ account: 'Behzad', count: 4 }, | ||
{ account: 'Magic', count: 2 }, | ||
], | ||
mentioned: [0, 1, 1, 1, 2, 0, 0, 1, 1, 0, 1, 0, 2, 0, 4, 3, 1, 2, 0, 1, 0, 1, 0, 2], | ||
reacter: [0, 1, 1, 1, 2, 0, 0, 1, 1, 0, 1, 0, 2, 0, 4, 3, 1, 2, 0, 1, 0, 1, 0, 2], | ||
reacted_per_acc: [ | ||
{ account: 'End', count: 2 }, | ||
{ account: 'Magic', count: 2 }, | ||
], | ||
reacted: [0, 1, 1, 1, 2, 0, 0, 1, 1, 0, 1, 0, 2, 0, 4, 3, 1, 2, 0, 1, 0, 1, 0, 2], | ||
channelId: '123123123123', | ||
account_name: 'MagicPalm', | ||
}; | ||
}); | ||
|
||
test('should correctly validate a valid heatMap', async () => { | ||
await expect(new HeatMap(heatMap).validate()).resolves.toBeUndefined(); | ||
}); | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,27 +1,26 @@ | ||
import { Token } from '../../../src/models'; | ||
import { IToken } from '../../../src/interfaces/Token.interface' | ||
import moment from "moment"; | ||
import { IToken } from '../../../src/interfaces/Token.interface'; | ||
import moment from 'moment'; | ||
|
||
describe('Token model', () => { | ||
describe('Token validation', () => { | ||
let token: IToken; | ||
beforeEach(() => { | ||
token = { | ||
user: "681946187490000906", | ||
token: "716384", | ||
type: "access", | ||
expires: moment("2022-02-01 08:30:26.127Z").toDate() | ||
}; | ||
}); | ||
|
||
test('should correctly validate a valid token', async () => { | ||
await expect(new Token(token).validate()).resolves.toBeUndefined(); | ||
}); | ||
describe('Token validation', () => { | ||
let token: IToken; | ||
beforeEach(() => { | ||
token = { | ||
user: '1234', | ||
token: '4321', | ||
type: 'access', | ||
expires: moment('2022-02-01 08:30:26.127Z').toDate(), | ||
}; | ||
}); | ||
|
||
test('should throw a validation error if type is invalid', async () => { | ||
token.type = 'invalidToken'; | ||
await expect(new Token(token).validate()).rejects.toThrow(); | ||
}); | ||
test('should correctly validate a valid token', async () => { | ||
await expect(new Token(token).validate()).resolves.toBeUndefined(); | ||
}); | ||
|
||
test('should throw a validation error if type is invalid', async () => { | ||
token.type = 'invalidToken'; | ||
await expect(new Token(token).validate()).rejects.toThrow(); | ||
}); | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,22 @@ | ||
import { User } from '../../../src/models'; | ||
import { IUser } from '../../../src/interfaces/User.interface' | ||
import { IUser } from '../../../src/interfaces/User.interface'; | ||
|
||
describe('User model', () => { | ||
describe('User validation', () => { | ||
let user: IUser; | ||
beforeEach(() => { | ||
user = { | ||
discordId: "681946187490000906", | ||
}; | ||
}); | ||
describe('User validation', () => { | ||
let user: IUser; | ||
beforeEach(() => { | ||
user = { | ||
discordId: '1234', | ||
}; | ||
}); | ||
|
||
test('should correctly validate a valid user', async () => { | ||
await expect(new User(user).validate()).resolves.toBeUndefined(); | ||
}); | ||
test('should correctly validate a valid user', async () => { | ||
await expect(new User(user).validate()).resolves.toBeUndefined(); | ||
}); | ||
|
||
test('should throw a validation error if email is invalid', async () => { | ||
user.email = 'invalidEmail'; | ||
await expect(new User(user).validate()).rejects.toThrow(); | ||
}); | ||
test('should throw a validation error if email is invalid', async () => { | ||
user.email = 'invalidEmail'; | ||
await expect(new User(user).validate()).rejects.toThrow(); | ||
}); | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
version: '3.9' | ||
|
||
services: | ||
app: | ||
build: | ||
context: . | ||
target: test | ||
dockerfile: Dockerfile | ||
volumes: | ||
- ./coverage:/project/coverage |
Oops, something went wrong.