Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ci/setup cicd #2

Merged
merged 12 commits into from
Jul 16, 2023
78 changes: 78 additions & 0 deletions .github/workflows/multi-platform-workflow.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
name: Worflow to test support on multiple platforms


on:
push: # Triggers the workflow on push for whatever branch
paths-ignore: # Pushes that change only these file won't start the workflow
- 'README.md'

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


jobs:
linux-based-support:
strategy:
fail-fast: false
matrix:
os: [ ubuntu-22.04, macos-latest ]
runs-on: ${{ matrix.os }}
steps:
- name: Set up Python 3.10.9
uses: actions/[email protected]
with:
python-version: 3.10.9
- name: Print the version of Python # DEBUG
run: python --version
- name: Checkout the repository
uses: actions/[email protected]
- name: Print repo structure # DEBUG
run: ls -lR
- name: Install dependencies
run: pip install -r ./requirements.txt
- name: Print dependencies # DEBUG
run: pip freeze
- name: Run Flask server tests
run: python -m unittest test/app_test.py

windows-support:
runs-on: windows-latest
steps:
- name: Set up Python 3.10.9
uses: actions/[email protected]
with:
python-version: 3.10.9
- name: Print the version of Python # DEBUG
run: python --version
- name: Checkout the repository
uses: actions/[email protected]
- name: Print repo structure # DEBUG
run: dir && dir gameoflife && dir test
- name: Install dependencies
run: pip install -r ./requirements.txt
- name: Print dependencies # DEBUG
run: pip freeze
- name: Run Flask server tests
run: python -m unittest test/app_test.py

dockerize:
runs-on: ubuntu-22.04
needs:
- linux-based-support
steps:
- name: Set up Python 3.10.9
uses: actions/[email protected]
with:
python-version: 3.10.9
- name: Checkout the repository
uses: actions/[email protected]
- name: Install dependencies
run: pip install -r ./requirements.txt
- name: Build image
run: docker build -t "alecalv/game-of-life:latest" .
- name: Tag also for Github
run: docker tag alecalv/game-of-life:latest ghcr.io/xalessandroc/game-of-life:latest
- name: Log in to Github registry
run: echo "${{ secrets.REGISTRY_TOKEN }}" | docker login ghcr.io -u xAlessandroC --password-stdin
- name: Deliver on Github registry
run: docker push ghcr.io/xalessandroc/game-of-life:latest
Empty file added gameoflife/__init__.py
Empty file.
File renamed without changes.
Empty file added test/__init__.py
Empty file.
12 changes: 12 additions & 0 deletions test/app_test.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import unittest
from gameoflife.app import app


class FlaskApp_TestCase(unittest.TestCase):

def test_main_page(self):
response = app.test_client().get("/")

self.assertEqual(response.status_code, 200)
self.assertEqual(response.data, b"<h1>Conway's Game of Life</h1>")