name: readme_python

defaults:
  run:
    shell: bash

on:
  push:
    branches: [ main ]
  pull_request:
    branches: [ main ]
  schedule:
    - cron: '0 13 * * 4'

jobs:
  python:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v2
        with:
          submodules: recursive

      - uses: actions/setup-python@v1
        with:
          python-version: 3.9

      - run: pip install -e .
      - run: pip install pytest-codeblocks pytest
      - run: python -c "import pytest_codeblocks; code=pytest_codeblocks.extract_from_file('README.md'); f=open('readme.py', 'w'); f.writelines(block.code for block in code if block.syntax=='Python'); f.close()"
      - run: cat -n readme.py

      - run: python -We readme.py
