Skip to content
Draft
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
48 changes: 42 additions & 6 deletions .github/workflows/rhiza_deptry.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,45 @@ jobs:
with:
token: ${{ secrets.GH_PAT }}

- name: Run deptry
run: make deptry
# NOTE: make deptry is good style because it encapsulates the folders to check
# (e.g. src and book/marimo) and keeps CI in sync with local development.
# Since we use a 'uv' container, the Makefile is optimised to use the
# pre-installed 'uv' and 'uvx' from the system PATH.
- name: Extract folder variables
id: folders
run: |
# Extract SOURCE_FOLDER from the project configuration (via Makefile)
# shellcheck disable=SC2016 # Single quotes intentional - Make syntax, not shell expansion
SOURCE_FOLDER=$(make -s -f Makefile -f - <<< 'print: ; @echo $(or $(SOURCE_FOLDER),src)' print)
echo "source=$SOURCE_FOLDER" >> "$GITHUB_OUTPUT"

# Extract MARIMO_FOLDER from the project configuration (via Makefile)
# shellcheck disable=SC2016 # Single quotes intentional - Make syntax, not shell expansion
MARIMO_FOLDER=$(make -s -f Makefile -f - <<< 'print: ; @echo $(or $(MARIMO_FOLDER),marimo)' print)
echo "marimo=$MARIMO_FOLDER" >> "$GITHUB_OUTPUT"

# Extract Python version
PYTHON_VERSION=$(cat .python-version 2>/dev/null || echo "3.13")
echo "python_version=$PYTHON_VERSION" >> "$GITHUB_OUTPUT"

echo "Detected SOURCE_FOLDER: $SOURCE_FOLDER"
echo "Detected MARIMO_FOLDER: $MARIMO_FOLDER"
echo "Using Python version: $PYTHON_VERSION"

- name: Run deptry on source folder
if: steps.folders.outputs.source != ''
run: |
if [ -d "${{ steps.folders.outputs.source }}" ]; then
uvx -p "${{ steps.folders.outputs.python_version }}" deptry "${{ steps.folders.outputs.source }}"
else
echo "Source folder ${{ steps.folders.outputs.source }} does not exist, skipping"
fi

- name: Run deptry on marimo folder
if: steps.folders.outputs.marimo != ''
run: |
if [ -d "${{ steps.folders.outputs.marimo }}" ]; then
if [ -d "${{ steps.folders.outputs.source }}" ]; then
uvx -p "${{ steps.folders.outputs.python_version }}" deptry "${{ steps.folders.outputs.marimo }}" "${{ steps.folders.outputs.source }}" --ignore DEP004
else
uvx -p "${{ steps.folders.outputs.python_version }}" deptry "${{ steps.folders.outputs.marimo }}" --ignore DEP004
fi
else
echo "Marimo folder ${{ steps.folders.outputs.marimo }} does not exist, skipping"
fi
3 changes: 2 additions & 1 deletion .gitlab/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,8 @@ This directory contains GitLab CI/CD workflow configurations that mirror the fun
- On merge requests to main/master

**Key Features:**
- Automatic source folder detection
- Extracts SOURCE_FOLDER and MARIMO_FOLDER from Makefile configuration
- Automatically detects and checks all configured source folders
- Identifies unused dependencies

**Equivalent GitHub Action:** `.github/workflows/rhiza_deptry.yml`
Expand Down
8 changes: 6 additions & 2 deletions .gitlab/TESTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -98,12 +98,16 @@ This workflow is designed for repositories that use rhiza as a template, not for

**Expected behavior:**
- Checks for missing/obsolete dependencies
- Automatically detects source folder (`src/` or `.`)
- Automatically extracts SOURCE_FOLDER and MARIMO_FOLDER from Makefile configuration
- Runs deptry on detected folders if they exist
- Reports unused dependencies

**Manual test:**
```bash
# Run deptry locally
# Run deptry locally using make (recommended)
make deptry

# Or run deptry directly
uvx deptry src/
```

Expand Down
29 changes: 28 additions & 1 deletion .gitlab/workflows/rhiza_deptry.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,34 @@ deptry:check:
needs: []
image: ghcr.io/astral-sh/uv:0.9.30-bookworm
script:
- make deptry
# Extract SOURCE_FOLDER and MARIMO_FOLDER from the project configuration
# and run deptry on detected folders
- |
SOURCE_FOLDER=$(make -s -f Makefile -f - <<< 'print: ; @echo $(or $(SOURCE_FOLDER),src)' print)
MARIMO_FOLDER=$(make -s -f Makefile -f - <<< 'print: ; @echo $(or $(MARIMO_FOLDER),marimo)' print)
PYTHON_VERSION=$(cat .python-version 2>/dev/null || echo "3.13")

echo "Detected SOURCE_FOLDER: $SOURCE_FOLDER"
echo "Detected MARIMO_FOLDER: $MARIMO_FOLDER"
echo "Using Python version: $PYTHON_VERSION"

# Run deptry on source folder if it exists
if [ -n "$SOURCE_FOLDER" ] && [ -d "$SOURCE_FOLDER" ]; then
uvx -p "$PYTHON_VERSION" deptry "$SOURCE_FOLDER"
else
echo "Source folder $SOURCE_FOLDER does not exist, skipping"
fi

# Run deptry on marimo folder if it exists
if [ -n "$MARIMO_FOLDER" ] && [ -d "$MARIMO_FOLDER" ]; then
if [ -d "$SOURCE_FOLDER" ]; then
uvx -p "$PYTHON_VERSION" deptry "$MARIMO_FOLDER" "$SOURCE_FOLDER" --ignore DEP004
else
uvx -p "$PYTHON_VERSION" deptry "$MARIMO_FOLDER" --ignore DEP004
fi
else
echo "Marimo folder $MARIMO_FOLDER does not exist, skipping"
fi
rules:
- if: $CI_PIPELINE_SOURCE == "merge_request_event"
- if: $CI_COMMIT_BRANCH