Merge pull request #6 from MarcusElwin/chore/build #54
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: PB API build | |
on: [push] | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
python-version: ["3.8"] | |
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 | |
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi | |
- name: Lint with flake8 | |
run: | | |
# stop the build if there are Python syntax errors or undefined names | |
flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics | |
# exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide | |
flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics | |
- name: Test with pytest | |
run: | | |
pytest tests | |
- name: Run training | |
run: | | |
python train.py | |
- name: Build docker image for API | |
run: | | |
docker build -t latest/pb-api -f Dockerfile . | |
- name: Generate deployment package for API | |
run: | | |
zip -r deploy.zip . -x '*.git*'. | |
- name: Deploy API to EB | |
uses: einaregilsson/beanstalk-deploy@v20 | |
with: | |
aws_access_key: ${{ secrets.AWS_ACCESS_KEY_ID }} | |
aws_secret_key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} | |
application_name: prob-default-api | |
environment_name: Probdefaultapi-env | |
version_label: prob-default-api-${{github.SHA}} | |
use_existing_version_if_available: false | |
version_description: ${{github.SHA}} | |
region: eu-west-1 | |
deployment_package: deploy.zip |