add reusable workflows

This commit is contained in:
umarcor
2021-11-22 02:07:12 +01:00
parent 7647c96c79
commit 35738eef8f
11 changed files with 633 additions and 0 deletions

56
.github/workflows/VerifyDocs.yml vendored Normal file
View File

@@ -0,0 +1,56 @@
name: Verify examples
on:
workflow_call:
inputs:
pyver:
description: 'Python version.'
required: false
default: '3.10'
type: string
jobs:
VerifyDocs:
name: 👍 Verify example snippets using Python ${{ inputs.pyver }}
runs-on: ubuntu-latest
steps:
- name: ⏬ Checkout repository
uses: actions/checkout@v2
- name: 🐍 Setup Python
uses: actions/setup-python@v2
with:
python-version: ${{ inputs.pyver }}
- name: 🐍 Install dependencies
run: |
pip3 install .
- name: ✂ Extract code snippet from README
shell: python
run: |
from pathlib import Path
import re
ROOT = Path('.')
with (ROOT / 'README.md').open('r') as rptr:
content = rptr.read()
m = re.search(r"```py(thon)?(?P<code>.*?)```", content, re.MULTILINE|re.DOTALL)
if m is None:
raise Exception("Regular expression did not find the example in the README!")
with (ROOT / 'tests/docs/example.py').open('w') as wptr:
wptr.write(m["code"])
- name: Print example.py
run: cat tests/docs/example.py
- name: ☑ Run example snippet
working-directory: tests/docs
run: |
python3 example.py