Skip to content

Commit

Permalink
ci: add readme codeblock checks
Browse files Browse the repository at this point in the history
This adds a CI check, which uses the python package `codeblocks` to
extract all python codeblocks from the readme to check them with `mypy`
and `pycodestyle`, and also run them with `python` itself.
  • Loading branch information
jkhsjdhjs authored and s-heppner committed Dec 11, 2023
1 parent 7369d2e commit fb884bf
Showing 1 changed file with 29 additions and 2 deletions.
31 changes: 29 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@ name: ci

on: [push, pull_request]

env:
X_PYTHON_VERSION: "3.10"

jobs:
test:
runs-on: ubuntu-latest
Expand Down Expand Up @@ -46,10 +49,10 @@ jobs:

steps:
- uses: actions/checkout@v2
- name: Set up Python 3.10
- name: Set up Python ${{ env.X_PYTHON_VERSION }}
uses: actions/setup-python@v2
with:
python-version: "3.10"
python-version: ${{ env.X_PYTHON_VERSION }}
- name: Install Python dependencies
run: |
python -m pip install --upgrade pip
Expand All @@ -62,6 +65,30 @@ jobs:
run: |
pycodestyle --count --max-line-length 120 basyx test
readme-codeblocks:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
- name: Set up Python ${{ env.X_PYTHON_VERSION }}
uses: actions/setup-python@v2
with:
python-version: ${{ env.X_PYTHON_VERSION }}
- name: Install Python dependencies
run: |
python -m pip install --upgrade pip
pip install pycodestyle mypy codeblocks
pip install -r requirements.txt
- name: Check typing with MyPy
run: |
mypy <(codeblocks python README.md)
- name: Check code style with PyCodestyle
run: |
codeblocks --wrap python README.md | pycodestyle --count --max-line-length 120 -
- name: Run readme codeblocks with Python
run: |
codeblocks python README.md | python
package:
runs-on: ubuntu-latest

Expand Down

0 comments on commit fb884bf

Please sign in to comment.