Skip to content

minor change

minor change #14

Workflow file for this run

name: CI
on:
push:
branches:
- main
- dev
paths-ignore:
- "**/meta.yml"
pull_request:
branches:
- main
paths-ignore:
- "**/meta.yml"
workflow_dispatch:
# Cancel if a newer run is started
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NXF_ANSI_LOG: false
# renovate: datasource=github-releases depName=nextflow/nextflow versioning=semver
NXF_VER: "25.04.8"
jobs:
prettier:
runs-on: ubuntu-latest
steps:
- name: Check out code
uses: actions/checkout@v4
- name: Setup Node
uses: actions/setup-node@v4
with:
node-version: "20"
- name: Install Prettier
run: npm install -g prettier
- name: Run Prettier check
run: prettier --check .
editorconfig:
runs-on: ubuntu-latest
steps:
- name: Check out code
uses: actions/checkout@v4
- name: Setup Python
uses: actions/setup-python@v5
with:
python-version: "3.11"
- name: Install editorconfig-checker
run: pip install editorconfig-checker
- name: Run editorconfig-checker
run: ec
detect-changed-modules:
name: Detect changed modules
runs-on: ubuntu-latest
outputs:
paths: ${{ steps.list.outputs.paths }}
modules: ${{ steps.components.outputs.modules }}
steps:
- name: Check out code
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Detect changed test paths
id: list
run: |
# Get base commit for comparison
if [ "${{ github.event_name }}" == "pull_request" ]; then
BASE_SHA="${{ github.event.pull_request.base.sha }}"
else
BASE_SHA="HEAD~1"
fi
echo "Comparing against: $BASE_SHA"
# Get changed files
CHANGED_FILES=$(git diff --name-only $BASE_SHA...HEAD || git diff --name-only HEAD~1 HEAD)
echo "Changed files:"
echo "$CHANGED_FILES"
# Extract test paths for changed modules
CHANGED_PATHS=()
while IFS= read -r file; do
# Check if file is in modules directory
if [[ "$file" =~ ^modules/([^/]+)/([^/]+)/ ]]; then
org="${BASH_REMATCH[1]}"
module="${BASH_REMATCH[2]}"
test_path="tests/modules/${org}/${module}"
# Check if test exists
if [ -d "$test_path" ]; then
if [[ ! " ${CHANGED_PATHS[@]} " =~ " ${test_path} " ]]; then
CHANGED_PATHS+=("$test_path")
fi
fi
fi
# Also check if test files themselves changed
if [[ "$file" =~ ^tests/modules/([^/]+)/([^/]+)/ ]]; then
test_path="$file"
# Remove the main.nf or nextflow.config to get the directory
test_path="${test_path%/*}"
if [[ ! " ${CHANGED_PATHS[@]} " =~ " ${test_path} " ]]; then
CHANGED_PATHS+=("$test_path")
fi
fi
done <<< "$CHANGED_FILES"
# Convert to JSON array
if [ ${#CHANGED_PATHS[@]} -eq 0 ]; then
echo 'paths=[]' >> $GITHUB_OUTPUT
echo "No changed modules with tests found."
else
PATHS_JSON=$(printf '%s\n' "${CHANGED_PATHS[@]}" | jq -R . | jq -s .)
{
echo "paths<<EOF"
echo "$PATHS_JSON"
echo "EOF"
} >> $GITHUB_OUTPUT
echo "Changed test paths:"
printf '%s\n' "${CHANGED_PATHS[@]}"
fi
- name: Separate modules
id: components
run: |
PATHS='${{ steps.list.outputs.paths }}'
if [ "$PATHS" == "[]" ]; then
echo 'modules=[]' >> $GITHUB_OUTPUT
else
MODULES=$(echo "$PATHS" | jq -c 'map(gsub("tests/modules/"; ""))')
{
echo "modules<<EOF"
echo "$MODULES"
echo "EOF"
} >> $GITHUB_OUTPUT
fi
- name: Debug
run: |
echo "Paths: ${{ steps.list.outputs.paths }}"
echo "Modules: ${{ steps.components.outputs.modules }}"
test-modules:
name: "${{ matrix.profile }} | ${{ matrix.module }}"
needs: [detect-changed-modules]
if: needs.detect-changed-modules.outputs.modules != '[]'
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
module: ${{ fromJson(needs.detect-changed-modules.outputs.modules) }}
profile: [docker]
steps:
- name: Check out code
uses: actions/checkout@v4
- name: Install Nextflow
uses: nf-core/setup-nextflow@v1
with:
version: ${{ env.NXF_VER }}
- name: Run test for ${{ matrix.module }}
run: |
MODULE_PATH="${{ matrix.module }}"
TEST_DIR="tests/modules/${MODULE_PATH}"
echo "Testing module: ${MODULE_PATH}"
echo "Test directory: ${TEST_DIR}"
echo "Profile: ${{ matrix.profile }}"
if [ ! -d "${TEST_DIR}" ]; then
echo "Error: Test directory ${TEST_DIR} not found"
exit 1
fi
cd "${TEST_DIR}"
# Create output directory
mkdir -p "../../../test_results/${MODULE_PATH}"
# Run test with specified profile
if [ "${{ matrix.profile }}" == "docker" ]; then
PROFILE_FLAG="-with-docker"
elif [ "${{ matrix.profile }}" == "singularity" ]; then
PROFILE_FLAG="-with-singularity"
else
PROFILE_FLAG=""
fi
# Run test workflow
# Nextflow will automatically detect and run the workflow defined in main.nf
nextflow run main.nf \
-c nextflow.config \
-c ../../../config/nextflow.config \
--outdir "../../../test_results/${MODULE_PATH}" \
$PROFILE_FLAG \
-with-report "../../../test_results/${MODULE_PATH}/report.html" \
-with-trace "../../../test_results/${MODULE_PATH}/trace.txt" \
|| exit 1
- name: Upload test results
if: always()
uses: actions/upload-artifact@v4
with:
name: test-results-${{ matrix.profile }}-${{ matrix.module }}
path: test_results/${{ matrix.module }}/
retention-days: 7
confirm-pass-tests:
name: Confirm all tests passed
runs-on: ubuntu-latest
needs: [test-modules]
if: always()
steps:
- name: One or more tests failed
if: ${{ contains(needs.*.result, 'failure') }}
run: exit 1
- name: One or more tests cancelled
if: ${{ contains(needs.*.result, 'cancelled') }}
run: exit 1
- name: All tests ok
if: ${{ contains(needs.*.result, 'success') }}
run: exit 0
- name: Debug
if: always()
run: |
echo "::group::DEBUG: Test Results"
echo "DEBUG: toJSON(needs) = ${{ toJSON(needs) }}"
echo "DEBUG: toJSON(needs.*.result) = ${{ toJSON(needs.*.result) }}"
echo "::endgroup::"