Skip to content

LORIS-MRI tooling configuration (Docker version) #1182

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 0 additions & 23 deletions .github/actions/setup-python/action.yml

This file was deleted.

4 changes: 1 addition & 3 deletions .github/workflows/loristest.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
name: LORIS Test Suite

on:
- push
- pull_request
on: workflow_dispatch

jobs:
docker:
Expand Down
115 changes: 81 additions & 34 deletions .github/workflows/python-checks.yml
Original file line number Diff line number Diff line change
@@ -1,32 +1,73 @@
name: Python checks

on:
- push
- pull_request
on: pull_request

jobs:
docker:
name: Docker
runs-on: ubuntu-latest

strategy:
matrix:
python-version: ["3.11", "3.12"]

steps:
- name: Check out LORIS-MRI
uses: actions/checkout@v3

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2

- name: Build Docker image
id: build-and-push
uses: docker/build-push-action@v4
with:
context: .
file: ./test/python.Dockerfile
build-args: |
PYTHON_VERSION=${{ matrix.python-version }}
WORKSPACE=/workspace
tags: loris-python:${{ matrix.python-version }}
cache-from: type=gha,scope=loris-python-${{ matrix.python-version }}
cache-to: type=gha,scope=loris-python-${{ matrix.python-version }}
outputs: type=docker,dest=/tmp/loris-python-${{ matrix.python-version }}.tar

- name: Upload Docker image
uses: actions/upload-artifact@v4
with:
name: loris-python-${{ matrix.python-version }}
path: /tmp/loris-python-${{ matrix.python-version }}.tar

ruff:
name: "Ruff"
name: Ruff
needs: docker
runs-on: ubuntu-latest

strategy:
matrix:
python-version: ["3.11", "3.12"]

steps:
- name: Check out LORIS-MRI
uses: actions/checkout@v4
- name: Checkout LORIS-MRI
uses: actions/checkout@v4

- name: Set up Python
uses: ./.github/actions/setup-python
with:
python-version: ${{ matrix.python-version }}
- name: Download Docker image
uses: actions/download-artifact@v4
with:
name: loris-python-${{ matrix.python-version }}
path: /tmp

- name: Run Ruff
run: ruff check --output-format=github
- name: Load Docker image
run: docker load -i /tmp/loris-python-${{ matrix.python-version }}.tar

- name: Run Ruff
run: |
docker run -v ${{ github.workspace }}:/workspace -w /workspace loris-python:${{ matrix.python-version }} \
ruff check --output-format=github

pyright-strict:
name: "Pyright strict"
name: Pyright strict
needs: docker
runs-on: ubuntu-latest

strategy:
Expand All @@ -37,37 +78,43 @@ jobs:
- name: Check out LORIS-MRI
uses: actions/checkout@v4

- name: Set up Python
uses: ./.github/actions/setup-python
- name: Download Docker image
uses: actions/download-artifact@v4
with:
python-version: ${{ matrix.python-version }}
name: loris-python-${{ matrix.python-version }}
path: /tmp

- name: Load Docker image
run: docker load -i /tmp/loris-python-${{ matrix.python-version }}.tar

# Like in the other Pyright run, the `jq` arcane is used to translate the errors from JSON to
# the GitHub actions format
- name: Run Pyright
run: |
pyright --outputjson | jq -r '.generalDiagnostics[] | "::error file=\(.file),line=\(.range.start.line),col=\(.range.start.character)::\(.message)"'
(exit ${PIPESTATUS[0]})
docker run -v ${{ github.workspace }}:/workspace -w /workspace loris-python:${{ matrix.python-version }} bash -c \
"set -o pipefail && pyright --outputjson | bash test/pyright_to_github.sh"

pyrigh-global:
name: "Pyright global"
name: Pyright global
needs: docker
runs-on: ubuntu-latest

strategy:
matrix:
python-version: ["3.11", "3.12"]

steps:
- name: Check out LORIS-MRI
uses: actions/checkout@v4

- name: Set up Python
uses: ./.github/actions/setup-python
with:
python-version: ${{ matrix.python-version }}

- name: Run Pyright
run: |
cd test
pyright --outputjson | jq -r '.generalDiagnostics[] | "::error file=\(.file),line=\(.range.start.line),col=\(.range.start.character)::\(.message)"'
(exit ${PIPESTATUS[0]})
- name: Check out LORIS-MRI
uses: actions/checkout@v4

- name: Download Docker image
uses: actions/download-artifact@v4
with:
name: loris-python-${{ matrix.python-version }}
path: /tmp

- name: Load Docker image
run: docker load -i /tmp/loris-python-${{ matrix.python-version }}.tar

- name: Run Pyright
run: |
docker run -v ${{ github.workspace }}:/workspace -w /workspace loris-python:${{ matrix.python-version }} bash -c \
"cd test && set -o pipefail && pyright --outputjson | bash pyright_to_github.sh"
3 changes: 3 additions & 0 deletions test/pyright_to_github.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# This is a simple script to format Pyright errors (in JSON format) into GitHub errors, used by CI.
# TODO: Add formatting for warnings
jq -r '.generalDiagnostics[] | "::error file=\(.file),line=\(.range.start.line),col=\(.range.start.character)::\(.message)"'
25 changes: 25 additions & 0 deletions test/python.Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# This is a minimal Docker image to run static tests on the Python code of LORIS-MRI.
# It sets up Python and our Python dependencies, but does not configure a full setup
# to test LORIS-MRI (Perl code, database...).

# Python version to use for the tests
ARG PYTHON_VERSION=3.11

FROM python:${PYTHON_VERSION}-slim

# Path of the LORIS-MRI repository in the container
ARG WORKSPACE

RUN apt-get update

# Required for the Python library `mysqlclient`
RUN apt-get install -y default-libmysqlclient-dev build-essential pkg-config

# Used to format the Pyright errors to the GitHub format
RUN apt-get install -y jq

COPY ./python/requirements.txt requirements.txt

RUN pip install --no-cache-dir --root-user-action=ignore -r requirements.txt

ENV PYTHONPATH=${WORKSPACE}/python:${WORKSPACE}/python/react-series-data-viewer
Loading