Skip to content
Merged

Ci #326

Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
f5f6639
add github workflows
Behzad-rabiei Feb 28, 2024
15565d5
add docker files
Behzad-rabiei Feb 28, 2024
77dab72
Merge branch 'development' into ci
Behzad-rabiei Mar 4, 2024
f86d332
update tests
Behzad-rabiei Mar 4, 2024
38dc892
update the connection of db
Behzad-rabiei Mar 4, 2024
edace47
format the code
Behzad-rabiei Mar 4, 2024
95014a9
fix some lint errors
Behzad-rabiei Mar 4, 2024
7098645
fix jest config lint errors
Behzad-rabiei Mar 4, 2024
6c6a41f
fix readme lint errors
Behzad-rabiei Mar 4, 2024
2105593
checking lint errors for platfrom controller
Behzad-rabiei Mar 5, 2024
4d632c4
checking lint errors for platfrom controller
Behzad-rabiei Mar 5, 2024
fa8282a
checking lint errors for platfrom controller
Behzad-rabiei Mar 5, 2024
26b8a14
checking lint errors for platfrom controller
Behzad-rabiei Mar 5, 2024
fe315a9
refactor the code
Behzad-rabiei Mar 5, 2024
5831458
refactor the code
Behzad-rabiei Mar 5, 2024
8fe92ac
refactor the code
Behzad-rabiei Mar 5, 2024
086442f
checking lint errors for platfrom controller
Behzad-rabiei Mar 5, 2024
c27901e
Merge branch 'development' into ci
Behzad-rabiei Mar 5, 2024
f4e6596
format the code
Behzad-rabiei Mar 5, 2024
6547eb2
format the code
Behzad-rabiei Mar 5, 2024
1a6a804
checking lint errors for ouath2 file
Behzad-rabiei Mar 5, 2024
8a93bc9
format the code
Behzad-rabiei Mar 5, 2024
bbe09bc
fixing lint issue with platform controller
Behzad-rabiei Mar 6, 2024
c65498d
working on member activity tests
Behzad-rabiei Mar 6, 2024
c6328f4
format the code
Behzad-rabiei Mar 6, 2024
9e9f537
working on tests db connection
Behzad-rabiei Mar 6, 2024
0f62e1c
working on tests db connection
Behzad-rabiei Mar 6, 2024
d5eb5cb
format the code
Behzad-rabiei Mar 6, 2024
3a74e68
format the code
Behzad-rabiei Mar 6, 2024
975b58d
checking test issues
Behzad-rabiei Mar 7, 2024
bc063bd
checking test issues
Behzad-rabiei Mar 7, 2024
00b2f08
change jest config
Behzad-rabiei Mar 7, 2024
6d7ec41
change jest
Behzad-rabiei Mar 7, 2024
0029e38
format code
Behzad-rabiei Mar 7, 2024
782b38a
disable the tests
Behzad-rabiei Mar 7, 2024
b2aeeb1
format code
Behzad-rabiei Mar 7, 2024
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
11 changes: 5 additions & 6 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
node_modules
logs
*.log
coverage
lib
.idea
.github/
coverage/
dist/
node_modules/
.env
23 changes: 12 additions & 11 deletions .eslintrc.json
Original file line number Diff line number Diff line change
@@ -1,20 +1,21 @@
{
"env": {
"browser": true,
"es2021": true
"es2021": true,
"node": true
},
"extends": [
"eslint:recommended",
"plugin:@typescript-eslint/recommended"
],
"overrides": [],
"parser": "@typescript-eslint/parser",
"parserOptions": {
"ecmaVersion": "latest",
"sourceType": "module"
"sourceType": "module",
"project": "./tsconfig.json"
},
"plugins": [
"@typescript-eslint"
],
"rules": {}
"rules": {},
"ignorePatterns": [
"coverage",
"dist",
"__tests__/",
"jest.config.ts",
"*.yml"
]
}
11 changes: 11 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
---
name: CI Pipeline

on:
push:

jobs:
ci:
uses: TogetherCrew/operations/.github/workflows/ci.yml@main
secrets:
CC_TEST_REPORTER_ID: ${{ secrets.CC_TEST_REPORTER_ID }}
12 changes: 12 additions & 0 deletions .github/workflows/production.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
name: Production CI/CD Pipeline

on:
push:
branches:
- main

jobs:
ci:
uses: TogetherCrew/operations/.github/workflows/ci.yml@main
secrets:
CC_TEST_REPORTER_ID: ${{ secrets.CC_TEST_REPORTER_ID }}
12 changes: 12 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
---
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 }}
5 changes: 5 additions & 0 deletions .prettierrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"printWidth": 120,
"trailingComma": "all",
"singleQuote": true
}
5 changes: 5 additions & 0 deletions .textlintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"plugins": {},
"filters": {},
"rules": {}
}
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ COPY . .
RUN npm ci

FROM base AS test
CMD [ "npx", "jest", "--coverage" ]
CMD [ "npx", "jest", "--runInBand", "--coverage" ]

FROM base AS build
RUN npm run build
Expand Down
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
# ServerComm
All communcation between front-end and DB
All communcation between frontend and DB

[![Maintainability](https://api.codeclimate.com/v1/badges/ad9db42ef0a42bb21764/maintainability)](https://codeclimate.com/github/TogetherCrew/api/maintainability)
[![Test Coverage](https://api.codeclimate.com/v1/badges/ad9db42ef0a42bb21764/test_coverage)](https://codeclimate.com/github/TogetherCrew/api/test_coverage)

## Installation

Clone the repo
Clone the repository

Install the dependencies:

Expand All @@ -33,10 +33,10 @@ Run tests:
npm run test
```

## Neo4j Server
## Neo4j Server

Below is a command for starting a Neo4j container in Docker
```
```bash
docker run \
-d \
--publish=7474:7474 --publish=7687:7687 \
Expand Down
3 changes: 0 additions & 3 deletions TODO.md

This file was deleted.

134 changes: 77 additions & 57 deletions __tests__/fixtures/announcement.fixture.ts
Original file line number Diff line number Diff line change
@@ -1,66 +1,86 @@
import { Announcement, IAnnouncement } from '@togethercrew.dev/db';
import { Types } from 'mongoose';

type AnnouncementDataFixture = Array<IAnnouncement['data'][0] & { type: string }>
type AnnouncementFixture = Pick<IAnnouncement, 'title' | 'scheduledAt' | 'draft' | 'community' | 'createdBy' | 'updatedBy'> & { _id: Types.ObjectId, data: AnnouncementDataFixture };
type AnnouncementDataFixture = Array<IAnnouncement['data'][0] & { type: string }>;
type AnnouncementFixture = Pick<
IAnnouncement,
'title' | 'scheduledAt' | 'draft' | 'community' | 'createdBy' | 'updatedBy'
> & { _id: Types.ObjectId; data: AnnouncementDataFixture };

export const generatePublicDiscordAnnouncement = (communityId: Types.ObjectId, platformId: Types.ObjectId, channelIds: string[]): AnnouncementFixture => ({
_id: new Types.ObjectId(),
title: "Announcement One",
scheduledAt: new Date(),
draft: false,
community: communityId,
data: [{
platform: platformId,
type: "discord_public",
template: "Hello World",
options: {
channelIds: channelIds,
},
}],
createdBy: new Types.ObjectId(),
updatedBy: new Types.ObjectId(),
export const generatePublicDiscordAnnouncement = (
communityId: Types.ObjectId,
platformId: Types.ObjectId,
channelIds: string[],
): AnnouncementFixture => ({
_id: new Types.ObjectId(),
title: 'Announcement One',
scheduledAt: new Date(),
draft: false,
community: communityId,
data: [
{
platform: platformId,
type: 'discord_public',
template: 'Hello World',
options: {
channelIds: channelIds,
},
},
],
createdBy: new Types.ObjectId(),
updatedBy: new Types.ObjectId(),
});

export const generatePrivateUserDiscordAnnouncement = (communityId: Types.ObjectId, platformId: Types.ObjectId, userIds: any[]): AnnouncementFixture => ({
_id: new Types.ObjectId(),
title: "Announcement Two",
scheduledAt: new Date(),
draft: false,
community: communityId,
data: [{
platform: platformId,
type: "discord_private",
template: "Hello api world",
options: {
userIds: userIds,
},
}],
createdBy: new Types.ObjectId(),
updatedBy: new Types.ObjectId(),
})
export const generatePrivateUserDiscordAnnouncement = (
communityId: Types.ObjectId,
platformId: Types.ObjectId,
userIds: any[],
): AnnouncementFixture => ({
_id: new Types.ObjectId(),
title: 'Announcement Two',
scheduledAt: new Date(),
draft: false,
community: communityId,
data: [
{
platform: platformId,
type: 'discord_private',
template: 'Hello api world',
options: {
userIds: userIds,
},
},
],
createdBy: new Types.ObjectId(),
updatedBy: new Types.ObjectId(),
});

export const generatePrivateRoleDiscordAnnouncement = (communityId: Types.ObjectId, platformId: Types.ObjectId, roleIds: any[]): AnnouncementFixture => ({
_id: new Types.ObjectId(),
title: "Announcement Three",
scheduledAt: new Date(),
draft: false,
community: communityId,
data: [{
platform: platformId,
type: "discord_private",
template: "Sample Template",
options: {
roleIds: roleIds,
},
}],
createdBy: new Types.ObjectId(),
updatedBy: new Types.ObjectId(),
})
export const generatePrivateRoleDiscordAnnouncement = (
communityId: Types.ObjectId,
platformId: Types.ObjectId,
roleIds: any[],
): AnnouncementFixture => ({
_id: new Types.ObjectId(),
title: 'Announcement Three',
scheduledAt: new Date(),
draft: false,
community: communityId,
data: [
{
platform: platformId,
type: 'discord_private',
template: 'Sample Template',
options: {
roleIds: roleIds,
},
},
],
createdBy: new Types.ObjectId(),
updatedBy: new Types.ObjectId(),
});

export const insertAnnouncement = async (announcements: AnnouncementFixture[]) => {
for (const announcement of announcements) {
await Announcement.create(announcement);
}
}

for (const announcement of announcements) {
await Announcement.create(announcement);
}
};
33 changes: 16 additions & 17 deletions __tests__/fixtures/community.fixture.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,32 +2,31 @@ import { Types } from 'mongoose';
import { Community } from '@togethercrew.dev/db';

interface CommunityFixture {
_id: Types.ObjectId;
name: string;
avatarURL?: string;
users?: Types.ObjectId[];
platforms?: Types.ObjectId[];
_id: Types.ObjectId;
name: string;
avatarURL?: string;
users?: Types.ObjectId[];
platforms?: Types.ObjectId[];
}


export const communityOne: CommunityFixture = {
_id: new Types.ObjectId(),
name: "Community Alpha",
avatarURL: "path/to/avatar1.png",
_id: new Types.ObjectId(),
name: 'Community Alpha',
avatarURL: 'path/to/avatar1.png',
};

export const communityTwo: CommunityFixture = {
_id: new Types.ObjectId(),
name: "Community Beta",
_id: new Types.ObjectId(),
name: 'Community Beta',
};

export const communityThree: CommunityFixture = {
_id: new Types.ObjectId(),
name: "Community Teta",
_id: new Types.ObjectId(),
name: 'Community Teta',
};

export const insertCommunities = async function <Type>(communities: Array<Type>) {
for (const community of communities) {
await Community.create(community);
}
};
for (const community of communities) {
await Community.create(community);
}
};
Loading