-
Notifications
You must be signed in to change notification settings - Fork 6
234 lines (226 loc) · 9.6 KB
/
ci.yaml
File metadata and controls
234 lines (226 loc) · 9.6 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
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
name: Weekly global Tool Linting and Tests
on:
schedule:
# Run at midnight every monday
- cron: '0 0 * * 1'
repository_dispatch:
types: [run-all-tool-tests-command]
env:
GALAXY_RELEASE: release_20.09
GALAXY_FORK: galaxyproject
MAX_CHUNKS: 40
jobs:
setup:
name: Setup cache
if: github.repository_owner == 'ASaiM'
runs-on: ubuntu-latest
outputs:
branch: ${{ steps.get-fork-branch.outputs.branch }}
fork: ${{ steps.get-fork-branch.outputs.fork }}
galaxy_head_sha: ${{ steps.get-galaxy-sha.outputs.galaxy_head_sha }}
nchunks: ${{ steps.get-chunks.outputs.nchunks }}
chunk_list: ${{ steps.get-chunks.outputs.chunk_list }}
strategy:
matrix:
python-version: [3.7]
steps:
- name: Add reaction
if: ${{ github.event.client_payload.slash_command.command == 'run-all-tool-tests' }}
uses: peter-evans/create-or-update-comment@v1
with:
token: ${{ secrets.PAT }}
repository: ${{ github.event.client_payload.github.payload.repository.full_name }}
comment-id: ${{ github.event.client_payload.github.payload.comment.id }}
reaction-type: hooray
- name: Set galaxy fork and branch
id: get-fork-branch
run: |
TMP="${{ github.event.client_payload.slash_command.args.named.fork }}"
echo "::set-output name=fork::${TMP:-$GALAXY_FORK}"
TMP="${{ github.event.client_payload.slash_command.args.named.branch }}"
echo "::set-output name=branch::${TMP:-$GALAXY_RELEASE}"
- name: Determine latest commit in the Galaxy repo
id: get-galaxy-sha
run: echo "::set-output name=galaxy_head_sha::$(git ls-remote https://github.com/${{ steps.get-fork-branch.outputs.fork }}/galaxy refs/heads/${{ steps.get-fork-branch.outputs.branch }} | cut -f1)"
- uses: actions/setup-python@v1
with:
python-version: ${{ matrix.python-version }}
- name: Cache .cache/pip
uses: actions/cache@v2
id: cache-pip
with:
path: ~/.cache/pip
key: pip_cache_py_${{ matrix.python-version }}_gxy_${{ steps.get-galaxy-sha.outputs.galaxy_head_sha }}
# Install the `wheel` package so that when installing other packages which
# are not available as wheels, pip will build a wheel for them, which can be cached.
- name: Install wheel
run: pip install wheel
- name: Install Planemo
run: pip install planemo
- name: Fake a Planemo run to update cache
if: steps.cache-pip.outputs.cache-hit != 'true'
run: |
touch tool.xml
PIP_QUIET=1 planemo test --galaxy_python_version ${{ matrix.python-version }} --no_conda_auto_init --galaxy_source 'https://github.com/${{ steps.get-fork-branch.outputs.fork }}/galaxy' --galaxy_branch "${{ steps.get-fork-branch.outputs.branch }}" --galaxy_python_version ${{ matrix.python-version }}
- uses: actions/checkout@v2
with:
fetch-depth: 1
- name: Planemo ci_find_repos
run: planemo ci_find_repos --exclude packages --exclude deprecated --exclude_from .tt_skip --output repository_list.txt
- name: Show repository list
run: cat repository_list.txt
- name: Planemo ci_find_tools for the repository list
run: planemo ci_find_tools --output tool_list.txt $(cat repository_list.txt)
- name: Show tool list
run: cat tool_list.txt
- name: Compute chunks
id: get-chunks
run: |
nchunks=$(wc -l < tool_list.txt)
if [ "$nchunks" -gt "$MAX_CHUNKS" ]; then
nchunks=$MAX_CHUNKS
elif [ "$nchunks" -eq 0 ]; then
nchunks=1
fi
echo "::set-output name=nchunks::$nchunks"
echo "::set-output name=chunk_list::[$(seq -s ", " 0 $(($nchunks - 1)))]"
- name: Show chunks
run: |
echo 'Using ${{ steps.get-chunks.outputs.nchunks }} chunks (${{ steps.get-chunks.outputs.chunk_list }})'
test:
name: Test tools
# This job runs on Linux
runs-on: ubuntu-latest
needs: setup
strategy:
fail-fast: false
matrix:
chunk: ${{ fromJson(needs.setup.outputs.chunk_list) }}
python-version: [3.7]
services:
postgres:
image: postgres:11
env:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgres
POSTGRES_DB: postgres
ports:
- 5432:5432
steps:
# checkout the repository
# and use it as the current working directory
- uses: actions/checkout@v2
with:
fetch-depth: 1
- uses: actions/setup-python@v1
with:
python-version: ${{ matrix.python-version }}
- name: Cache .cache/pip
uses: actions/cache@v2
id: cache-pip
with:
path: ~/.cache/pip
key: pip_cache_py_${{ matrix.python-version }}_gxy_${{ needs.setup.outputs.galaxy_head_sha }}
- name: Install Planemo
run: pip install planemo
- name: Planemo ci_find_tools, chunked
run: planemo ci_find_tools --chunk_count ${{ needs.setup.outputs.nchunks }} --chunk ${{ matrix.chunk }} --exclude test_repositories --exclude packages --exclude deprecated --exclude_from .tt_skip --group_tools --output tool_list_chunk.txt
- name: Show tool list chunk
run: cat tool_list_chunk.txt
- name: Planemo test tools
run: |
mkdir json_output
while read -r TOOL_GROUP; do
# Check if any of the lines in .tt_biocontainer_skip is a substring of $TOOL_GROUP
if echo $TOOL_GROUP | grep -qf .tt_biocontainer_skip; then
PLANEMO_OPTIONS=""
else
PLANEMO_OPTIONS="--biocontainers --no_dependency_resolution --no_conda_auto_init"
fi
json=$(mktemp -u -p json_output --suff .json)
PIP_QUIET=1 planemo test --database_connection postgresql://postgres:postgres@localhost:5432/galaxy $PLANEMO_OPTIONS --galaxy_source "https://github.com/${{ needs.setup.outputs.fork }}/galaxy" --galaxy_branch "${{ needs.setup.outputs.branch }}" --galaxy_python_version ${{ matrix.python-version }} --test_output_json "$json" $TOOL_GROUP || true
docker system prune --all --force --volumes || true
done < tool_list_chunk.txt
if [ ! -s tool_list_chunk.txt ]; then
echo '{"tests":[]}' > "$(mktemp -u -p json_output --suff .json)"
fi
- name: Merge tool_test_output.json files
run: planemo merge_test_reports json_output/*.json tool_test_output.json
- name: Create tool_test_output.html
run: planemo test_reports tool_test_output.json --test_output tool_test_output.html
- name: Copy artifacts into place
run: |
mkdir upload
mv tool_test_output.json tool_test_output.html upload/
- uses: actions/upload-artifact@v2
with:
name: 'Tool test output ${{ matrix.chunk }}'
path: upload
# - combine the results of the test chunks (which will never fail due
# to `|| true`) and create a global test report as json and html which
# is provided as artifact
# - check if any tool test actually failed (by lookup in the combined json)
# and fail this step if this is the case
combine_outputs:
name: Combine chunked test results
needs: [setup, test]
strategy:
matrix:
python-version: [3.7]
# This job runs on Linux
runs-on: ubuntu-latest
steps:
- uses: actions/download-artifact@v2
with:
path: artifacts
- uses: actions/setup-python@v1
with:
python-version: ${{ matrix.python-version }}
- name: Cache .cache/pip
uses: actions/cache@v2
id: cache-pip
with:
path: ~/.cache/pip
key: pip_cache_py_${{ matrix.python-version }}_gxy_${{ needs.setup.outputs.galaxy_head_sha }}
- name: Install Planemo
run: pip install planemo
- name: Install jq
run: sudo apt-get install jq
- name: Combine outputs
run: find artifacts/ -name tool_test_output.json -exec sh -c 'planemo merge_test_reports "$@" tool_test_output.json' sh {} +
- name: Create tool_test_output.html
run: planemo test_reports tool_test_output.json --test_output tool_test_output.html
- name: Copy artifacts into place
run: |
mkdir upload
mv tool_test_output.json tool_test_output.html upload/
- uses: actions/upload-artifact@v2
with:
name: 'All tool test results'
path: upload
- name: Create URL to the run output
if: ${{ github.event.client_payload.slash_command.command == 'run-all-tool-tests' }}
id: vars
run: echo ::set-output name=run-url::https://github.com/$GITHUB_REPOSITORY/actions/runs/$GITHUB_RUN_ID
- name: Gather statistics
if: ${{ github.event.client_payload.slash_command.command == 'run-all-tool-tests' }}
id: stats
run: echo ::set-output name=statistics::$(jq '.["tests"][]["data"]["status"]' upload/tool_test_output.json | sed 's/"//g' | sort | uniq -c)
- name: Create comment
if: ${{ github.event.client_payload.slash_command.command == 'run-all-tool-tests' }}
uses: peter-evans/create-or-update-comment@v1
with:
token: ${{ secrets.PAT }}
repository: ${{ github.event.client_payload.github.payload.repository.full_name }}
issue-number: ${{ github.event.client_payload.github.payload.issue.number }}
body: |
Summary:
${{ steps.stats.outputs.statistics }}
[Find all tool test results here][1]
[1]: ${{ steps.vars.outputs.run-url }}
- name: Check status of combined outputs
run: |
if jq '.["tests"][]["data"]["status"]' upload/tool_test_output.json | grep -v "success"; then
echo "Unsuccessful tests found, inspect the 'All tool test results' artifact for details."
exit 1
fi