-
Notifications
You must be signed in to change notification settings - Fork 0
87 lines (75 loc) · 2.43 KB
/
validate.yml
File metadata and controls
87 lines (75 loc) · 2.43 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
name: Validate WDL scripts
on:
# Trigger after the Zip workflow finishes (covers wdl_tasks changes)
workflow_run:
workflows: ["Build imports zips"]
types: [completed]
# Trigger when workflow WDLs are edited directly
push:
branches: [master, dev-branch]
paths:
- "workflows/*/*.wdl"
- ".github/workflows/validate.yml"
pull_request:
paths:
- "workflows/*/*.wdl"
- ".github/workflows/validate.yml"
jobs:
validate:
name: Validate WDL workflow with WOMtool
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 2
- name: Download WOMtool jar
id: download_womtool
run: |
wget -q https://github.com/broadinstitute/cromwell/releases/download/90/womtool-90.jar -O womtool.jar
- name: Find changed workflow dirs
id: changed_dirs
run: |
if [ "${{ github.event_name }}" = "workflow_run" ]; then
base_ref=HEAD^
else
base_ref=${{ github.base_ref || 'HEAD^' }}
fi
dirs=$(git diff --name-only $base_ref HEAD \
| grep -E 'workflows/.+(\.wdl$|imports\.zip$)' \
| xargs -r -n1 dirname \
| sort -u)
if [ -n "$dirs" ]; then
{
echo "dirs<<EOF"
echo "$dirs"
echo "EOF"
} >> $GITHUB_OUTPUT
fi
- name: Unzip imports if present
if: steps.changed_dirs.outputs.dirs != ''
run: |
# turn any newlines in the output into spaces
DIRS="${{ steps.changed_dirs.outputs.dirs }}"
DIRS="${DIRS//$'\n'/ }"
for d in $DIRS; do
if [ -f "$d/imports.zip" ]; then
echo "Unzipping $d/imports.zip"
unzip -o "$d/imports.zip" -d "$d/imports"
fi
done
- name: Validate changed workflows
if: steps.changed_dirs.outputs.dirs != ''
run: |
# Normalize to space-separated list (convert any newlines to spaces)
DIRS="${{ steps.changed_dirs.outputs.dirs }}"
DIRS="${DIRS//$'\n'/ }"
for d in $DIRS; do
# Skip if no .wdl files
for w in "$d"/*.wdl; do
[ -e "$w" ] || continue
echo "Validating $w"
java -jar womtool.jar validate "$w" || exit 1
done
done
shell: bash