Skip to content

Commit

Permalink
Fix merge checks (#39)
Browse files Browse the repository at this point in the history
Use virtual environement using 'trap deactivate EXIT'

Merging requires that the ci git hub action passes all checks and
also passes functional tests a.k.a registration-demo.

The github action of releasing must only be executed when releasing as
wheels in pypi are immutable. Otherwise we would have to bump release
versions if the releases fail. Once code is merged it is releasable.

Added support for 3.13
Added additional wheel attributes.
  • Loading branch information
eccles authored Nov 27, 2024
1 parent ae28248 commit 72178ac
Show file tree
Hide file tree
Showing 16 changed files with 91 additions and 89 deletions.
44 changes: 32 additions & 12 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,13 @@ name: Build and test

on:
workflow_call:

jobs:
build:
strategy:
fail-fast: false
matrix:
python-version: ["3.11", "3.12" ]
python-version: ["3.11", "3.12", "3.13" ]
# reduced matrix for ci
os: [ubuntu-latest, windows-latest]
runs-on: ${{ matrix.os }}
Expand All @@ -27,28 +28,28 @@ jobs:
shell: bash

- name: Run integrity checks
env:
DATATRAILS_URL: ${{ vars.DATATRAILS_URL }}
DATATRAILS_CLIENT_ID: ${{ vars.DATATRAILS_CLIENT_ID }}
DATATRAILS_CLIENT_SECRET: ${{ secrets.DATATRAILS_CLIENT_SECRET }}

run: |
ruff check datatrails_scitt_samples unittests
python3 -m black datatrails_scitt_samples unittests
ruff check datatrails_scitt_samples tests
python3 -m black datatrails_scitt_samples tests
python3 -m pyright --stats datatrails_scitt_samples
modified=$(git status -s | wc -l)
if [ $modified -gt 0 ]
then
echo "there are $modified files that must be reformatted"
echo "DISABLED guard due to mismatch with local environment"
# exit 1
fi
python3 -m unittest
shell: bash
- name: Run type-hint checks
if: ${{ matrix.python-version != '3.12' }}

- name: Simple tests
env:
DATATRAILS_URL: ${{ vars.DATATRAILS_URL }}
DATATRAILS_CLIENT_ID: ${{ vars.DATATRAILS_CLIENT_ID }}
DATATRAILS_CLIENT_SECRET: ${{ secrets.DATATRAILS_CLIENT_SECRET }}
run: |
python3 -m pyright --stats datatrails_scitt_samples
python3 -m unittest
shell: bash

- uses: pypa/[email protected]
if: ${{ matrix.os == 'ubuntu-latest' }}
with:
Expand All @@ -57,4 +58,23 @@ jobs:
GHSA-wj6h-64fc-37mp
inputs: requirements.txt

- name: Install Task
uses: arduino/setup-task@v1
with:
version: "3.x"
repo-token: ${{ secrets.GITHUB_TOKEN }}

- name: Create and install wheel
run: |
python3 -m build --wheel
python3 -m pip install --force-reinstall dist/*.whl
shell: bash

- name: Test installed package (registration-demo)
env:
DATATRAILS_URL: ${{ vars.DATATRAILS_URL }}
DATATRAILS_CLIENT_ID: ${{ vars.DATATRAILS_CLIENT_ID }}
DATATRAILS_CLIENT_SECRET: ${{ secrets.DATATRAILS_CLIENT_SECRET }}
run: |
task registration-demo
shell: bash
19 changes: 2 additions & 17 deletions .github/workflows/merge-requires.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,32 +4,17 @@
# granting repository stakeholders the ability configure what workflows are
# appropriate to satisfy that check.
name: Merge Requires
on:
push:
on: [pull_request]

jobs:
ci:
if: ${{ github.event_name != 'release' }}
secrets: inherit
uses: ./.github/workflows/ci.yml
release:
if: ${{ github.event_name == 'release' }}
secrets: inherit
uses: ./.github/workflows/package.yml

merge-checks-ok:
runs-on: ubuntu-latest
needs: [ci]
steps:
- name: ok
run: |
echo "It's working!"
release-checks-ok:
runs-on: ubuntu-latest
if: ${{ github.event_name == 'release' }}
needs: [ci, release]
steps:
- name: ok
run: |
echo "Houston we have cleared the tower"
echo "This code is mergeable"
42 changes: 19 additions & 23 deletions .github/workflows/package.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,41 +4,37 @@
name: Package and Publish

on:
workflow_call:
release:
types: [created]

jobs:
build:
strategy:
fail-fast: false
matrix:
python-version: ["3.11", "3.12" ]
# reduced matrix for ci
os: [ubuntu-latest, windows-latest]
# os: [ubuntu-latest, windows-latest] scripts on windows are a PITA
# instead, peaple can do 'python3 -m datatrails_scitt_samples.scripts.create_signed_statement ...'
runs-on: ${{ matrix.os }}
deploy:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
python-version: '3.x'

- name: Install Task
uses: arduino/setup-task@v1
with:
version: 3.x
version: "3.x"
repo-token: ${{ secrets.GITHUB_TOKEN }}

- name: Build Package
- name: Install dependencies
run: |
python3 -m pip install -qq -r requirements.txt
python3 -m pip install -qq -r requirements-dev.txt
python3 -m build --sdist
python3 -m build --wheel
twine check dist/*
pip install --force-reinstall dist/*.whl
python3 -m pip install --upgrade pip
python3 -m pip install -r requirements.txt
python3 -m pip install -r requirements-dev.txt
shell: bash

- name: Create wheel
run: |
python3 -m build --sdist
python3 -m build --wheel
shell: bash

- name: Test installed package (registration-demo)
Expand All @@ -48,14 +44,14 @@ jobs:
DATATRAILS_CLIENT_SECRET: ${{ secrets.DATATRAILS_CLIENT_SECRET }}

run: |
python3 -m pip install --force-reinstall dist/*.whl
task registration-demo
shell: bash

- name: Publish to PyPI
if: ${{ github.event_name == 'release' }}
uses: pypa/gh-action-pypi-publish@release/v1
with:
verbose: true
# skip-existing: true
user: ${{ vars.PYPI_USER }}
user: ${{ secrets.PYPI_USERNAME }}
password: ${{ secrets.PYPI_PASSWORD }}
3 changes: 2 additions & 1 deletion .github/workflows/registration-demo.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# no longer required?
name: Registration Demo

# NOTE: This workflow can't be tested until it is merged into the main branch :-/
Expand Down Expand Up @@ -71,4 +72,4 @@ jobs:
echo -n "Transparent Statement: "
cat transparent-statement.cbor | base64
echo -n "Receipt : "
cat statement-receipt.cbor | base64
cat statement-receipt.cbor | base64
33 changes: 16 additions & 17 deletions Taskfile.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ tasks:
- |
set -e
source {{.VENV_DIR}}/bin/activate
trap deactivate EXIT
python -m pip install -e .
audit:
Expand All @@ -26,11 +27,10 @@ tasks:
- |
set -e
source {{.VENV_DIR}}/bin/activate
trap deactivate EXIT
pip-audit -r requirements.txt
deactivate
check:
desc: Check the style, bug and quality of the code
deps:
Expand All @@ -39,12 +39,11 @@ tasks:
- |
set -e
source {{.VENV_DIR}}/bin/activate
trap deactivate EXIT
python3 --version
ruff check {{ .PACKAGE_NAME }} unittests
python3 -m pyright --stats {{ .PACKAGE_NAME }} unittests
deactivate
ruff check {{ .PACKAGE_NAME }} tests
python3 -m pyright --stats {{ .PACKAGE_NAME }} tests
clean:
desc: Clean git repo
Expand All @@ -60,25 +59,23 @@ tasks:
- |
set -e
source {{ .VENV_DIR }}/bin/activate
trap deactivate EXIT
ruff format {{ .PACKAGE_NAME }} unittests
black {{ .PACKAGE_NAME }} unittests
deactivate
ruff format {{ .PACKAGE_NAME }} tests
black {{ .PACKAGE_NAME }} tests
test:
desc: Run unittests
desc: Run simple tests
deps:
- task: venv
cmds:
- |
set -e
source {{ .VENV_DIR }}/bin/activate
trap deactivate EXIT
python3 -m unittest
deactivate
test:wheel:
desc: |
Build and install the package, then register a signed statement with the datatrails server
Expand All @@ -94,9 +91,10 @@ tasks:
cmds:
- |
source {{ .VENV_DIR }}/bin/activate
trap deactivate EXIT
pip install --force-reinstall dist/*.whl
task registration-demo
deactivate
registration-demo:
Expand Down Expand Up @@ -171,9 +169,10 @@ tasks:
then
python3 -m venv {{ .VENV_DIR }}
source {{ .VENV_DIR }}/bin/activate
trap deactivate EXIT
python3 -m pip install -r requirements.txt
python3 -m pip install -r requirements-dev.txt
deactivate
fi
wheel:
Expand All @@ -183,9 +182,9 @@ tasks:
set -e
rm -rf dist/*
source {{ .VENV_DIR }}/bin/activate
trap deactivate EXIT
python3 -m build --sdist
python3 -m build --wheel
twine check dist/*
deactivate
5 changes: 4 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
[tool.black]
target-version = ["py311", "py312", "py313"]

[tool.coverage.report]
fail_under = 100

Expand All @@ -6,4 +9,4 @@ enabled = true

[tool.pyright]
include = ["datatrails_scitt_samples"]
typeCheckingMode = "basic"
typeCheckingMode = "basic"
32 changes: 15 additions & 17 deletions setup.cfg
Original file line number Diff line number Diff line change
@@ -1,20 +1,3 @@
[options]
packages =
datatrails_scitt_samples
datatrails_scitt_samples.datatrails
datatrails_scitt_samples.mmriver
datatrails_scitt_samples.scripts
datatrails_scitt_samples.artifacts
include_package_data = True
setup_requires =
setuptools-git-versioning
setuptools_scm

[pycodestyle]
ignore = E128, E203, E225, E265, E266, E402, E501, E713, E722, E741, W504, W503
statistics = True
max-line-length = 88

[metadata]
name = datatrails-scitt-samples
use_scm_version = True
Expand All @@ -40,6 +23,21 @@ project_urls =
Source = https://github.com/datatrails/datatrails-scitt-samples
Tracker = https://github.com/datatrails/datatrails-scitt-samples/issues

[options]
install_requires = file: requirements.txt
packages =
datatrails_scitt_samples
datatrails_scitt_samples.datatrails
datatrails_scitt_samples.mmriver
datatrails_scitt_samples.scripts
datatrails_scitt_samples.artifacts
include_package_data = True
platforms = any
python_requires = >=3.11
setup_requires =
setuptools-git-versioning
setuptools_scm

[options.entry_points]
console_scripts =
datatrails-sciit-demo-generate-example-key = datatrails_scitt_samples.scripts.generate_example_key:main
Expand Down
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion unittests/constants.py → tests/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@

KNOWN_STATEMENT = {"author": "fred", "title": "my biography", "reviews": "mixed"}

KNOWN_RECEIPT_FILE: str = "unittests/resources/scitt-receipt.cbor"
KNOWN_RECEIPT_FILE: str = "tests/resources/scitt-receipt.cbor"
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 comments on commit 72178ac

Please sign in to comment.