Skip to content
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
101 changes: 76 additions & 25 deletions .github/workflows/build_and_publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,32 +3,83 @@ name: Publish Python 🐍 distributions 📦 to PyPI
on:
push:
tags:
- '*'
- '*'
# Manual runs must be started from a tag; branch runs fail tag validation.
workflow_dispatch:

permissions:
contents: read

concurrency:
group: pypi-${{ github.ref }}
cancel-in-progress: false

jobs:
build-n-publish:
name: Build and publish Python 🐍 distributions 📦 to PyPI
build:
name: Build distributions
runs-on: ubuntu-latest
steps:
- name: Check out the repository
uses: actions/checkout@v7.0.1

- name: Set up Python 3.13
uses: actions/setup-python@v7.1.0
with:
python-version: '3.13'

- name: Install build tooling
run: python -m pip install --upgrade build twine

- name: Run the test suite
run: python -m unittest test -v

- name: Validate the release tag and stamp the version
env:
TAG_NAME: ${{ github.ref_name }}
run: |
version="${TAG_NAME#v}"
python -c "import sys; from packaging.version import Version; Version(sys.argv[1])" "$version"
echo "Releasing funcprofiler ${version}"
sed -i "s/{{VERSION_PLACEHOLDER}}/${version}/g" setup.py
sed -i "s/^__version__ = .*/__version__ = \"${version}\"/" funcprofiler/__init__.py
grep -n "^__version__" funcprofiler/__init__.py

- name: Build sdist and wheel
run: python -m build

- name: Check the distribution metadata
run: python -m twine check --strict dist/*

- name: List the distributions
run: ls -l dist/

- name: Upload the distributions
uses: actions/upload-artifact@v7.0.2
with:
name: dist
path: dist/
if-no-files-found: error
retention-days: 7

publish:
name: Publish to PyPI
needs: build
runs-on: ubuntu-latest
# No GitHub environment: the PyPI trusted publisher is configured without
# an environment name, so the OIDC token must not carry an environment
# claim. If you ever set an environment on PyPI, declare it here too.
permissions:
# Mandatory for trusted publishing (OIDC); no API token is used.
id-token: write
steps:
- uses: actions/checkout@master
- name: Set up Python 3.12
uses: actions/setup-python@v3
with:
python-version: '3.12'
- name: Install pypa/setuptools
run: >-
python -m
pip install setuptools wheel
- name: Extract tag name
id: tag
run: echo ::set-output name=TAG_NAME::$(echo $GITHUB_REF | cut -d / -f 3)
- name: Update version in setup.py
run: >-
sed -i "s/{{VERSION_PLACEHOLDER}}/${{ steps.tag.outputs.TAG_NAME }}/g" setup.py
- name: Build a binary wheel
run: >-
python setup.py sdist bdist_wheel
- name: Publish distribution 📦 to PyPI
uses: pypa/gh-action-pypi-publish@master
with:
password: ${{ secrets.PYPI_API_TOKEN }}
- name: Download the distributions
uses: actions/download-artifact@v8.0.2
with:
name: dist
path: dist/

- name: Publish distribution 📦 to PyPI
uses: pypa/gh-action-pypi-publish@v1.14.3
with:
# PEP 740 attestations are generated automatically via OIDC.
attestations: true
59 changes: 59 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
name: Tests

on:
push:
branches:
- '**'
pull_request:
workflow_dispatch:

permissions:
contents: read

jobs:
test:
name: Python ${{ matrix.python-version }}
runs-on: ubuntu-22.04
strategy:
fail-fast: false
matrix:
python-version: ['3.8', '3.9', '3.10', '3.11', '3.12', '3.13']
steps:
- name: Check out the repository
uses: actions/checkout@v7.0.1

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v7.1.0
with:
python-version: ${{ matrix.python-version }}

- name: Install the package
run: |
python -m pip install --upgrade pip
python -m pip install .

- name: Byte-compile the package
run: python -m compileall -q funcprofiler

- name: Run the test suite
run: python -m unittest test -v

build:
name: Build distributions
runs-on: ubuntu-22.04
steps:
- name: Check out the repository
uses: actions/checkout@v7.0.1

- name: Set up Python 3.13
uses: actions/setup-python@v7.1.0
with:
python-version: '3.13'

- name: Build sdist and wheel
run: |
python -m pip install --upgrade build
python -m build

- name: Verify the package metadata
run: python -m pip install --force-reinstall dist/*.whl
18 changes: 17 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,21 @@ __pycache__/
*.py[cod]
*$py.class

# Log files
# Packaging artifacts
build/
dist/
*.egg-info/
.eggs/
*.whl

# Log files produced by shared_log=True
*.txt

# Reports produced with the default filenames
*_funcprofile_report.*
*_lblprofile_report.*

# Test and tooling caches
.pytest_cache/
.coverage
htmlcov/
12 changes: 8 additions & 4 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,16 @@ Thank you for considering contributing to **FuncProfiler**! Contributions, wheth
Create a fork of this repository to your GitHub account and clone it locally.

2. **Set Up the Environment**
Ensure you have Python 3.6+ installed. You should also install compatible versions of the necessary dependencies for the project.
Ensure you have Python 3.8+ installed. FuncProfiler has no third-party runtime dependencies, so you can work directly from a clone.

3. **Run Tests**
Before making changes, run tests to confirm that everything works.
Before making changes, run the test suite to confirm that everything works:

> [!TIP]
> We sometimes include testing scripts in our projects for easy testing.
```bash
python -m unittest test -v
```

Continuous integration runs the same suite on every supported Python version.

## How to Contribute

Expand All @@ -32,6 +35,7 @@ Thank you for considering contributing to **FuncProfiler**! Contributions, wheth
- Push your changes to a feature branch in your fork.
- Submit a pull request with a detailed explanation of what you've changed or added.
- Ensure your PR passes all automated tests and adheres to the contribution guidelines.
- Add tests for new behaviour in `test.py`.

## Community Guidelines

Expand Down
Loading