From 5e2f7669d711f6a0e7dbf6a60191d13923905177 Mon Sep 17 00:00:00 2001 From: Robin Krahl Date: Tue, 30 Jul 2024 10:22:22 +0200 Subject: [PATCH] Test example code from readme in CI To make sure that our example code actually works, this patch adds a CI job that extracts the code and tries to run it. --- .github/workflows/ci.yaml | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 9b7592e..d2314c4 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -127,3 +127,22 @@ jobs: run: ./venv/bin/pip install . - name: Run test suite run: ./venv/bin/python -m unittest -v + test-readme: + name: Run example code from readme + runs-on: ubuntu-latest + container: python:3.9-slim + steps: + - name: Checkout repository + uses: actions/checkout@v4 + - name: Install required packages + run: apt update && apt install -y ${REQUIRED_PACKAGES} cargo + - name: Checkout tangler + run: git clone https://github.com/wiktor-k/tangler.git --branch v0.3.0 --depth 1 + - name: Install Poetry + run: pip install poetry + - name: Create virtual environment + run: make install + - name: Extract code from readme + run: cargo run --manifest-path tangler/Cargo.toml --locked python < README.md > readme.py + - name: Run code from readme + run: poetry run readme.py