GitHub Actions quick start
GitHub Actions is among the best no-cost CI and is relatively easy to use. Here are a couple example GitHub Actions templates we use across many projects. Each workflow is stored in the project under directory “.github/workflows”. For clarity, usually we use a filename like “.github/workflows/ci.yml”.
This Python template tests on Linux, macOS and Windows. Always enclose version numbers in quotes to avoid YAML interpretation issues.
The optional “Unix FC var” step is an example of setting an environment variable dynamically–here for a Fortran compiler.
name: ci
on:
push:
paths:
- "**.py"
- .github/workflows/ci.yml
jobs:
core:
strategy:
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
runs-on: ${{ matrix.os}}
steps:
- uses: actions/checkout
- uses: actions/setup-python
with:
python-version: '3.x'
- run: pip install .
- run: pip install flake8 mypy pytest
- run: flake8
- run: mypy
- name: Unix FC var
if: runner.os != 'Windows'
run: echo "FC=gfortran-14" >> $GITHUB_ENV
- run: pytest