Add decorators for prometheus (#110) #558
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: wipac ci/cd | |
on: [ push ] | |
jobs: | |
py-versions: | |
runs-on: ubuntu-latest | |
outputs: | |
matrix: ${{ steps.versions.outputs.matrix }} | |
steps: | |
- uses: actions/checkout@v4 | |
- id: versions | |
uses: WIPACrepo/[email protected] | |
###################################################################################### | |
flake8: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: actions/setup-python@v5 | |
- uses: WIPACrepo/[email protected] | |
mypy: | |
needs: [ py-versions ] | |
runs-on: ubuntu-latest | |
strategy: | |
fail-fast: false | |
matrix: | |
py3: ${{ fromJSON(needs.py-versions.outputs.matrix) }} | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: actions/setup-python@v5 | |
with: | |
python-version: ${{ matrix.py3 }} | |
- uses: WIPACrepo/[email protected] | |
###################################################################################### | |
writable-branch-detect: | |
runs-on: ubuntu-latest | |
outputs: | |
OKAY: ${{ steps.detect.outputs.OKAY }} | |
steps: | |
- name: is this a non-dependabot branch? | |
id: detect | |
# dependabot can't access normal secrets | |
# & don't run non-branch triggers (like tags) | |
# & we don't want to trigger an update on PR's merge to main/master/default (which is a branch) | |
run: | | |
if [[ \ | |
${{github.actor}} != 'dependabot[bot]' && \ | |
${{github.ref_type}} == 'branch' && \ | |
${{format('refs/heads/{0}', github.event.repository.default_branch)}} != ${{github.ref}} \ | |
]]; then | |
echo "OKAY=true" >> "$GITHUB_OUTPUT" | |
echo "yes, this branch is compatible" | |
else | |
echo "OKAY=false" >> "$GITHUB_OUTPUT" | |
echo "no, this branch is incompatible" | |
fi | |
py-setup: | |
needs: [ writable-branch-detect ] | |
runs-on: ubuntu-latest | |
steps: | |
- if: needs.writable-branch-detect.outputs.OKAY == 'true' | |
uses: actions/checkout@v4 | |
with: | |
token: ${{ secrets.PERSONAL_ACCESS_TOKEN }} | |
- if: needs.writable-branch-detect.outputs.OKAY == 'true' | |
uses: WIPACrepo/[email protected] | |
with: | |
python_min: 3.9 | |
pypi_name: wipac-dev-tools | |
author: WIPAC Developers | |
author_email: [email protected] | |
keywords: WIPAC python tools utilities | |
py-dependencies: | |
needs: [ writable-branch-detect ] | |
runs-on: ubuntu-latest | |
steps: | |
- if: needs.writable-branch-detect.outputs.OKAY == 'true' | |
uses: actions/checkout@v4 | |
with: | |
token: ${{ secrets.PERSONAL_ACCESS_TOKEN }} | |
- if: needs.writable-branch-detect.outputs.OKAY == 'true' | |
uses: WIPACrepo/[email protected] | |
with: | |
use_directory: true | |
###################################################################################### | |
tests: | |
needs: [ py-versions ] | |
runs-on: ubuntu-latest | |
strategy: | |
fail-fast: false | |
matrix: | |
py3: ${{ fromJSON(needs.py-versions.outputs.matrix) }} | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: actions/setup-python@v5 | |
with: | |
python-version: ${{ matrix.py3 }} | |
- name: Pytest | |
run: | | |
pip install --upgrade pip wheel setuptools pytest | |
pip install .[dev] | |
pytest -vvvv tests | |
###################################################################################### | |
release: | |
# only run on main/master/default | |
if: format('refs/heads/{0}', github.event.repository.default_branch) == github.ref | |
needs: [ flake8, mypy, py-setup, py-dependencies, tests ] | |
runs-on: ubuntu-latest | |
concurrency: release # prevent any possible race conditions | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
# Python-Package Version Bump | |
- uses: python-semantic-release/[email protected] | |
id: psr-psr | |
with: | |
github_token: ${{ secrets.GITHUB_TOKEN }} | |
# PyPI Release | |
- uses: pypa/[email protected] | |
if: steps.psr-psr.outputs.released == 'true' | |
with: | |
password: ${{ secrets.PYPI_TOKEN }} | |
# GitHub Release | |
- uses: python-semantic-release/[email protected] | |
if: steps.psr-psr.outputs.released == 'true' | |
with: | |
github_token: ${{ secrets.GITHUB_TOKEN }} |