Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
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
205 changes: 91 additions & 114 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,136 +27,113 @@ jobs:
fetch-depth: 0
ref: ${{ github.event.pull_request.head.sha }}

- name: Setup python
uses: actions/setup-python@v4
- name: Setup Python
uses: actions/setup-python@v6
with:
python-version: 3.9
cache: "pip"
cache-dependency-path: requirements.txt
python-version-file: ".python-version"

- name: Install Dependencies
run: |
pip install --upgrade pip
pip install -r requirements.txt

- name: Run black
shell: bash
run: pre-commit run black --all-files
- name: Install uv
uses: astral-sh/setup-uv@v6
with:
enable-cache: true

- name: Run flake8
shell: bash
run: pre-commit run flake8 --all-files
- name: Install Dependencies
run: uv sync --locked --all-extras --dev

- name: Run docformatter
- name: Run ruff linter
shell: bash
run: pre-commit run docformatter --all-files
run: uv run pre-commit run ruff-check --all-files

- name: Run pydocstyle
- name: Run ruff formatter
shell: bash
run: pre-commit run pydocstyle --all-files
run: uv run pre-commit run ruff-format --all-files

- name: Run mypy
shell: bash
run: pre-commit run mypy --all-files
run: uv run pre-commit run mypy --all-files

- name: Run pytest with code coverage
run: |
pytest --junitxml pytest.xml --cov=. --cov-report=term-missing --cov-report=xml:coverage.xml --cov-branch | tee pytest-coverage.txt

- name: Upload Coverage Results
uses: actions/upload-artifact@v3
with:
name: coverage-results
path: coverage.xml
if: ${{ always() }}
uv run pytest --junitxml pytest.xml --cov=. --cov-report=term-missing --cov-report=xml:coverage.xml --cov-branch | tee pytest-coverage.txt

- name: Upload Unit Test Results
if: always()
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: unit-test-py39
path: pytest.xml
name: unit-test-py312
path: |
pytest.xml
coverage.xml
pytest-coverage.txt

- name: Upload Unit Test Results
if: always()
uses: actions/upload-artifact@v3
with:
name: unit-test-py39
path: pytest-coverage.txt

publish-test-results:
name: "Publish Unit Tests Results"
needs: pre-commit-and-test
runs-on: ubuntu-latest
if: always()
timeout-minutes: 20

steps:
- name: Download Artifacts
uses: actions/download-artifact@v3
with:
name: unit-test-py39
path: unit-test-py39

- name: Download coverage report
uses: actions/download-artifact@v3
with:
name: coverage-results

- name: Pytest coverage comment in pull-request
uses: MishaKav/pytest-coverage-comment@main
with:
default-branch: main
pytest-coverage-path: unit-test-py39/pytest-coverage.txt
junitxml-path: unit-test-py39/pytest.xml
hide-badge: true
hide-report: false
create-new-comment: false
hide-comment: false
report-only-changed-files: true

- name: Get the Coverage
shell: bash
run: |
regex='<coverage.+line-rate="([0-9).[0-9]+)".+>'
line=$(grep -oP $regex coverage.xml)
[[ $line =~ $regex ]]
coverage=$( bc <<< ${BASH_REMATCH[1]}*100 )
if (( $(echo "$coverage > 90" |bc -l) )); then
COLOR=green
else
COLOR=red
fi
echo "COVERAGE=${coverage%.*}%" >> $GITHUB_ENV
echo "COLOR=$COLOR" >> $GITHUB_ENV

- name: Create Coverage Badge
uses: schneegans/[email protected]
with:
auth: ${{ secrets.GIST_SECRET }}
gistID: ${{ secrets.GIST_ID }}
filename: coverage.${{ env.REPO_NAME }}.${{ github.event.number }}.json
label: coverage
message: ${{ env.COVERAGE }}
color: ${{ env.COLOR }}

- name: Find Comment
uses: peter-evans/find-comment@v2
id: fc
with:
issue-number: ${{ github.event.pull_request.number }}
comment-author: "github-actions[bot]"
body-includes: Current Branch | Main Branch

- name: Create coverage comment
uses: peter-evans/create-or-update-comment@v2
with:
comment-id: ${{ steps.fc.outputs.comment-id }}
issue-number: ${{ github.event.pull_request.number }}
reactions: eyes
body: |
Current Branch | Main Branch |
| ------ | ------ |
![Coverage Badge](https://img.shields.io/endpoint?url=https://gist.githubusercontent.com/${{ env.GIST_OWNER }}/${{ secrets.GIST_ID }}/raw/coverage.${{ env.REPO_NAME }}.${{ github.event.number }}.json) | ![Coverage Badge](https://img.shields.io/endpoint?url=https://gist.githubusercontent.com/${{ github.repository_owner }}/${{ secrets.GIST_ID }}/raw/coverage.${{ env.REPO_NAME }}.main.json) |
edit-mode: replace
name: Publish Unit Tests Results
needs: pre-commit-and-test
runs-on: ubuntu-latest
if: always()
timeout-minutes: 20

steps:
- name: Download Artifacts
uses: actions/download-artifact@v4
with:
name: unit-test-py312
path: unit-test-py312

- name: Pytest coverage comment in pull-request
uses: MishaKav/pytest-coverage-comment@main
with:
default-branch: main
pytest-coverage-path: unit-test-py312/pytest-coverage.txt
pytest-xml-coverage-path: unit-test-py312/coverage.xml
junitxml-path: unit-test-py312/pytest.xml
hide-badge: true
hide-report: false
create-new-comment: false
hide-comment: false
report-only-changed-files: true

- name: Get the Coverage
shell: bash
run: |
regex='<coverage.+line-rate="([0-9).[0-9]+)".+>'
line=$(grep -oP $regex unit-test-py312/coverage.xml)
[[ $line =~ $regex ]]
coverage=$( bc <<< ${BASH_REMATCH[1]}*100 )
if (( $(echo "$coverage > 90" |bc -l) )); then
COLOR=green
else
COLOR=red
fi
echo "COVERAGE=${coverage%.*}%" >> $GITHUB_ENV
echo "COLOR=$COLOR" >> $GITHUB_ENV

- name: Create Coverage Badge
uses: schneegans/[email protected]
with:
auth: ${{ secrets.GIST_SECRET }}
gistID: ${{ secrets.GIST_ID }}
filename: coverage.${{ env.REPO_NAME }}.${{ github.event.number }}.json
label: coverage
message: ${{ env.COVERAGE }}
color: ${{ env.COLOR }}

- name: Find Comment
uses: peter-evans/find-comment@v2
id: fc
with:
issue-number: ${{ github.event.pull_request.number }}
comment-author: "github-actions[bot]"
body-includes: Current Branch | Main Branch

- name: Create coverage comment
uses: peter-evans/create-or-update-comment@v2
with:
comment-id: ${{ steps.fc.outputs.comment-id }}
issue-number: ${{ github.event.pull_request.number }}
reactions: eyes
body: |
Current Branch | Main Branch |
| ------ | ------ |
![Coverage Badge](https://img.shields.io/endpoint?url=https://gist.githubusercontent.com/${{ env.GIST_OWNER }}/${{ secrets.GIST_ID }}/raw/coverage.${{ env.REPO_NAME }}.${{ github.event.number }}.json) | ![Coverage Badge](https://img.shields.io/endpoint?url=https://gist.githubusercontent.com/${{ github.repository_owner }}/${{ secrets.GIST_ID }}/raw/coverage.${{ env.REPO_NAME }}.main.json) |
edit-mode: replace
28 changes: 16 additions & 12 deletions .github/workflows/merge.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,32 +6,36 @@ on:

jobs:
pre-commit-and-test:
name: "Pre-commit and Test Python 3.9"
name: Pre-commit and Test Python 3.12
runs-on: ubuntu-latest
if: always()
timeout-minutes: 20

steps:
- uses: actions/checkout@v3
- name: Setup python
uses: actions/setup-python@v4
- uses: actions/checkout@v5

- name: Setup Python
uses: actions/setup-python@v6
with:
python-version-file: ".python-version"

- name: Install uv
uses: astral-sh/setup-uv@v6
with:
python-version: "3.9"
cache: "pip"
enable-cache: true

- name: Install Dependencies
run: |
pip install --upgrade pip
pip install -r requirements.txt
pip install pytest-github-actions-annotate-failures

uv sync --locked --all-extras --dev
uv pip install pytest-github-actions-annotate-failures

- name: Install Graphviz
uses: tlylt/install-graphviz@v1

- name: PyTest with code coverage
continue-on-error: true
run: |
pytest --cov=. --cov-report=term-missing --cov-report=xml --cov-branch
uv run pytest --junitxml pytest.xml --cov=. --cov-report=term-missing --cov-report=xml:coverage.xml --cov-branch | tee pytest-coverage.txt

- name: Get the Coverage
shell: bash
Expand All @@ -47,7 +51,7 @@ jobs:
fi
echo "COVERAGE=${coverage%.*}%" >> $GITHUB_ENV
echo "COLOR=$COLOR" >> $GITHUB_ENV

- name: Create Coverage Badge
uses: schneegans/[email protected]
with:
Expand Down
36 changes: 15 additions & 21 deletions .github/workflows/python-package-conda.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,38 +21,32 @@ jobs:
ref: ${{ github.event.pull_request.head.sha }}

- name: Setup python
uses: actions/setup-python@v4
uses: actions/setup-python@v6
with:
architecture: x64
python-version: 3.9
cache: "pip"
cache-dependency-path: requirements.txt
python-version-file: ".python-version"

- name: Install uv
uses: astral-sh/setup-uv@v6
with:
enable-cache: true

- name: Install Dependencies
run: |
pip install --upgrade pip
pip install -r requirements.txt

- name: Run black
shell: bash
run: pre-commit run black --all-files
uv sync --locked --all-extras --dev

- name: Run flake8
- name: Run ruff linter
shell: bash
run: pre-commit run flake8 --all-files
run: uv run pre-commit run ruff-check --all-files

- name: Run docformatter
- name: Run ruff formatter
shell: bash
run: pre-commit run docformatter --all-files

- name: Run pydocstyle
shell: bash
run: pre-commit run pydocstyle --all-files
run: uv run pre-commit run ruff-format --all-files

- name: Run mypy
shell: bash
run: pre-commit run mypy --all-files
run: uv run pre-commit run mypy --all-files

- name: Run pytest with code coverage
run: |
pytest --junitxml pytest.xml --cov=. --cov-report=term-missing --cov-report=xml:coverage.xml --cov-branch | tee pytest-coverage.txt
uv run pytest --junitxml pytest.xml --cov=. --cov-report=term-missing --cov-report=xml:coverage.xml --cov-branch | tee pytest-coverage.txt
6 changes: 3 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -81,9 +81,6 @@ target/
profile_default/
ipython_config.py

# pyenv
.python-version

# pipenv
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
# However, in case of collaboration, if having platform-specific dependencies or dependencies
Expand Down Expand Up @@ -127,3 +124,6 @@ dmypy.json

# Pyre type checker
.pyre/

# Ruff
.ruff_cache/
Loading
Loading