-
Notifications
You must be signed in to change notification settings - Fork 3
199 lines (176 loc) · 6.12 KB
/
lint-pipelines.yml
File metadata and controls
199 lines (176 loc) · 6.12 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
name: Lint nf-core 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
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