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

40: Update to latest python template. #41

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
111 changes: 57 additions & 54 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,42 +3,67 @@ name: Build-Test-Lint-etc (linux)
on: [push]

jobs:

flake8-lint:
setup:
runs-on: ubuntu-latest
name: Lint
strategy:
fail-fast: false
matrix:
python-version: [ "3.11" ]
name: Setup
steps:
- name: Check out source repository
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up Python environment
- uses: actions/checkout@v3
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: 3.11
- name: flake8 Lint
uses: TrueBrain/actions-flake8@v2
python-version: ${{ matrix.python-version }}
cache: 'pip'
- run: |
./ci/linux/create_venv.sh
./ci/linux/install_dependencies.sh
- name: 'Tar venv'
run: tar -cvf venv.tar ./.venv/
- name: Save venv
uses: actions/upload-artifact@v4
with:
plugins: Flake8-pyproject==1.2.3 flake8-docstrings==1.7.0 flake8-quotes==3.3.2 flake8-bugbear==23.9.16 flake8-mock==0.4 flake8-tuple==0.4.1
# only_warn: 1 #causes action to always be succesful, but still provide annotations
path: ./venv.tar
name: ${{ runner.os }}-python-${{ matrix.python-version }}-venv-${{github.run_id}}

test:
lint:
name: Lint
runs-on: ubuntu-latest
needs: [ setup ]
strategy:
fail-fast: false
matrix:
python-version: ["3.11"]
# python-version: [3.8, 3.9, 3.10, 3.11]
python-version: [ "3.11" ]
steps:
- uses: actions/checkout@v3
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
- name: Restore venv
uses: actions/download-artifact@v4
with:
python-version: ${{ matrix.python-version }}
cache: 'pip'
- run: |
./ci/linux/create_venv.sh
./ci/linux/install_dependencies.sh
name: ${{ runner.os }}-python-${{ matrix.python-version }}-venv-${{github.run_id}}
- name: Untar venv
run: tar -xvf venv.tar
- name: run unit tests
run: |
./ci/linux/lint.sh

test:
name: Test
runs-on: ubuntu-latest
needs: [ setup ]
strategy:
fail-fast: false
matrix:
python-version: [ "3.11" ]
steps:
- uses: actions/checkout@v3
- name: Restore venv
uses: actions/download-artifact@v4
with:
name: ${{ runner.os }}-python-${{ matrix.python-version }}-venv-${{github.run_id}}
- name: Untar venv
run: tar -xvf venv.tar
- name: run unit tests
run: |
./ci/linux/test_unit.sh
Expand Down Expand Up @@ -67,46 +92,24 @@ jobs:
fail-on-empty: true

typecheck:
name: Typecheck
runs-on: ubuntu-latest
needs: [ setup ]
strategy:
fail-fast: false
matrix:
python-version: ["3.11"]
# python-version: [3.8, 3.9, 3.10, 3.11]
python-version: [ "3.11" ]
steps:
- uses: actions/checkout@v3
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
- name: Restore venv
uses: actions/download-artifact@v4
with:
python-version: ${{ matrix.python-version }}
cache: 'pip'
- run: |
./ci/linux/create_venv.sh
./ci/linux/install_dependencies.sh

name: ${{ runner.os }}-python-${{ matrix.python-version }}-venv-${{github.run_id}}
- name: Untar venv
run: tar -xvf venv.tar
- name: Add mypy annotator
uses: pr-annotators/mypy-pr-annotator@v1.0.0

- name: run typechecker
run: |
./ci/linux/typecheck.sh

build:
name: Build the python package
runs-on: ubuntu-latest
strategy:
matrix:
python-version: [ "3.11" ]
steps:
- uses: actions/checkout@v3
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
cache: 'pip'
- run: |
./ci/linux/create_venv.sh
./ci/linux/install_dependencies.sh

- name: build
run: |
./ci/linux/build_python_package.sh
5 changes: 5 additions & 0 deletions ci/linux/_load_dot_env.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/usr/bin/env bash

set -a
source $1
set +a
8 changes: 6 additions & 2 deletions ci/linux/build_python_package.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
#!/usr/bin/env sh
#!/usr/bin/env bash

if [[ "$OSTYPE" != "win32" && "$OSTYPE" != "msys" ]]; then
echo "Activating .venv first."
. .venv/bin/activate
fi

. .venv/bin/activate
python -m build
7 changes: 5 additions & 2 deletions ci/linux/create_venv.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
#!/usr/bin/env sh
#!/usr/bin/env bash

python3 -m venv ./.venv
. .venv/bin/activate
if [[ "$OSTYPE" != "win32" && "$OSTYPE" != "msys" ]]; then
echo "Activating .venv first."
. .venv/bin/activate
fi
pip3 install pip-tools
8 changes: 6 additions & 2 deletions ci/linux/install_dependencies.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
#!/usr/bin/env sh
#!/usr/bin/env bash

if [[ "$OSTYPE" != "win32" && "$OSTYPE" != "msys" ]]; then
echo "Activating .venv first."
. .venv/bin/activate
fi

. .venv/bin/activate
pip-sync ./dev-requirements.txt ./requirements.txt
10 changes: 7 additions & 3 deletions ci/linux/lint.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
#!/usr/bin/env sh
#!/usr/bin/env bash

. .venv/bin/activate
flake8 ./src/simulator_worker
if [[ "$OSTYPE" != "win32" && "$OSTYPE" != "msys" ]]; then
echo "Activating .venv first."
. .venv/bin/activate
fi

flake8 ./src/simulator_worker ./unit_test/
8 changes: 6 additions & 2 deletions ci/linux/test_unit.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
#!/usr/bin/env sh
#!/usr/bin/env bash

if [[ "$OSTYPE" != "win32" && "$OSTYPE" != "msys" ]]; then
echo "Activating .venv first."
. .venv/bin/activate
fi

. .venv/bin/activate
PYTHONPATH='$PYTHONPATH:src/' pytest --junit-xml=test-results.xml unit_test/
8 changes: 6 additions & 2 deletions ci/linux/typecheck.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
#!/usr/bin/env sh
#!/usr/bin/env bash

if [[ "$OSTYPE" != "win32" && "$OSTYPE" != "msys" ]]; then
echo "Activating .venv first."
. .venv/bin/activate
fi

. .venv/bin/activate
python -m mypy ./src/simulator_worker ./unit_test/
12 changes: 8 additions & 4 deletions ci/linux/update_dependencies.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
#!/usr/bin/env sh
#!/usr/bin/env bash

. .venv/bin/activate
pip-compile --output-file=requirements.txt pyproject.toml
pip-compile --extra=dev --output-file=dev-requirements.txt -c requirements.txt pyproject.toml
if [[ "$OSTYPE" != "win32" && "$OSTYPE" != "msys" ]]; then
echo "Activating .venv first."
. .venv/bin/activate
fi

pip-compile --upgrade --output-file=requirements.txt pyproject.toml
pip-compile --upgrade --extra=dev -c requirements.txt --output-file=dev-requirements.txt pyproject.toml
Loading
Loading