Skip to content

refactor: Fix lint/typecheck errors #134

refactor: Fix lint/typecheck errors

refactor: Fix lint/typecheck errors #134

Workflow file for this run

name: default
on: [push, pull_request]
jobs:
pre-commit-check:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: "3.11.4"
- name: Cache pre-commit dependencies
id: cache_pre_commit
uses: actions/cache@v3
with:
path: |
.pre_commit_venv
~/.cache/pre-commit
key: pre-commit-${{ hashFiles('.pre-commit-config.yaml','~/.cache/pre-commit/*') }}
- name: Install pre-commit
if: steps.cache_pre_commit.outputs.cache-hit != 'true'
run: |
python -m venv .pre_commit_venv
. .pre_commit_venv/bin/activate
pip install --upgrade pip
pip install pre-commit
pre-commit install --install-hooks
pre-commit gc
- name: Run pre-commit hooks
run: |
if [ "$GITHUB_EVENT_NAME" == "pull_request" -a -n "$GITHUB_HEAD_REF" ]; then
echo "(skipping matchers for pull request from local branches)"
else
echo "::add-matcher::.github/workflows/flake8-matcher.json"
echo "::add-matcher::.github/workflows/mypy-matcher.json"
fi
. .pre_commit_venv/bin/activate
pre-commit run --color=always --all-files
test-unit:
runs-on: ubuntu-latest
services:
redis:
image: redis:7-alpine
ports:
- 6379
options: >-
--health-cmd "redis-cli ping"
--health-interval 4s
--health-timeout 2s
--health-retries 5
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: "3.11.4"
cache: pip
cache-dependency-path: |
setup.cfg
requirements/test.txt
- name: Install dependencies
run: |
sudo apt install -y libsnappy-dev
python -m pip install -U pip setuptools wheel
python -m pip install -U -e ".[build,test,zeromq,redis,thrift,snappy]"
- name: Run unit tests
env:
REDIS_HOST: localhost
REDIS_PORT: ${{ job.services.redis.ports[6379] }}
run: |
python -m pytest --cov tests
- name: Upload coverage report
uses: codecov/codecov-action@v3
test-integration:
runs-on: ubuntu-latest
services:
redis:
image: redis:7-alpine
ports:
- 6379
options: >-
--health-cmd "redis-cli ping"
--health-interval 4s
--health-timeout 2s
--health-retries 5
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: "3.11.4"
cache: pip
cache-dependency-path: |
setup.cfg
requirements/test.txt
- name: Install dependencies
run: |
sudo apt install -y libsnappy-dev
python -m pip install -U pip setuptools wheel
python -m pip install -U -e ".[build,test,zeromq,redis,thrift,snappy]"
- name: Run integration tests
env:
REDIS_HOST: localhost
REDIS_PORT: ${{ job.services.redis.ports[6379] }}
run: |
./scripts/run-integration-tests.sh
build-distributions:
needs: [pre-commit-check, test-unit, test-integration]
if: github.event_name == 'push' && contains(github.ref, 'refs/tags/')
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Fetch remote tags
run: git fetch origin 'refs/tags/*:refs/tags/*' -f
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: "3.11.4"
cache: pip
cache-dependency-path: |
setup.cfg
requirements/build.txt
- name: Install dependencies
run: |
python -m pip install -U pip setuptools wheel
python -m pip install -U -r requirements/build.txt
- name: Build packages
run: |
python -c "import callosum; print(callosum.__version__)" | tee version.txt
python -m build -s -w
- name: Upload the build version
uses: actions/upload-artifact@v3
with:
name: version
path: version.txt
- name: Upload build artifacts
uses: actions/upload-artifact@v3
with:
name: distributions
path: dist
publish:
needs: [build-distributions]
if: github.event_name == 'push' && contains(github.ref, 'refs/tags/')
runs-on: ubuntu-latest
environment: release
permissions:
id-token: write # mandatory for trusted publishing
contents: write # mandatory for making repo releases
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Download the build version
uses: actions/download-artifact@v3
with:
name: version
path: .
- name: Download build artifacts
uses: actions/download-artifact@v3
with:
name: distributions
path: dist
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: "3.11.4"
- name: Extract the release changelog
run: |
python ./scripts/extract-release-changelog.py
python ./scripts/determine-release-type.py
- name: Publish to GitHub
uses: softprops/action-gh-release@v1
with:
body_path: "CHANGELOG_RELEASE.md"
prerelease: ${{ env.IS_PRERELEASE }}
files: |
dist/*.tar.gz
dist/*.whl
- name: Publish to PyPI
uses: pypa/gh-action-pypi-publish@release/v1