.github/workflows/test-and-publish.yml
name: Test & publish package
on: [push, pull_request]
jobs:
test:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
python-version:
- '3.8'
- '3.9'
- '3.10'
- '3.11'
- '3.12'
steps:
- uses: actions/checkout@v3
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install coverage coveralls
pip install -r requirements.txt
- name: Run tests
run: |
python -m coverage run --branch --source=prometheus_flask_exporter -m unittest discover -s tests -v
- name: Upload coverage report
if: always() && matrix.python-version == '3.10'
run: |
coveralls --service=github
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
integration:
runs-on: ubuntu-latest
needs: test
strategy:
fail-fast: false
matrix:
include:
- testname: gunicorn
- testname: gunicorn-internal
- testname: gunicorn-app-factory
- testname: uwsgi
- testname: uwsgi-lazy-apps
- testname: wsgi
# - testname: connexion-pydantic
- testname: restful-with-blueprints
- testname: restful-return-none
- testname: restplus-default-metrics
- testname: flask-httpauth
- testname: flask-multi-processes
- testname: reload
steps:
- uses: actions/checkout@v3
- name: Run integration test for ${{ matrix.testname }}
run: |
sh examples/${{ matrix.testname }}/run_tests.sh
publish:
runs-on: ubuntu-latest
needs: integration
steps:
- uses: actions/checkout@v3
- name: Install dependencies
run: |
pip install build
- name: Build package
run: |
python -m build
- name: Publish package
uses: pypa/gh-action-pypi-publish@release/v1
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags')
with:
user: __token__
password: ${{ secrets.PYPI_API_TOKEN }}
verify:
runs-on: ubuntu-latest
needs: publish
steps:
- name: Verify installation
run: |
pip install prometheus-flask-exporter