-
Notifications
You must be signed in to change notification settings - Fork 96
220 lines (212 loc) · 7.03 KB
/
Copy pathworkflow_test.yml
File metadata and controls
220 lines (212 loc) · 7.03 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
# workflow level env vars cannot be used at the job level
# https://github.qkg1.topmunity/t/how-to-set-and-access-a-workflow-variable/17335/15
name: Galaxy Workflow Tests for push and PR
on:
push:
paths-ignore:
- '**/*.md'
- 'scripts/**'
- 'website/**'
pull_request:
paths-ignore:
- '**/*.md'
- 'scripts/**'
- 'website/**'
env:
GITHUB_USER: iwc-workflows-bot
jobs:
setup:
name: Setup cache and determine changed repositories
uses: ./.github/workflows/setup.yml
with:
python-version-list: "[\"3.11\"]"
max-chunks: 4
galaxy-fork: galaxyproject
galaxy-branch: release_26.0
# Planemo lint the changed repositories
lint:
name: Lint workflows
needs: setup
if: needs.setup.outputs.repository-list != ''
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ['3.11']
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 1
- uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Cache .cache/pip
uses: actions/cache@v4
id: cache-pip
with:
path: ~/.cache/pip
key: pip_cache_py_${{ matrix.python-version }}_gxy_${{ needs.setup.outputs.galaxy-head-sha }}
- name: Install wheel
run: pip install wheel
- name: Planemo lint workflows
uses: galaxyproject/planemo-ci-action@v1
id: lint
with:
mode: lint
workflows: true
repository-list: "${{ needs.setup.outputs.repository-list }}"
additional-planemo-options: --iwc
# Detect if any changed repo contains a .wt_instance file
# and set environment to 'secret-env' (if there is such a file)
# or None (otherwise)
determine_env:
name: Determine github environment to use
needs: setup
runs-on: ubuntu-latest
outputs:
environment: ${{ steps.check.outputs.environment }}
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 1
- id: check
run: |
echo "environment=" >> $GITHUB_OUTPUT
for repo in $(echo "${{ needs.setup.outputs.repository-list }}" | tr ',' '\n'); do
if [[ -f "$repo/.wt_instance" ]]; then
echo "Found $repo/.wt_instance"
echo "environment=secret-env" >> $GITHUB_OUTPUT
break
fi
done
echo "Will use $(cat $GITHUB_OUTPUT)"
test:
name: Test workflows
needs: [setup, determine_env]
if: ${{ needs.setup.outputs.repository-list != '' }}
uses: ./.github/workflows/test_workflows.yml
with:
galaxy-head-sha: ${{ needs.setup.outputs.galaxy-head-sha }}
chunk-count: ${{ fromJSON(needs.setup.outputs.chunk-count) }}
chunk-list: ${{ needs.setup.outputs.chunk-list }}
python-version-list: "[\"3.11\"]"
repository-list: ${{ needs.setup.outputs.repository-list }}
galaxy-fork: galaxyproject
galaxy-branch: release_26.0
check-outputs: false
galaxy-user-key-environment: ${{ needs.determine_env.outputs.environment }}
secrets: inherit
combine_outputs:
# same as tool step
name: Combine chunked test results
needs: [setup, test]
if: always()
strategy:
matrix:
python-version: ['3.11']
runs-on: ubuntu-latest
steps:
- uses: actions/download-artifact@v4
with:
path: artifacts
- uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Cache .cache/pip
uses: actions/cache@v4
id: cache-pip
with:
path: ~/.cache/pip
key: pip_cache_py_${{ matrix.python-version }}_gxy_{{ needs.setup.outputs.galaxy-head-sha }}
- name: Combine outputs
uses: galaxyproject/planemo-ci-action@v1
id: combine
with:
mode: combine
html-report: true
markdown-report: true
- run: cat upload/tool_test_output.md >> $GITHUB_STEP_SUMMARY
- name: Save PR number
run: echo ${{ github.event.number }} > ./upload/NR
- name: Debug PR number
run: |
cat ./upload/NR
- uses: actions/upload-artifact@v4
with:
name: 'All tool test results'
path: upload
- name: Check outputs
uses: galaxyproject/planemo-ci-action@v1
id: check
with:
mode: check
# deploy workflows to organization
deploy:
name: Deploy
needs: [setup,test,combine_outputs]
strategy:
matrix:
python-version: ['3.11']
runs-on: ubuntu-latest
if: github.ref == 'refs/heads/main' && github.repository_owner == 'galaxyproject'
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 1
- uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Cache .cache/pip
uses: actions/cache@v4
id: cache-pip
with:
path: ~/.cache/pip
key: pip_cache_py_${{ matrix.python-version }}_gxy_{{ needs.setup.outputs.galaxy-head-sha }}
- name: Install requirements for gen_crates.py
run: pip install -r workflows/requirements.txt
- name: Generate RO-Crate metadata for workflow repositories
run: python workflows/gen_crates.py workflows
- name: Set git user
run: |
git config --global user.email "$GITHUB_USER@galaxyproject.org"
git config --global user.name "$GITHUB_USER"
git config --global init.defaultBranch main
- uses: fusion-engineering/setup-git-credentials@v2
with:
credentials: 'https://${{ env.GITHUB_USER }}:${{ secrets.IWC_WORKFLOWS_BOT_TOKEN }}@github.com/'
- name: Update or create repositories in github namespace
uses: galaxyproject/planemo-ci-action@v1
with:
mode: deploy
repository-list: ${{ needs.setup.outputs.repository-list }}
workflows: true
workflow-namespace: iwc-workflows
github-token: ${{ secrets.IWC_WORKFLOWS_BOT_TOKEN }}
deploy-report:
name: Report deploy status
needs: [deploy]
if: ${{ always() && needs.deploy.result != 'success' && (github.ref == 'refs/heads/master' || github.ref == 'refs/heads/main' ) && github.repository_owner == 'galaxyproject' }}
runs-on: ubuntu-latest
steps:
# report to the PR if deployment failed
- name: Get PR object
uses: 8BitJonny/gh-get-current-pr@3.0.0
id: getpr
with:
sha: ${{ github.event.after }}
- name: Create comment
uses: peter-evans/create-or-update-comment@v4
with:
token: ${{ secrets.PAT }}
issue-number: ${{ steps.getpr.outputs.number }}
body: |
Attention: deployment ${{ needs.deploy.result }}!
https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}
determine-success:
name: Check workflow success
needs: [setup, lint, combine_outputs]
if: ${{ always() && github.ref != 'refs/heads/main' }}
runs-on: ubuntu-latest
steps:
- name: Check status
if: ${{ needs.combine_outputs.result != 'skipped' && (needs.lint.result != 'success' || needs.combine_outputs.result != 'success') }}
run: exit 1