Skip to content

Commit

Permalink
feat: added gRPC into Node.js (skyra-project#1612)
Browse files Browse the repository at this point in the history
* feat: added gRPC into Node.js

- chore: fixed so the code compiles
- refactor: move to workspace structure
- refactor: move dist to typescript
- fix: nullability warnings in Guild.cs
- fix: change arrays that default to null! to Array<string>.Empty()

* chore: bump c# deps

closes skyra-project#1763
closes skyra-project#1761

Co-authored-by: Jeroen Claassens <[email protected]>
  • Loading branch information
kyranet and favna authored Apr 11, 2021
1 parent 7bbcb3c commit 3df6949
Show file tree
Hide file tree
Showing 1,716 changed files with 3,100 additions and 5,947 deletions.
6 changes: 3 additions & 3 deletions .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,19 +9,19 @@
},
"overrides": [
{
"files": ["src/commands/**/*.ts", "jest.config.ts"],
"files": ["typescript/src/commands/**/*.ts", "typescript/**/jest.config.ts"],
"rules": {
"@typescript-eslint/require-await": 0
}
},
{
"files": ["src/lib/structures/commands/*.ts"],
"files": ["typescript/src/lib/structures/commands/*.ts"],
"rules": {
"@typescript-eslint/no-namespace": 0
}
},
{
"files": ["src/lib/types/definitions/*.ts"],
"files": ["typescript/src/lib/types/definitions/*.ts"],
"rules": {
"@typescript-eslint/no-namespace": 0
}
Expand Down
2 changes: 1 addition & 1 deletion .github/CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ To run Skyra locally a few steps should be taken.
1. Follow [the wiki page on setting up a PostgreSQL schema for Skyra][].
1. In the Discord Developer portal go to your application and then to the "Bot" menu.
1. At "Privileged Gateway Intents" enable "SERVER MEMBERS INTENT".
1. Copy and paste the [`.env.development`] file in the `src` directory and rename it to `.env.development.local`.
1. Copy and paste the [`.env.development`] file in the `typescript/src` directory and rename it to `.env.development.local`.
1. Scroll down to the tokens section.
1. At this section enter your own bot's API token at `DISCORD_TOKEN`.
1. Fill in any other API keys you have / want to fill in.
Expand Down
73 changes: 65 additions & 8 deletions .github/workflows/continuous-integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -70,11 +70,11 @@ jobs:
path: node_modules
key: ${{ runner.os }}-15-${{ hashFiles('**/yarn.lock') }}
- name: Install Dependencies
run: yarn --ignore-scripts --frozen-lockfile
run: yarn --frozen-lockfile
- name: Run tsc
run: yarn build

NodeTesting:
NodeUnitTesting:
name: Unit Tests
runs-on: ubuntu-latest
if: "!contains(needs.pre_ci.outputs.commit_message, '[skip ci]')"
Expand All @@ -97,24 +97,81 @@ jobs:
yarn global add node-gyp node-pre-gyp
- name: Install Dependencies
run: yarn --frozen-lockfile
- name: Run tests
run: yarn test --coverage
- name: Run gRPC generator script
run: yarn scripts:grpc
- name: Run unit tests
run: yarn test:unit --coverage
- name: Store code coverage report
uses: actions/upload-artifact@v2
with:
name: nodejs-coverage
path: coverage/

NodeIntegrationTesting:
name: Integration Tests
runs-on: ubuntu-latest
if: "!contains(needs.pre_ci.outputs.commit_message, '[skip ci]')"
needs: pre_ci
services:
postgres:
image: ghcr.io/skyra-project/postgres:latest
env:
POSTGRES_DB: skyra-nodejs-test
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
ports:
- 5432:5432
grpc:
image: ghcr.io/skyra-project/grpc:latest
env:
POSTGRES_DB: skyra-nodejs-test
POSTGRES_HOST: postgres
ports:
- '8291:80'
steps:
- name: Checkout Project
uses: actions/checkout@v2
- name: Use Node.js v15
uses: actions/setup-node@v2
with:
node-version: 15
- name: Restore CI Cache
uses: actions/[email protected]
with:
path: node_modules
key: ${{ runner.os }}-15-${{ hashFiles('**/yarn.lock') }}
- name: Install Dependencies
run: yarn --frozen-lockfile
- name: Run gRPC generator script
run: yarn scripts:grpc
- name: Wait for Skyra.Grpc
run: |
while ! nc -z localhost 8291; do
sleep 0.1 # wait for 1/10 of the second before check again
done
- name: Run EntityFramework migrations
run: |
dotnet new tool-manifest
dotnet tool install dotnet-ef
dotnet tool run dotnet-ef database update -p Skyra.Database
working-directory: services
env:
POSTGRES_DB: skyra-nodejs-test
- name: Run Integration Tests
run: yarn test:it

DotNetCI:
name: Dotnet Build & Test
runs-on: ubuntu-latest
if: "!contains(needs.pre_ci.outputs.commit_message, '[skip ci]')"
needs: pre_ci
services:
postgres:
image: postgres:12
image: ghcr.io/skyra-project/postgres:latest
env:
POSTGRES_PASSWORD: postgres
POSTGRES_DB: skyra-dotnet-test
options: >-
--health-cmd pg_isready
Expand Down Expand Up @@ -145,7 +202,7 @@ jobs:
dotnet tool install dotnet-ef
dotnet tool run dotnet-ef database update --project services/Skyra.Database
dotnet run --project services/Skyra.Grpc &
while ! nc -z localhost 5000; do
while ! nc -z localhost 8291; do
sleep 0.1 # wait for 1/10 of the second before check again
done
dotnet test services/Skyra.IntegrationTests --collect:"XPlat Code Coverage" --settings services/coverlet.runsettings
Expand All @@ -166,7 +223,7 @@ jobs:
name: Upload coverage report to codecov
needs:
- DotNetCI
- NodeTesting
- NodeUnitTesting
runs-on: ubuntu-latest
steps:
- name: Checkout Project
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ node_modules/
*.iml
/rethinkdb_data/
coverage/
generated/

# Environment variables
.DS_Store
Expand Down
2 changes: 1 addition & 1 deletion .gqlconfig
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
query: {
files: [
{
match: { include: 'src/lib/util/APIs/Pokemon.ts' },
match: { include: 'typescript/src/lib/util/APIs/Pokemon.ts' },
parser: ['EmbeddedQueryParser', { startTag: 'gql`', endTag: '`' }]
}
]
Expand Down
3 changes: 2 additions & 1 deletion .prettierignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
src/languages/**/*.json
**/languages/**/*.json
dist/
2 changes: 2 additions & 0 deletions .yarnrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
--add.ignore-workspace-root-check true
--remove.ignore-workspace-root-check true
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@
same "printed page" as the copyright notice for easier
identification within third-party archives.

Copyright 2019-2020 Antonio Román
Copyright 2019 Skyra Project

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand Down
4 changes: 2 additions & 2 deletions crowdin.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@ commit_message: 'chore(i18n-crowdin): new translations for %original_file_name%
append_commit_message: false

files:
- source: /src/languages/en-US/**/*.json
translation: /src/languages/%locale%/**/%original_file_name%
- source: /typescript/src/languages/en-US/**/*.json
translation: /typescript/src/languages/%locale%/**/%original_file_name%
9 changes: 0 additions & 9 deletions docker/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,15 +1,6 @@
version: '2.4'
services:
protos:
build:
context: ../assets/protos
command: exit 1
image: ghcr.io/skyra-project/grpc-protofiles:latest
networks:
- skyra
grpc:
build:
context: ../services
image: skyrabot/grpc:latest
container_name: 'skyra-grpc'
depends_on:
Expand Down
43 changes: 0 additions & 43 deletions jest.config.ts

This file was deleted.

7 changes: 4 additions & 3 deletions lgtm.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ extraction:
javascript:
index:
include:
- src
- tests
- typescript/src
- typescript/unit-tests
- typescript/integration-tests
filters:
- exclude: "src/languages/**/*.json"
- exclude: 'typescript/src/languages/**/*.json'
2 changes: 1 addition & 1 deletion ormconfig.js
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
// eslint-disable-next-line @typescript-eslint/no-var-requires
module.exports = require('./dist/lib/database/database.config').config;
module.exports = require('./typescript/dist/lib/database/database.config').config;
Loading

0 comments on commit 3df6949

Please sign in to comment.