-
Notifications
You must be signed in to change notification settings - Fork 2
94 lines (80 loc) · 2.95 KB
/
tests_and_ci.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
name: Tests and CI
on:
pull_request:
push:
branches:
- main
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'
docker-server-buildable:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Build the server image
run: |
docker build . --tag ghcr.io/thearyadev/top500-aggregator-server:latest --file ./Dockerfile.server
docker-frontend-buildable:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Build the frontend image
run: |
docker build . --tag ghcr.io/thearyadev/top500-aggregator-frontend:latest --file ./Dockerfile.frontend
build_and_publish:
runs-on: ubuntu-latest
needs:
- tests
- docker-server-buildable
- docker-frontend-buildable
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
steps:
- uses: actions/checkout@v3
- name: Docker Login
run: |
docker login --username thearyadev --password ${{ secrets.GH_PAT }} ghcr.io
- name: Build Frontend
run: |
docker build . --tag ghcr.io/thearyadev/top500-aggregator-frontend:latest --file ./Dockerfile.frontend
- name: Build Server
run: |
docker build . --tag ghcr.io/thearyadev/top500-aggregator-server:latest --file ./Dockerfile.server
- name: push images
run: |
docker push ghcr.io/thearyadev/top500-aggregator-frontend:latest
docker push ghcr.io/thearyadev/top500-aggregator-server:latest