Skip to content

Split sublibrary CI to only test on dependency changes #6

Split sublibrary CI to only test on dependency changes

Split sublibrary CI to only test on dependency changes #6

Workflow file for this run

name: Sublibrary CI
on:
pull_request:
branches:
- master
push:
branches:
- master
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: ${{ startsWith(github.ref, 'refs/pull/') }}
jobs:
detect-changes:
runs-on: ubuntu-latest
outputs:
# JSON array of {group, version} objects for matrix include
matrix: ${{ steps.compute.outputs.matrix }}
# Whether any sublibraries are affected
has_changes: ${{ steps.compute.outputs.has_changes }}
steps:
- uses: actions/checkout@v6
with:
fetch-depth: 0
- uses: julia-actions/setup-julia@v2
with:
version: '1'
- name: Compute affected sublibraries from dependency graph
id: compute
run: |
if [ "${{ github.event_name }}" = "push" ]; then
# For push events, compare against the previous commit
CHANGED=$(git diff --name-only ${{ github.event.before }} ${{ github.sha }} 2>/dev/null || git diff --name-only HEAD~1 HEAD)
else
# For pull requests, compare against the base branch
git fetch origin ${{ github.event.pull_request.base.ref }} --depth=1
CHANGED=$(git diff --name-only origin/${{ github.event.pull_request.base.ref }}...HEAD)
fi
MATRIX=$(echo "$CHANGED" | julia .github/scripts/compute_affected_sublibraries.jl .)
echo "Changed files in lib/:"
echo "$CHANGED" | grep "^lib/" || echo "(none)"
echo ""
echo "Matrix entries: $MATRIX"
echo "matrix=$MATRIX" >> "$GITHUB_OUTPUT"
if [ "$MATRIX" = "[]" ]; then
echo "has_changes=false" >> "$GITHUB_OUTPUT"
else
echo "has_changes=true" >> "$GITHUB_OUTPUT"
fi
test:
needs: detect-changes
if: needs.detect-changes.outputs.has_changes == 'true'
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
include: ${{ fromJson(needs.detect-changes.outputs.matrix) }}
steps:
- uses: actions/checkout@v6
- uses: julia-actions/setup-julia@v2
with:
version: ${{ matrix.version }}
- uses: actions/cache@v5
env:
cache-name: cache-artifacts
with:
path: ~/.julia/artifacts
key: ${{ runner.os }}-sublib-${{ env.cache-name }}-${{ hashFiles('**/Project.toml') }}
restore-keys: |
${{ runner.os }}-sublib-${{ env.cache-name }}-
${{ runner.os }}-sublib-
${{ runner.os }}-
- uses: julia-actions/julia-runtest@v1
with:
coverage: false
check_bounds: auto
env:
GROUP: ${{ matrix.group }}
- uses: julia-actions/julia-processcoverage@v1
- uses: codecov/codecov-action@v5
with:
token: ${{ secrets.CODECOV_TOKEN }}
files: lcov.info
fail_ci_if_error: false
disable_safe_directory: true