Skip to content

Merge pull request #18 from wphillipmoore/feature/docs-only-detection-v2 #6

Merge pull request #18 from wphillipmoore/feature/docs-only-detection-v2

Merge pull request #18 from wphillipmoore/feature/docs-only-detection-v2 #6

Workflow file for this run

name: CI - Test and Validate
on:
pull_request:
push:
branches:
- develop
- 'release/**'
permissions:
contents: read
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
docs-only:
name: docs-only
runs-on: ubuntu-latest
outputs:
docs_only: ${{ steps.detect.outputs.docs_only }}
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Detect docs-only changes
id: detect
env:
GH_TOKEN: ${{ github.token }}
run: |
if [ "${{ github.event_name }}" != "pull_request" ]; then
echo "docs_only=false" >> "$GITHUB_OUTPUT"
exit 0
fi
files=$(gh api "repos/${{ github.repository }}/pulls/${{ github.event.pull_request.number }}/files" --paginate --jq '.[].filename')
if [ -z "$files" ]; then
echo "docs_only=false" >> "$GITHUB_OUTPUT"
exit 0
fi
docs_only=true
for file in $files; do
if [[ "$file" == docs/* ]] || [[ "$file" == "README.md" ]] || [[ "$file" == "CHANGELOG.md" ]]; then
continue
fi
docs_only=false
break
done
echo "docs_only=$docs_only" >> "$GITHUB_OUTPUT"
dependency-audit:
name: dependency-audit
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Python 3.14
uses: actions/setup-python@v5
with:
python-version: "3.14"
- name: Cache Poetry installation
uses: actions/cache@v4
with:
path: |
~/.local/share/pypoetry
~/.local/bin/poetry
key: poetry-install-${{ runner.os }}-3.14
- name: Install Poetry
run: |
if ! command -v poetry &> /dev/null; then
curl -sSL https://install.python-poetry.org | python3 -
echo "$HOME/.local/bin" >> $GITHUB_PATH
fi
poetry --version
- name: Cache dependencies
uses: actions/cache@v4
with:
path: ~/.cache/pypoetry/virtualenvs
key: poetry-${{ runner.os }}-py3.14-${{ hashFiles('poetry.lock') }}
restore-keys: |
poetry-${{ runner.os }}-py3.14-
- name: Install dependencies
run: poetry install --no-interaction
- name: Run pip-audit (fail on any vulnerability)
run: poetry run pip-audit -r requirements.txt -r requirements-dev.txt
test-and-validate:
name: test-and-validate
runs-on: ubuntu-latest
needs: docs-only
if: needs.docs-only.outputs.docs_only != 'true'
strategy:
matrix:
python-version: ["3.14"]
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Fetch base branch for version checks
if: github.event_name == 'pull_request'
run: git fetch origin ${{ github.base_ref }} --depth=1
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Validate version string policy
run: python3 scripts/dev/validate_version.py
- name: Cache Poetry installation
uses: actions/cache@v4
with:
path: |
~/.local/share/pypoetry
~/.local/bin/poetry
key: poetry-install-${{ runner.os }}-${{ matrix.python-version }}
- name: Install Poetry
run: |
if ! command -v poetry &> /dev/null; then
curl -sSL https://install.python-poetry.org | python3 -
echo "$HOME/.local/bin" >> $GITHUB_PATH
fi
poetry --version
- name: Validate dependency specifications
run: python3 scripts/dev/validate_dependency_specs.py
- name: Verify poetry.lock sync
run: poetry check --lock
- name: Cache dependencies
uses: actions/cache@v4
with:
path: ~/.cache/pypoetry/virtualenvs
key: poetry-${{ runner.os }}-py${{ matrix.python-version }}-${{ hashFiles('poetry.lock') }}
restore-keys: |
poetry-${{ runner.os }}-py${{ matrix.python-version }}-
- name: Install dependencies
run: poetry install --no-interaction
- name: Run ruff check
run: poetry run ruff check
- name: Run mypy
run: poetry run mypy src/
- name: Run tests with coverage
run: |
poetry run pytest \
--cov=pymqrest \
--cov-report=term-missing \
--cov-branch \
--cov-fail-under=100