Skip to content

Commit

Permalink
BETA VERSION 0.68.0 (#1849)
Browse files Browse the repository at this point in the history
  • Loading branch information
Mittelblut9 authored Jan 16, 2024
2 parents 9b2981a + 8a0de48 commit a112001
Show file tree
Hide file tree
Showing 15 changed files with 305 additions and 322 deletions.
34 changes: 1 addition & 33 deletions .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
@@ -1,19 +1,7 @@
# For most projects, this workflow file will not need changing; you simply need
# to commit it to your repository.
#
# You may wish to alter this file to override the set of languages analyzed,
# or to provide custom queries or build logic.
#
# ******** NOTE ********
# We have attempted to detect the languages in your repository. Please check
# the `language` matrix defined below to confirm you have the correct set of
# supported CodeQL languages.
#
name: 'CodeQL'

on:
pull_request:
# The branches below must be a subset of the branches above
branches: [beta, main, dev]
schedule:
- cron: '31 5 * * 5'
Expand All @@ -31,39 +19,19 @@ jobs:
fail-fast: false
matrix:
language: ['javascript']
# CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python', 'ruby' ]
# Learn more about CodeQL language support at https://git.io/codeql-language-support

steps:
- name: Checkout repository
uses: actions/checkout@v3
uses: actions/checkout@v4

# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
uses: github/codeql-action/init@v1
with:
languages: ${{ matrix.language }}
source-root: ./
# If you wish to specify custom queries, you can do so here or in a config file.
# By default, queries listed here will override any specified in a config file.
# Prefix the list here with "+" to use these queries and those in the config file.
# queries: ./path/to/local/query, your-org/your-repo/queries@main

# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
# If this step fails, then you should remove it and run the build manually (see below)
- name: Autobuild
uses: github/codeql-action/autobuild@v1

# ℹ️ Command-line programs to run using the OS shell.
# 📚 https://git.io/JvXDl

# ✏️ If the Autobuild fails above, remove it and uncomment the following three lines
# and modify them (or add more) to build your code if your project
# uses a compiled language

#- run: |
# make bootstrap
# make release

- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v1
11 changes: 7 additions & 4 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,22 @@ on:
types: [published]

jobs:
test:
uses: ./.github/workflows/test-build.yml
deploy:
runs-on: self-hosted
needs: test

steps:
- name: Checkout code
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
ref: beta

- name: Setup Node.js
uses: actions/setup-node@v3
uses: actions/setup-node@v4
with:
node-version: 18
node-version: 20

- name: Install dependencies
run: npm install --omit=dev
Expand Down Expand Up @@ -47,7 +50,7 @@ jobs:
- name: Build
run: |
npm run restart-prod
docker compose down && docker compose up -d
- name: Stop Workflow
if: steps.check_condition.outputs.stop_workflow == 'true'
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/first-interaction.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:
check_for_first_interaction:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- uses: actions/first-interaction@main
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}
Expand Down
4 changes: 1 addition & 3 deletions .github/workflows/prettier.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
name: Code Check

on:
pull_request_target:
branches: [dev, main, beta]
push:
branches: [dev]

Expand All @@ -12,7 +10,7 @@ jobs:

steps:
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
# Make sure the actual branch is checked out when running on pull requests
ref: ${{ github.head_ref }}
Expand Down
61 changes: 52 additions & 9 deletions .github/workflows/test-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,36 +3,79 @@ name: Deployment Test Build
on:
pull_request:
branches: [dev, main, beta]
workflow_call:

jobs:
prettier:
runs-on: ubuntu-latest

steps:
- name: Checkout
uses: actions/checkout@v3
with:
# Make sure the actual branch is checked out when running on pull requests
ref: ${{ github.head_ref }}
# This is important to fetch the changes to the previous commit
fetch-depth: 0

- name: Prettify code
uses: creyD/[email protected]
with:
prettier_options: '--config .tools/prettier/.prettierrc --ignore-path .tools/prettier/.prettierignore --check . --single-quote --bracket-same-line=true'
dry: true
only_changed: True
test:
runs-on: ubuntu-latest
needs: prettier
steps:
- uses: actions/checkout@v4

- name: Setup Node
uses: actions/setup-node@v4
with:
node-version: 20

- name: Install Dependencies
run: npm install

- name: Run Tests
run: npm test

test-deploy:
runs-on: ubuntu-latest
needs: test
steps:
- name: Checkout code
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Setup Node.js
uses: actions/setup-node@v3
uses: actions/setup-node@v4
with:
node-version: 18
node-version: 20

- name: Install test env data
run: |
cp .env.example .env
echo ${{ secrets.TEST_TOKEN }} >> .env
echo ${{ secrets.TEST_TOKEN }} >> .env
echo ${{ secrets.TEST_SECRET }} >> .env
echo ${{ secrets.TEST_APPLICATION_ID }} >> .env
echo ${{ secrets.TEST_DEVELOPER_DISCORD_GUILD_ID }} >> .env
- name: Install important data
- name: Start Container
run: |
NODE_ENV=production docker compose up -d
- name: Wait 60 seconds and check if all containers are healthy
run: |
npm run start-prod
docker compose exec bot npm install --omit=dev
docker compose exec bot npm run alias-build
sleep 60
docker ps -a
docker inspect --format='{{json .State.Health}}' mittelbot
docker inspect --format='{{json .State.Health}}' mittelbot-mysql
- name: Build
- name: Stop Container
run: |
npm run restart-prod
npm run stop
- name: Stop Workflow
if: steps.check_condition.outputs.stop_workflow == 'true'
Expand Down
21 changes: 0 additions & 21 deletions .github/workflows/tests.yml

This file was deleted.

3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ node_modules/
.DS_Store
._*

./core
core
!bot/core

.env
.env.prod
Expand Down
21 changes: 0 additions & 21 deletions Dockerfile

This file was deleted.

24 changes: 8 additions & 16 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,11 @@ Anyone is welcome to contribute to this project and add a "how to host" guide to

<br>

## Performance
This project is designed to run on a server with at least 4GB of RAM and 2 CPU cores.

<br>

---

<br>
Expand Down Expand Up @@ -119,31 +124,18 @@ YT_KEY= #Your Youtube API Key to run the youtube notifier

<br>

3. Execute the install script
3. Start Docker
```bash
# Linux
bash ./scripts/install-linux.sh

# Windows
./scripts/install-windows.bat

npm run start
```

<br>

4. View all commands
4. View all commands (development only)

Go to your bot direct message and send `deploycommands`. You will notice, that in your console the commands will be deployed and updated.


<br>

## **Known Issues**

![](./docs/readme/module_not_found.png)

**Fix:** Run the install script again. If this doesn't work, please open an issue.

<br>

-----------------------
Expand Down
5 changes: 3 additions & 2 deletions bot/core/core.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ module.exports.startBot = async (bot) => {
await database.init();
await setActivity(bot, true);
await Promise.resolve(this.fetchCache(bot));
await bot.player.extractors.loadDefault();
//await bot.player.extractors.loadDefault();
new Music(null, bot, true).generateQueueAfterRestart();

/**
Expand All @@ -39,7 +39,8 @@ module.exports.startBot = async (bot) => {
----END ----
*/

bot.commands = (await loadCommandList(bot)).cmd;
const botList = await loadCommandList(bot);
bot.commands = botList.cmd;

setActivity(bot);
if (process.env.NODE_ENV === 'production') {
Expand Down
27 changes: 19 additions & 8 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,25 +3,32 @@ version: '3.9'
volumes:
mysql:

networks:
app:
driver: bridge

services:
bot:
image: node:20.9
working_dir: /app
container_name: mittelbot
build:
context: .
dockerfile: Dockerfile
args:
- NODE_ENV=development
restart: unless-stopped
environment:
- NODE_ENV=development
links:
- mysql
- TZ=Europe/Berlin
env_file:
- ./.env
volumes:
- .:/app
ports:
- 5000:5000
command: >
sh -c 'if [ "$NODE_ENV" = "development" ]; then
npm install -g nodemon && npm install && npm run alias-build && ls -la /app/bot/core && node ./bot/core/shard.js
else
npm install && npm run alias-build && node bot/core/shard.js
fi'
networks:
- app

mysql:
container_name: mittelbot-mysql
Expand All @@ -46,6 +53,8 @@ services:
test: ['CMD', 'mysqladmin', 'ping', '-h', 'localhost']
timeout: 5s
retries: 10
networks:
- app

mysql-backup:
image: fradelg/mysql-cron-backup
Expand All @@ -64,3 +73,5 @@ services:
- TIMEOUT=10s
- INIT_BACKUP=1
- MAX_BACKUPS=7
networks:
- app
Loading

0 comments on commit a112001

Please sign in to comment.