Skip to content

Commit

Permalink
Merge pull request #326 from TogetherCrew/ci
Browse files Browse the repository at this point in the history
Ci
  • Loading branch information
Behzad-rabiei authored Mar 13, 2024
2 parents 49cdc21 + b2aeeb1 commit ef00579
Show file tree
Hide file tree
Showing 138 changed files with 12,732 additions and 10,551 deletions.
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

0 comments on commit ef00579

Please sign in to comment.