-
Notifications
You must be signed in to change notification settings - Fork 1
/
first-pass.nf
140 lines (115 loc) · 3.29 KB
/
first-pass.nf
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
process CloneRepository {
input:
val repo_url
output:
path 'repo'
script:
"""
rm -rf /tmp/nextflow_repo/repo
mkdir -p /tmp/nextflow_repo
git clone ${repo_url} /tmp/nextflow_repo/repo
cp -r /tmp/nextflow_repo/repo ./repo
"""
}
process CheckReadme {
input:
path repo
script:
"""
cd repo
if [ -f README.md ]; then
echo "Found README.md"
elif [ -f README.rst ]; then
echo "Found README.rst"
elif [ -f README.txt ]; then
echo "Found README.txt"
elif [ -f README ]; then
echo "Found README"
else
echo "No README file found" >&2
exit 1
fi
"""
}
process CheckDependencies {
input:
path repo
script:
"""
cd repo
# Python Dependency Files
if find . -maxdepth 1 -type f -name '*requirements*' | grep -q .; then
echo "Found a requirements file"
elif [ -f Pipfile ]; then
echo "Found Pipfile for Python"
elif [ -f Pipfile.lock ]; then
echo "Found Pipfile.lock for Python"
elif [ -f setup.py ]; then
echo "Found setup.py for Python"
elif [ -f pyproject.toml ]; then
echo "Found pyproject.toml for Python"
# JavaScript/Node.js Dependency Files
elif [ -f package.json ]; then
echo "Found package.json for JavaScript/Node.js"
elif [ -f package-lock.json ]; then
echo "Found package-lock.json for JavaScript/Node.js"
elif [ -f yarn.lock ]; then
echo "Found yarn.lock for JavaScript/Node.js"
# Java Dependency Files
elif [ -f pom.xml ]; then
echo "Found pom.xml for Java"
elif [ -f build.gradle ]; then
echo "Found build.gradle for Java"
elif [ -f settings.gradle ]; then
echo "Found settings.gradle for Java"
# R Dependency Files
elif [ -f DESCRIPTION ]; then
echo "Found DESCRIPTION file for R"
elif [ -f renv.lock ]; then
echo "Found renv.lock file for R"
elif [ -d packrat ] && [ -f packrat/packrat.lock ]; then
echo "Found packrat.lock file for R"
else
echo "No recognized dependency files found" >&2
exit 1
fi
"""
}
process CheckTests {
input:
path repo
script:
"""
cd repo
# Check for test directories
if [ -d tests ] || [ -d test ]; then
echo "Found test directory (tests or test)"
# Check for test files with common extensions
elif find . -maxdepth 1 -name '*.test.js' -o -name '*.test.py' -o -name '*.test.java' | grep -q .; then
echo "Found test files with common extensions (*.test.js, *.test.py, *.test.java)"
else
echo "No test files or directories found" >&2
exit 1
fi
"""
}
process CheckAlmanack {
input:
path repo
output:
path "${params.output_dir}/almanack-results.json", emit: almanack_results
script:
"""
mkdir -p ${params.output_dir} # Create the output directory if it doesn't exist
python -c "import json; import almanack; print(json.dumps(almanack.table(repo_path='${repo}'), indent=4))" > \
${params.output_dir}/almanack-results.json
"""
}
workflow {
repo_url = params.repo_url
repoPath = CloneRepository(repo_url)
CheckReadme(repoPath)
CheckDependencies(repoPath)
CheckTests(repoPath)
CheckAlmanack(repoPath)
}