Skip to content

Commit

Permalink
tests update
Browse files Browse the repository at this point in the history
  • Loading branch information
Azazel0203 committed Mar 31, 2024
1 parent ecdff52 commit 85c40b0
Show file tree
Hide file tree
Showing 5 changed files with 59 additions and 9 deletions.
37 changes: 28 additions & 9 deletions .github/workflows/master_aadocr.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
# Docs for the Azure Web Apps Deploy action: https://github.com/Azure/webapps-deploy
# More GitHub Actions for Azure: https://github.com/Azure/actions

name: Build and deploy container app to Azure Web App - aadocr

on:
Expand All @@ -10,17 +7,39 @@ on:
workflow_dispatch:

jobs:
build:
build-and-test:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, windows-latest]
python-version: ["3.8", "3.9"]

steps:
- uses: actions/checkout@v3
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install flake8 pytest tox tox-gh-actions
pip install -r requirements_dev.txt
- name: Test with tox
run: tox

build-and-deploy-container:
runs-on: 'ubuntu-latest'
needs: build-and-test

steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3

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

- name: Log in to registry
uses: docker/login-action@v2
uses: docker/login-action@v3
with:
registry: https://captchaocr.azurecr.io/
username: ${{ secrets.AzureAppService_ContainerUsername_d6bd5132974749f0a76fc6d17b3791c0 }}
Expand All @@ -35,17 +54,17 @@ jobs:

deploy:
runs-on: ubuntu-latest
needs: build
needs: build-and-deploy-container
environment:
name: 'production'
url: ${{ steps.deploy-to-webapp.outputs.webapp-url }}

steps:
- name: Deploy to Azure Web App
id: deploy-to-webapp
uses: azure/webapps-deploy@v2
uses: azure/webapps-deploy@v3
with:
app-name: 'aadocr'
slot-name: 'production'
publish-profile: ${{ secrets.AzureAppService_PublishProfile_cbb30a72c9734778a7e48dfd3e97d717 }}
images: 'captchaocr.azurecr.io/${{ secrets.AzureAppService_ContainerUsername_d6bd5132974749f0a76fc6d17b3791c0 }}/flask_frontend:${{ github.sha }}'
images: 'captchaocr.azurecr.io/${{ secrets.AzureAppService_ContainerUsername_d6bd5132974749f0a76fc6d17b3791c0 }}/flask_frontend:${{ github.sha }}'
Empty file added tests/__init__.py
Empty file.
4 changes: 4 additions & 0 deletions tests/integration/test_int.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@


def test_empty():
assert True
4 changes: 4 additions & 0 deletions tests/unit/test_unit.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@


def test_empty():
assert True
23 changes: 23 additions & 0 deletions tox.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
[tox]
envlist = python3.7, python3.8, python3.9

[gh-actions]
python =
3.7: python3.7
3.8: python3.8
3.9: python3.9

[testenv]
deps =
-rrequirements_dev.txt
commands =
# stop the build if there are Python syntax errors or undefined names
flake8 src --count --select=E9,F63,F7,F82 --show-source --statistics
# exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
flake8 src --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
# type linting
mypy src/
# pytest unit
pytest -vv tests/test_unit.py
# pytest integration
pytest -vv tests/test_int.py

0 comments on commit 85c40b0

Please sign in to comment.