PSAAS-20085 Docs and versioning enforcement #76
Workflow file for this run
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: CI | |
on: | |
push: | |
branches: | |
- main | |
pull_request: | |
branches: | |
- main | |
jobs: | |
Version: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
- name: Run Base Steps | |
uses: ./.github/actions/base | |
- name: Gather PR version | |
id: pr-version | |
run: | | |
export PR_VERSION=$(poetry version --short) | |
echo "PR_VERSION=${PR_VERSION}" | |
echo "VERSION=${PR_VERSION}" >> $GITHUB_OUTPUT | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
with: | |
ref: main | |
- name: Gather main version | |
id: main-version | |
run: | | |
export BASE_VERSION=$(poetry version --short) | |
echo "BASE_VERSION=${BASE_VERSION}" | |
echo "VERSION=${BASE_VERSION}" >> $GITHUB_OUTPUT | |
- name: Compare versions | |
env: | |
BASE_VERSION: ${{ steps.main-version.outputs.VERSION }} | |
PR_VERSION: ${{ steps.pr-version.outputs.VERSION }} | |
run: | | |
export COMPARE_CODE=$(poetry run cmp-version $PR_VERSION $BASE_VERSION) && echo "COMPARE_CODE=$COMPARE_CODE" | |
if [ "$COMPARE_CODE" == "1" ]; then | |
echo "🟢 Version upgrading to $PR_VERSION" | |
else | |
echo "🛑 Version $PR_VERSION not greater than $BASE_VERSION" | |
echo "🚧 Update version through pyproject.toml or 'poetry version' command" | |
echo "Cf. https://semver.org/ and https://python-poetry.org/docs/cli/#version" | |
exit 1 | |
fi | |
- name: Checkout code # Checkouting back to current branch to make sure that the post actions are up to date with branch changes | |
uses: actions/checkout@v4 | |
PrecommitHooks: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
- name: Run Base Steps | |
uses: ./.github/actions/base | |
- name: Run pre-commit | |
run: | | |
poetry run pre-commit run --all-files | |
Tests: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
- name: Run Base Steps | |
uses: ./.github/actions/base | |
- name: Run tests with coverage | |
run: | | |
poetry run pytest --cov=./ | |
- name: Upload coverage file | |
uses: actions/upload-artifact@v4 | |
with: | |
name: coverage-data | |
path: .coverage | |
include-hidden-files: true | |
if-no-files-found: ignore | |
Coverage: | |
name: Combine & check coverage | |
if: always() | |
needs: Tests | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
- name: Run Base Steps | |
uses: ./.github/actions/base | |
- uses: actions/download-artifact@v4 | |
with: | |
pattern: coverage-data | |
- name: Combine coverage & fail if it's <90% | |
run: | | |
python -m pip install --upgrade pip | |
pip install --upgrade coverage[toml] | |
mv ./coverage-data/.coverage .coverage | |
coverage html --skip-covered --skip-empty | |
coverage report --format=markdown >> $GITHUB_STEP_SUMMARY | |
coverage report --fail-under=90 | |
- name: Upload HTML report if check failed | |
uses: actions/upload-artifact@v4 | |
with: | |
name: html-report | |
path: htmlcov | |
if: ${{ failure() }} |