Skip to content

Update pre-commit hooks (#180) #432

Update pre-commit hooks (#180)

Update pre-commit hooks (#180) #432

Workflow file for this run

name: CI - Tests
on:
pull_request:
push:
branches:
- main
- 'push-action/**'
jobs:
basic-tests:
name: External
uses: SINTEF/ci-cd/.github/workflows/ci_tests.yml@v2.7.1
with:
# General setup
install_extras: "[dev]"
# pre-commit
run_pre-commit: true
python_version_pre-commit: "3.10"
# pylint & safety
python_version_pylint_safety: "3.10"
run_pylint: false
run_safety: true
# Build dist
run_build_package: true
python_version_package: "3.10"
build_libs: "build"
build_cmd: "python -m build"
# Build documentation
run_build_docs: true
python_version_docs: "3.10"
warnings_as_errors: true
use_mkdocs: true
update_python_api_ref: true
update_docs_landing_page: true
package_dirs: "turtle_canon"
pytest:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Set up Python 3.10
uses: actions/setup-python@v5
with:
python-version: "3.10"
- name: Install python dependencies
run: |
python -m pip install -U pip
pip install -U setuptools wheel
pip install -e .[dev]
- name: Test with pytest
run: pytest -vvv --cov-report=xml
- name: Upload coverage to Codecov
if: github.repository == 'CasperWA/turtle-canon'
uses: codecov/codecov-action@v3
with:
fail_ci_if_error: true
env_vars: OS,PYTHON
name: turtle-canon
flags: turtle-canon
env:
OS: ubuntu-latest
PYTHON: "3.10"
as-pre-commit-hook:
name: As a pre-commit hook (pre-commit ${{ matrix.pre-commit-version }})
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
pre-commit-version:
- "==1.15.0" # minimum pre-commit version for turtle-canon
# latest major versions
- "~=1.0"
- "~=2.0"
- "~=3.0"
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Set up Python 3.10
uses: actions/setup-python@v5
with:
python-version: "3.10"
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -U setuptools wheel
pip install "pre-commit${{ matrix.pre-commit-version }}"
- name: Set 'rev' to current commit SHA
run: sed -i "s|COMMIT_SHA|${GITHUB_SHA}|" .github/utils/.pre-commit-config.yaml
- name: Test pre-commit hook
run: pre-commit run -c .github/utils/.pre-commit-config.yaml --all-files --verbose && exit 1 || exit 0
- name: Check files
run: |
if [ -z "$(git status --porcelain tests)" ]; then
echo "Turtle Canon didn't canonize any files under tests/ !"
echo "pre-commit log:"
cat "/home/runner/.cache/pre-commit/pre-commit.log"
exit 1
fi
if [ -n "$(git status --porcelain tests/static/rdflib_canonized)" ]; then
echo "Turtle Canon canonized already canonized files under tests/static/rdflib_canonized !"
echo "pre-commit log:"
cat "/home/runner/.cache/pre-commit/pre-commit.log"
exit 1
fi
# Now everything should run fine
pre-commit run -c .github/utils/.pre-commit-config.yaml --all-files