Skip to content

Refactor GitHub Actions workflows #935

Refactor GitHub Actions workflows

Refactor GitHub Actions workflows #935

Workflow file for this run

name: Tests
on:
push:
branches:
- master
pull_request:
workflow_dispatch:
inputs:
debug_enabled:
type: boolean
description: 'Run the build with tmate debugging enabled (https://github.com/marketplace/actions/debugging-with-tmate)'
required: false
default: false
jobs:
test:
runs-on: ubuntu-latest
steps:
- name: Configure environment
run: |
git config --global user.name dl-registry
git config --global user.email [email protected]
- name: Install git-annex
shell: bash
run: |
bash <(wget -q -O- https://neuro.debian.net/_files/neurodebian-travis.sh)
sudo apt-get update -qq
sudo apt-get install eatmydata
sudo eatmydata apt-get install git-annex-standalone
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up Python 3.9
uses: actions/setup-python@v5
with:
python-version: '3.9'
- name: Install dependencies
run: |
pip install --upgrade pip
pip install -r requirements.test.txt
pip install wheel
pip install .[test]
- name: Remove build artifacts
run: rm -rf build dist
- name: Load env vars from env.test to GitHub Actions workflow
run: dotenv -f env.test list >> "$GITHUB_ENV"
- name: Start services with Docker Compose
run: docker compose -f docker-compose.test.yml up -d
# Enable tmate debugging of manually-triggered workflows if the input option was provided
- name: Setup tmate session
uses: mxschmitt/action-tmate@v3
if: ${{ github.event_name == 'workflow_dispatch' && inputs.debug_enabled }}
# Run tests if the workflow is not triggered for debugging
- name: Run tests with Coverage
run: python -m pytest -s -v --cov=. --cov-report=xml
if: ${{ github.event_name != 'workflow_dispatch' || !inputs.debug_enabled }}
- name: Stop services provided by Docker Compose
run: docker compose -f docker-compose.test.yml down
- name: Upload coverage to codecov
uses: codecov/codecov-action@v4
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}