Walk in | 15 min |
Programming Cafe | 10 min |
GitHub Actions | 35 min |
Exercises or Work on your own code | 50 min |
Wrap-up | 10 min |
Drinks! |
Research Data Management Support
An online repository, based on Git software, for:
Automation of:
An action is a custom application for the GitHub Actions platform that performs a complex but frequently repeated task (e.g. installing Python). Use an action to help reduce the amount of repetitive code that you write in your workflow files.
An event is a specific activity in a repository that triggers GitHub Actions to start. For example, activity can originate from GitHub when someone creates a pull request, opens an issue, or pushes a commit to a repository. You can also trigger GitHub Actions on a schedule.
A job is a set of steps in a workflow that execute on the same runner (or server). Each step is either a shell script/command that will be executed, or an Action that will be run. Steps are executed in order and are dependent on each other.
A workflow is one (or a set of) job(s) that are defined in a script (YAML file) and triggered by events
A runner is a server that runs your workflows when they’re triggered. Each runner can run a single job at a time. GitHub provides Ubuntu Linux, Microsoft Windows, and macOS runners to run your workflows; each workflow run executes in a fresh, newly-provisioned virtual machine.
When to start with github actions? NOW!
name: python-package
on: [push, pull_request]
jobs:
build:
name: Build for (${{ matrix.python-version }}, ${{ matrix.os }})
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: ['ubuntu-latest', 'macos-latest', 'windows-latest']
python-version: ['3.6', '3.7', '3.8', '3.9']
steps:
- uses: actions/checkout@v2
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
- name: Lint with flake8
run: |
pip install flake8
flake8 mypackage tests
- name: Test with pytest
run: |
pip install pytest
pytest tests
It will save you time and the planet!
Restrict branch and event types
project-to-save-the-planet/
├── docs/
│ └── the_plan.md
│ └── ...
├── src/
│ ├── save_the_planet.py
│ ├── supporting_documentation.md
│ └── ...
├── tests/
│ └── ...
├── ...
└── README.md
Use CPU versions of tensorflow and pytorch
When?
See: Cache action
# tests.yaml
jobs:
test:
steps:
...
- uses: actions/cache@v3
id: cache-python-env
with:
path: ${{ env.pythonLocation }}
key: ${{ env.pythonLocation }}-${{ hashFiles('pyproject.toml') }}
- name: Install dependencies
if: steps.cache-python-env.outputs.cache-hit != 'true'
run: |
python -m pip install -e .
Restart tests from last failed test with the Pytest --last-failed
option
Exising GitHub action:
Reduce:
Reuse:
Recycle:
Check out https://github.com/UtrechtUniversity/programming-cafe if you want to try exercises.
Check out https://blog.esciencecenter.nl/ for the original blog post
Jelle Treep