Lint sanger-tol Pipelines #66
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Lint sanger-tol Pipelines | |
| on: | |
| schedule: | |
| # Run nightly at midnight UTC | |
| - cron: "0 0 * * *" | |
| workflow_dispatch: | |
| inputs: | |
| pipelines: | |
| description: "Specific pipeline(s) to lint (comma-separated, leave empty for all)" | |
| type: string | |
| default: "" | |
| modules: | |
| description: "Specific module(s) to lint (comma-separated, leave empty for all)" | |
| type: string | |
| default: "" | |
| subworkflows: | |
| description: "Specific subworkflow(s) to lint (comma-separated, leave empty for all)" | |
| type: string | |
| default: "" | |
| skip_pipelines: | |
| description: "Skip linting pipelines" | |
| type: boolean | |
| default: false | |
| skip_modules: | |
| description: "Skip linting modules" | |
| type: boolean | |
| default: false | |
| skip_subworkflows: | |
| description: "Skip linting subworkflows" | |
| type: boolean | |
| default: false | |
| no_cache: | |
| description: "Skip linting cache to force fresh linting of all files" | |
| type: boolean | |
| default: false | |
| permissions: | |
| contents: write | |
| jobs: | |
| # Setup job: Get Nextflow commit SHA for caching | |
| setup: | |
| runs-on: ubuntu-latest | |
| outputs: | |
| nf-commit: ${{ steps.nf-commit.outputs.sha }} | |
| steps: | |
| - name: Get Nextflow latest commit | |
| id: nf-commit | |
| run: | | |
| COMMIT=$(git ls-remote https://github.com/nextflow-io/nextflow.git HEAD | cut -f1) | |
| echo "sha=$COMMIT" >> $GITHUB_OUTPUT | |
| # Build Nextflow and upload as artifact | |
| build-nextflow: | |
| runs-on: ubuntu-latest | |
| needs: setup | |
| steps: | |
| - name: Restore Nextflow build cache | |
| id: cache-nextflow | |
| uses: actions/cache/restore@v4 | |
| with: | |
| path: nextflow-src/build/releases | |
| key: nextflow-build-${{ needs.setup.outputs.nf-commit }} | |
| - name: Set up Java | |
| if: steps.cache-nextflow.outputs.cache-hit != 'true' | |
| uses: actions/setup-java@v4 | |
| with: | |
| distribution: "temurin" | |
| java-version: "21" | |
| - name: Clone and build Nextflow | |
| id: build-nextflow | |
| if: steps.cache-nextflow.outputs.cache-hit != 'true' | |
| run: | | |
| git clone --depth 1 https://github.com/nextflow-io/nextflow.git nextflow-src | |
| cd nextflow-src | |
| make pack | |
| cd build/releases/ | |
| ln -s nextflow-*-dist nextflow | |
| - name: Save Nextflow build cache | |
| if: steps.cache-nextflow.outputs.cache-hit != 'true' && steps.build-nextflow.outcome == 'success' | |
| uses: actions/cache/save@v4 | |
| with: | |
| path: nextflow-src/build/releases | |
| key: nextflow-build-${{ needs.setup.outputs.nf-commit }} | |
| - name: Fix symlink if needed | |
| run: | | |
| cd nextflow-src/build/releases | |
| if [ -L nextflow ] && [ ! -e nextflow ]; then | |
| rm nextflow | |
| ln -s nextflow-*-dist nextflow | |
| fi | |
| - name: Upload Nextflow binary | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: nextflow-binary | |
| path: nextflow-src/build/releases/ | |
| retention-days: 1 | |
| lint: | |
| runs-on: ubuntu-latest | |
| needs: [setup, build-nextflow] | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| - name: Set up Python | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: "3.12" | |
| - name: Download Nextflow binary | |
| uses: actions/download-artifact@v4 | |
| with: | |
| name: nextflow-binary | |
| path: nextflow-src/build/releases | |
| - name: Add Nextflow to PATH | |
| run: | | |
| chmod +x nextflow-src/build/releases/nextflow* | |
| # Fix symlink if needed | |
| cd nextflow-src/build/releases | |
| if [ -L nextflow ] && [ ! -e nextflow ]; then | |
| rm nextflow | |
| ln -s nextflow-*-dist nextflow | |
| fi | |
| echo "${{ github.workspace }}/nextflow-src/build/releases" >> $GITHUB_PATH | |
| - name: Install dependencies | |
| run: pip install . | |
| - name: Build linting command | |
| id: build-cmd | |
| run: | | |
| CMD="strict-syntax-health --update-pipelines --update-readme" | |
| # Add skip flags based on inputs | |
| if [[ "${{ inputs.skip_pipelines }}" == "true" ]]; then | |
| CMD="$CMD --skip-pipelines" | |
| fi | |
| if [[ "${{ inputs.skip_modules }}" == "true" ]]; then | |
| CMD="$CMD --skip-modules" | |
| fi | |
| if [[ "${{ inputs.skip_subworkflows }}" == "true" ]]; then | |
| CMD="$CMD --skip-subworkflows" | |
| fi | |
| if [[ "${{ inputs.no_cache }}" == "true" ]]; then | |
| CMD="$CMD --no-cache" | |
| fi | |
| # Add specific filters if provided | |
| if [[ -n "${{ inputs.pipelines }}" ]]; then | |
| IFS=',' read -ra ITEMS <<< "${{ inputs.pipelines }}" | |
| for item in "${ITEMS[@]}"; do | |
| item=$(echo "$item" | xargs) | |
| [[ -n "$item" ]] && CMD="$CMD -p $item" | |
| done | |
| fi | |
| if [[ -n "${{ inputs.modules }}" ]]; then | |
| IFS=',' read -ra ITEMS <<< "${{ inputs.modules }}" | |
| for item in "${ITEMS[@]}"; do | |
| item=$(echo "$item" | xargs) | |
| [[ -n "$item" ]] && CMD="$CMD -m $item" | |
| done | |
| fi | |
| if [[ -n "${{ inputs.subworkflows }}" ]]; then | |
| IFS=',' read -ra ITEMS <<< "${{ inputs.subworkflows }}" | |
| for item in "${ITEMS[@]}"; do | |
| item=$(echo "$item" | xargs) | |
| [[ -n "$item" ]] && CMD="$CMD -s $item" | |
| done | |
| fi | |
| echo "cmd=$CMD" >> $GITHUB_OUTPUT | |
| echo "Running: $CMD" | |
| - name: Run linting | |
| env: | |
| SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }} | |
| run: ${{ steps.build-cmd.outputs.cmd }} | |
| - name: Run prek on all files to fix formatting | |
| uses: j178/prek-action@v1 | |
| with: | |
| install-only: true | |
| - run: prek run --all-files || true | |
| - name: Commit and push changes | |
| run: | | |
| git config --local user.email "github-actions[bot]@users.noreply.github.com" | |
| git config --local user.name "github-actions[bot]" | |
| git add README.md lint_results/ | |
| git diff --staged --quiet || git commit -m "Update lint results [skip ci]" | |
| git push |