You can also configure jobs to run with dependencies in GitHub actions. Like in the image below.
In this case, the "build" job and the "style" job need to both run without issues before any of the "windows" steps can run. Setting up dependencies like this can be a great way to prevent unnecessary code from running. The only downside is
Example
If you want to run GitHub actions with dependencies yourself, you can use the example below.
name: Python Unit
on:
pull_request:
branches:
- main
jobs:
style:
runs-on: ubuntu-latest
steps:
- uses: actions/[email protected]
- name: Set up Python
uses: actions/[email protected]
with:
python-version: "3.7"
- name: Install dependencies
run: |
python -m pip install --upgrade pip
python -m pip install -r requirements.txt
python -m pip install -r dev-requirements.txt
- name: Test with pytest
run: |
flake8
build:
strategy:
matrix:
python-version: ['3.7', '3.8', '3.9', '3.10']
os: [ubuntu-latest]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/[email protected]
- name: Set up Python ${{ matrix.python-version }}
uses: actions/[email protected]
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
python -m pip install -r requirements.txt
python -m pip install -r dev-requirements.txt
- name: Test with pytest
run: |
pytest --verbose
windows:
strategy:
matrix:
python-version: ['3.7', '3.8', '3.9', '3.10']
os: [windows-latest]
runs-on: ${{ matrix.os }}
needs: [style, build]
steps:
- uses: actions/[email protected]
- name: Set up Python ${{ matrix.python-version }}
uses: actions/[email protected]
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
python -m pip install -r requirements.txt
python -m pip install -r dev-requirements.txt
- name: Test with pytest
run: |
pytest --verbose