Skip to content

Commit

Permalink
Tests (#38)
Browse files Browse the repository at this point in the history
* fix some tests

* add testing workflow

* rename archive file

* add database test steps

* Add mysql port num

* add sleep step to allow mysql to start

* use docker instead of gh action for db server

* attempt to fix connection

* attempt to fix connection

* modify second connection string

* update archive with season 6 data

* run pytest on pr

* combine workflows to allow for conditional exec

* adjust on param

* adjust on param

* fix names
  • Loading branch information
thearyadev committed Jan 19, 2024
1 parent fa11005 commit 8c67803
Show file tree
Hide file tree
Showing 5 changed files with 379 additions and 300 deletions.
14 changes: 0 additions & 14 deletions .github/workflows/ghcr.yml

This file was deleted.

64 changes: 64 additions & 0 deletions .github/workflows/tests_and_ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
name: Tests and CI
on:
pull_request:
push:

jobs:
tests:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3

- name: Start MySQL Server
run: docker run -d -p 3800:3306 --name mysql -e MYSQL_ROOT_PASSWORD=dbtestpassword -e MYSQL_DATABASE=ghworkflow_testdb mysql@sha256:566007208a3f1cc8f9df6b767665b5c9b800fc4fb5f863d17aa1df362880ed04

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

- name: Install MySQL Client
run: sudo apt-get install -y mysql-client

- name: Wait for MySQL Server to Start
run: sleep 10

- name: Add Testing Database
run: mysql -h 127.0.0.1 -u root -pdbtestpassword -P 3800 -e "CREATE DATABASE testing_ghworkflow_testdb;"

- name: Copy data into database
run: mysql -h 127.0.0.1 -u root -pdbtestpassword -P 3800 ghworkflow_testdb < ./archive/latest.sql


- name: Install Poetry
uses: snok/install-poetry@v1
- name: Install Dependencies
run: |
poetry install --no-root --no-interaction
- name: Run Tests
run: |
poetry run pytest
env:
MYSQLDATABASE: 'ghworkflow_testdb'
MYSQLUSER: 'root'
MYSQLPASSWORD: 'dbtestpassword'
MYSQLHOST: 'localhost'
MYSQLPORT: '3800'

TESTING_MYSQLDATABASE: 'testing_ghworkflow_testdb'
TESTING_MYSQLUSER: 'root'
TESTING_MYSQLPASSWORD: 'dbtestpassword'
TESTING_MYSQLHOST: 'localhost'
TESTING_MYSQLPORT: '3800'

build_and_publish:
runs-on: ubuntu-latest
needs: tests
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
steps:
- uses: actions/checkout@v3
- name: Build and push the image
run: |
docker login --username thearyadev --password ${{ secrets.GH_PAT }} ghcr.io
docker build . --tag ghcr.io/thearyadev/top500-aggregator:latest
docker push ghcr.io/thearyadev/top500-aggregator:latest
313 changes: 313 additions & 0 deletions archive/latest.sql

Large diffs are not rendered by default.

284 changes: 0 additions & 284 deletions archive/season_5.sql

This file was deleted.

4 changes: 2 additions & 2 deletions tests/test_database.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ def test_info_table_create():
),
"disclaimer",
)
== None
is None
)


Expand Down Expand Up @@ -79,7 +79,7 @@ def test_season_table_add_entries():
],
),
)
== None
is None
)


Expand Down

0 comments on commit 8c67803

Please sign in to comment.