Test with Python 3.12 #17
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Build | |
on: | |
push: | |
pull_request: | |
jobs: | |
test: | |
name: Test on Python ${{ matrix.python-version }} and ${{ matrix.os }} | |
runs-on: ${{ matrix.os }} | |
strategy: | |
fail-fast: false | |
matrix: | |
python-version: [ 3.8, 3.9, '3.10', '3.11', '3.12' ] | |
os: [ ubuntu-latest, windows-latest ] | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
- name: Set up Python ${{ matrix.python-version }} | |
uses: actions/setup-python@v4 | |
with: | |
python-version: ${{ matrix.python-version }} | |
- name: Install Python packages | |
run: | | |
python -m pip install --upgrade pip | |
pip install -r ./requirements.txt | |
- name: Run tests with pre-trained models | |
run: | | |
pytest --verbose | |
- name: Run tests after retraining models | |
run: | | |
rm ./app/models/* | |
pytest --verbose | |
publish: | |
# Run only if the previous step succeeds (only master branch or new tags, no pull requests). | |
if: (endsWith(github.ref, '/master') || startsWith(github.ref, 'refs/tags/v')) && contains(github.event_name, 'pull_request') == false | |
needs: test | |
name: Push updated version to Docker Hub | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
- name: Login to DockerHub | |
uses: docker/login-action@v3 | |
with: | |
username: claudiugeorgiu | |
password: ${{ secrets.DOCKERHUB_TOKEN }} | |
- name: Docker meta | |
id: meta | |
uses: docker/metadata-action@v5 | |
with: | |
images: claudiugeorgiu/riskindroid | |
tags: | | |
type=raw,value=latest | |
type=semver,pattern={{version}} | |
- name: Build and push | |
uses: docker/build-push-action@v5 | |
with: | |
context: . | |
push: true | |
tags: ${{ steps.meta.outputs.tags }} |