Skip to content

Commit

Permalink
Merge pull request #22 from nickheyer/INIT_TEST_IMPL
Browse files Browse the repository at this point in the history
TEST AND WORKFLOW IMPL
  • Loading branch information
nickheyer authored Jan 15, 2024
2 parents 004063f + 907bf34 commit 8ff652f
Show file tree
Hide file tree
Showing 19 changed files with 477 additions and 19 deletions.
3 changes: 2 additions & 1 deletion .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,5 @@
__pycache__/
deploy/
data/db.sqlite3
data/django_key.txt
data/django_key.txt
.env
49 changes: 49 additions & 0 deletions .github/workflows/docker-deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
name: Docker Deploy

on:
workflow_run:
workflows: ["Run Tests"]
branches: [main]
types:
- completed
workflow_dispatch:

jobs:
build-and-push:
runs-on: ubuntu-latest

if: >
github.event.workflow_run.conclusion == 'success' ||
github.event_name == 'workflow_dispatch'
steps:
- name: Check out repository
uses: actions/checkout@v2

- name: Log in to Docker Hub
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKER_HUB_USERNAME }}
password: ${{ secrets.DOCKER_HUB_PASSWORD }}

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1

- name: Build and push Docker image for x86
run: |
echo "Building ${app}-image for x86"
docker build -t "${docker_user}/${app}" .
echo "Pushing x86 ${app}-image to dockerhub"
docker push "${docker_user}/${app}"
env:
app: discoflix
docker_user: nickheyer

- name: Build and push Docker image for ARM64
run: |
echo "Building ${app}-image for ARM64"
export DOCKER_CLI_EXPERIMENTAL=enabled
docker buildx build --platform=linux/arm64 -t "${docker_user}/${app}_rpi" . --push
env:
app: discoflix
docker_user: nickheyer
10 changes: 1 addition & 9 deletions .github/workflows/feed.yml
Original file line number Diff line number Diff line change
@@ -1,21 +1,13 @@

name: Update Feed ~ Heyer.app

# Controls when the workflow will run
on:
# Triggers the workflow on push or pull request events but only for the "main" branch
push:
branches: [ "main" ]

# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:
on: push

jobs:

send-request:
runs-on: ubuntu-latest

# Steps represent a sequence of tasks that will be executed as part of the job
steps:

- name: Send
Expand Down
32 changes: 32 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
name: Run Tests

on: push

jobs:
test:
runs-on: ubuntu-latest

steps:
- name: Check out repository
uses: actions/checkout@v2

- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: '3.11'

- name: Cache Python dependencies
uses: actions/cache@v2
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }}
restore-keys: |
${{ runner.os }}-pip-
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
- name: Run pytest
run: pytest
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@ __pycache__/
deploy/
data/db.sqlite3
data/django_key.txt
.env
3 changes: 3 additions & 0 deletions DiscoFlix/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,9 @@ def get_or_create_secret_key():
"default": {
"ENGINE": "django.db.backends.sqlite3",
"NAME": BASE_DIR / "data/db.sqlite3",
"TEST": {
"NAME": BASE_DIR / "data/test_db.sqlite3"
}
}
}

Expand Down
2 changes: 1 addition & 1 deletion DiscoFlixBot/commands/echo.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ class EchoCommand(Command):
def __init__(self) -> None:
super().__init__()
self.name = "echo"
self.permissions = ["user", "developer"]
self.permissions = ["developer"]
self.description = "Confirm bot can respond to messages"
self.aliases = ["echo"]
self.requires_input = True
Expand Down
2 changes: 1 addition & 1 deletion DiscoFlixBot/commands/error.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ class ErrorCommand(Command):
def __init__(self) -> None:
super().__init__()
self.name = "error"
self.permissions = ["user", "developer", "owner"]
self.permissions = ["developer", "owner"]
self.description = "Confirm bot is handling errors as intended"
self.aliases = ["error"]

Expand Down
2 changes: 1 addition & 1 deletion DiscoFlixBot/commands/log.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ class LogCommand(Command):
def __init__(self) -> None:
super().__init__()
self.name = "log"
self.permissions = ["user", "developer", "owner"]
self.permissions = ["developer", "owner"]
self.description = "Confirm bot is logging information to console/server as intended"
self.aliases = ["log"]
self.requires_input = True
Expand Down
2 changes: 1 addition & 1 deletion DiscoFlixBot/commands/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ class TestCommand(Command):
def __init__(self) -> None:
super().__init__()
self.name = "test"
self.permissions = ["owner", "admin", "user"]
self.permissions = ["owner", "admin"]
self.description = "Confirm bot is on and listening"
self.aliases = ["test"]

Expand Down
3 changes: 1 addition & 2 deletions DiscoFlixBot/controller.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
from DiscoFlixClient.utils import get_config, get_config_sync, get_state_sync
from DiscoFlixClient.utils import get_config
from DiscoFlixBot.bot import DiscordBot
import asyncio


async def main():
Expand Down
3 changes: 0 additions & 3 deletions DiscoFlixClient/tests.py

This file was deleted.

Empty file.
Empty file.
Loading

0 comments on commit 8ff652f

Please sign in to comment.