Skip to content

Commit

Permalink
Merge pull request #10 from spudde123/develop
Browse files Browse the repository at this point in the history
feat: poetry project, updated build file and new CI workflow
  • Loading branch information
spudde123 authored Sep 6, 2023
2 parents 99fa7af + 0a45a71 commit be47798
Show file tree
Hide file tree
Showing 57 changed files with 3,476 additions and 724 deletions.
9 changes: 9 additions & 0 deletions .flake8
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# .flake8
[flake8]
max-line-length = 88
extend-ignore = E203, F631
per-file-ignores =
*/__init__.py: F401
exclude =
tests/test_docs.py
run.py # should be removed?
43 changes: 43 additions & 0 deletions .github/workflows/build_c_extension.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
name: BuildCExtension
on:
push:
branches: [ master, develop ]

jobs:
build:
name: Build release

runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
# TODO: Get this working on ubuntu-latest. Refuses to build, and no idea why
os: [windows-latest, macos-latest]
python-version: ['3.11']

steps:
# check-out repo
- name: Checkout repository
uses: actions/checkout@v3
with:
ref: ${{ github.head_ref }}
# install poetry
- name: Install poetry
run: pipx install poetry==1.5
# set-up python with cache
- name: Setup Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
cache: 'poetry'
# Install requirements and build extension
- name: Install requirements and build extension
run: |
poetry install --with dev
python -c "import shutil, glob, os; [shutil.copy(f, '.') for f in glob.glob('mapanalyzerext*') if not os.path.exists(os.path.join('.', os.path.basename(f)))]"
- uses: actions/upload-artifact@v3
with:
name: ${{ matrix.os }}_python${{ matrix.python-version }}
path: |
./mapanalyzerext*
mapanalyzerext*
37 changes: 0 additions & 37 deletions .github/workflows/build_on_setup.yml

This file was deleted.

31 changes: 31 additions & 0 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
name: Linting

on:
pull_request:
branches: [ master, develop ]
workflow_call:

jobs:
build:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ ubuntu-latest ]
python-version: [ 3.11 ]

steps:
# check-out repo
- uses: actions/checkout@v2
- name: Set up ${{ matrix.python-version }}
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
pipx install poetry==1.6.1
poetry install --with dev
# run linters
- name: Run linters
run: |
set -o pipefail
poetry run make lint
21 changes: 21 additions & 0 deletions .github/workflows/orchestrator.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
name: Orchestrator

on:
push:
branches:
- master

jobs:
call-testing-pipeline:
name: Testing
uses: ./.github/workflows/tests.yml
call-linting-pipeline:
name: Linting
uses: ./.github/workflows/lint.yml
call-release-pipeline:
name: Release
needs:
- call-testing-pipeline
- call-linting-pipeline
uses: ./.github/workflows/release.yml
secrets: inherit
39 changes: 39 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
name: Release

on:
workflow_call:

jobs:
release:
runs-on: ubuntu-latest
concurrency: release

steps:
# check-out repo
- name: Checkout repository
uses: actions/checkout@v3
with:
ref: ${{ github.head_ref }}
# install poetry
- name: Install poetry
run: pipx install poetry==1.6.1
# set-up python with cache
- name: Setup Python 3.11
uses: actions/setup-python@v4
with:
python-version: '3.11'
cache: 'poetry'
# install requirements
- name: Install requirements
run: poetry install --only semver
# semantic release
- name: Python Semantic Release
env:
GH_TOKEN: ${{ secrets.GH_TOKEN_MA }}
run: |
set -o pipefail
# Set git details
git config --global user.name "github-actions"
git config --global user.email "github-actions@github.com"
# run semantic-release
poetry run semantic-release publish -v DEBUG -D commit_author="github-actions <action@github.com>"
15 changes: 15 additions & 0 deletions .github/workflows/semantic_pull_request.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
name: "Lint PR"
on:
pull_request_target:
types:
- opened
- edited
- synchronize
jobs:
main:
name: Validate PR title
runs-on: ubuntu-latest
steps:
- uses: amannn/action-semantic-pull-request@v5
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
36 changes: 36 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
name: RunTests

on:
pull_request:
branches: [ master, develop ]
workflow_call:


jobs:
build:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
python-version: [3.11]

steps:
- uses: actions/checkout@v2
- name: Set up ${{ matrix.python-version }}
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
pipx install poetry==1.6.1
poetry install --with dev
- name: Test with pytest + Coverage
run: |
poetry run pytest --html=html/${{ matrix.os }}-test-results-${{ matrix.python-version }}.html
- name: Upload pytest test results
uses: actions/upload-artifact@v2
with:
name: pytest-results-${{ matrix.os }}-${{ matrix.python-version }}
path: html/${{ matrix.os }}-test-results-${{ matrix.python-version }}.html
# Use always() to always run this step to publish test results when there are test failures
if: ${{ always() }}
27 changes: 27 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
format-black:
@black .
format-isort:
@isort .
lint-black:
@black . --check
lint-isort:
@isort . --check
lint-flake8:
@flake8 .

lint: lint-black lint-isort lint-flake8

current-version:
@semantic-release print-version --current

next-version:
@semantic-release print-version --next

current-changelog:
@semantic-release changelog --released

next-changelog:
@semantic-release changelog --unreleased

publish-noop:
@semantic-release publish --noop
16 changes: 7 additions & 9 deletions MapAnalyzer/Debugger.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import os
import sys
import warnings
from typing import Any, Dict, Optional, Tuple, TYPE_CHECKING, Union
from typing import TYPE_CHECKING, Any, Dict, Optional, Tuple, Union

import numpy as np
from loguru import logger
Expand Down Expand Up @@ -74,10 +74,9 @@ def close():

@staticmethod
def save(filename: str) -> bool:

for i in inspect.stack():
if "test_suite.py" in str(i):
logger.info(f"Skipping save operation on test runs")
logger.info("Skipping save operation on test runs")
logger.debug(f"index = {inspect.stack().index(i)} {i}")
return True
import matplotlib.pyplot as plt
Expand Down Expand Up @@ -164,12 +163,11 @@ def plot_chokes(self) -> None:
)
plt.scatter(x, y, color="w")
elif choke.is_vision_blocker:

fontdict = {"family": "serif", "size": 10}
plt.text(
cm[0],
cm[1],
f"VB<>",
"VB<>",
fontdict=fontdict,
bbox=dict(fill=True, alpha=0.3, edgecolor="red", linewidth=2),
)
Expand Down Expand Up @@ -211,14 +209,14 @@ def plot_chokes(self) -> None:
plt.text(
choke.side_a[0],
choke.side_a[1],
f"sA>",
"sA>",
fontdict=fontdict,
bbox=dict(fill=True, alpha=0.5, edgecolor="green", linewidth=2),
)
plt.text(
choke.side_b[0],
choke.side_b[1],
f"sB>",
"sB>",
fontdict=fontdict,
bbox=dict(fill=True, alpha=0.5, edgecolor="red", linewidth=2),
)
Expand Down Expand Up @@ -281,8 +279,8 @@ def plot_influenced_path(
fontdict: dict = None,
) -> None:
import matplotlib.pyplot as plt
from mpl_toolkits.axes_grid1 import make_axes_locatable
from matplotlib.cm import ScalarMappable
from mpl_toolkits.axes_grid1 import make_axes_locatable

if not fontdict:
fontdict = {"family": "serif", "weight": "bold", "size": 20}
Expand Down Expand Up @@ -334,8 +332,8 @@ def plot_influenced_path_nydus(
fontdict: dict = None,
) -> None:
import matplotlib.pyplot as plt
from mpl_toolkits.axes_grid1 import make_axes_locatable
from matplotlib.cm import ScalarMappable
from mpl_toolkits.axes_grid1 import make_axes_locatable

if not fontdict:
fontdict = {"family": "serif", "weight": "bold", "size": 20}
Expand Down
Loading

0 comments on commit be47798

Please sign in to comment.