-
Notifications
You must be signed in to change notification settings - Fork 9
230 lines (201 loc) · 7.49 KB
/
ci.yml
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
# This workflow will install Python dependencies, run tests and lint with a single version of Python
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions
name: build
on:
push:
branches: [main, develop, 'GEN*', 'gen*']
paths-ignore:
- '**.md' # All Markdown files
- '**/docs/**' # Documentation directory
- '.github/workflows/codeql.yml' # Code scanner
- '.github/workflows/build_docs.yml' # mkdocs GH workflow
pull_request:
types:
- opened
- reopened
release:
types:
- created
env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}
TEST_PROJECT_SYNID: syn7208886
jobs:
determine-changes:
runs-on: ubuntu-latest
outputs:
non-test-changes: ${{ steps.get-changes.outputs.non-test-changes }}
steps:
- name: Checkout Code
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Determine Changes
id: get-changes
run: |
if [ "${{ github.event_name }}" == "push" ]; then
echo "Handling a push event..."
ALL_CHANGED_FILES=$(git diff --name-only HEAD^ HEAD)
elif [ "${{ github.event_name }}" == "pull_request" ]; then
echo "Handling a pull request event..."
git fetch origin ${{ github.base_ref }}
ALL_CHANGED_FILES=$(git diff --name-only origin/${{ github.base_ref }} HEAD)
fi
echo "All Changed Files: $ALL_CHANGED_FILES"
NON_TEST_CHANGES=$(echo "$ALL_CHANGED_FILES" | grep -v '^tests/' || true)
echo "Non-Test Changes: $NON_TEST_CHANGES"
echo "::set-output name=non-test-changes::$NON_TEST_CHANGES"
test:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: [3.8, 3.9]
steps:
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
sudo apt-get install -y bedtools
python -m pip install --upgrade pip
pip install flake8 pytest pytest-cov cython
pip install .
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
# - name: Lint with flake8
# run: |
# # stop the build if there are Python syntax errors or undefined names
# flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
# # exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
# flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
- name: Test with pytest
run: |
pytest tests/ --cov=genie --cov=genie_registry --cov-report=html
- name: Upload pytest test results
uses: actions/upload-artifact@v4
with:
name: pytest-results-${{ matrix.python-version }}
path: htmlcov
# Use always() to always run this step to publish test results when there are test failures
if: ${{ always() }}
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: psf/black@stable
with:
version: "~=23.12"
build-container:
needs: [test, lint]
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Setup Docker buildx
uses: docker/setup-buildx-action@v3
- name: Log into registry ${{ env.REGISTRY }}
uses: docker/#-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Extract Docker metadata
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
- name: Format tags as registry refs
id: registry_refs
env:
TAGS: ${{ steps.meta.outputs.json }}
run: |
echo tags=$(echo $TAGS | jq '.tags[] | "type=registry,ref=" + . + "_cache"| @text') >> $GITHUB_OUTPUT
- name: Build and push Docker image
id: build-and-push
uses: docker/build-push-action@v5
if: github.event_name != 'pull_request'
with:
context: .
push: true
provenance: false
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: ${{ steps.registry_refs.outputs.tags }},mode=max
cache-to: ${{ steps.registry_refs.outputs.tags }},mode=max
integration-tests:
needs: [determine-changes, lint, test, build-container]
runs-on: ubuntu-latest
if: ${{ needs.determine-changes.outputs.non-test-changes }}
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Extract Branch Name
run: |
if [ "$GITHUB_HEAD_REF" != "" ]; then
echo "BRANCH_NAME=$GITHUB_HEAD_REF" >> $GITHUB_ENV
else
echo "BRANCH_NAME=${GITHUB_REF#refs/heads/}" >> $GITHUB_ENV
fi
- name: Pull Public Docker Image from GHCR
run: |
docker pull ghcr.io/sage-bionetworks/genie:${{ env.BRANCH_NAME }}
- name: Start Docker Container
run: |
docker run -d --name genie-container \
-e SYNAPSE_AUTH_TOKEN="${{ secrets.SYNAPSE_AUTH_TOKEN }}" \
ghcr.io/sage-bionetworks/genie:${{ env.BRANCH_NAME }} \
sh -c "while true; do sleep 1; done"
- name: Run validation in test pipeline
run: |
docker exec genie-container \
python3 /root/Genie/bin/input_to_database.py \
mutation \
--project_id ${{ env.TEST_PROJECT_SYNID }} \
--onlyValidate \
--genie_annotation_pkg /root/annotation-tools
- name: Run processing on mutation data in test pipeline
run: |
docker exec genie-container \
python3 /root/Genie/bin/input_to_database.py mutation \
--project_id ${{ env.TEST_PROJECT_SYNID }} \
--genie_annotation_pkg /root/annotation-tools \
--createNewMafDatabase
- name: Run processing on non-mutation data in test pipeline
run: |
docker exec genie-container \
python3 /root/Genie/bin/input_to_database.py main \
--project_id ${{ env.TEST_PROJECT_SYNID }}
- name: Run consortium release in test pipeline
run: |
docker exec genie-container \
python3 /root/Genie/bin/database_to_staging.py Jan-2017 ../cbioportal TEST --test
- name: Run public release in test pipeline
run: |
docker exec genie-container \
python3 /root/Genie/bin/consortium_to_public.py Jan-2017 ../cbioportal TEST --test
- name: Stop and Remove Docker Container
run: docker stop genie-container && docker rm genie-container
deploy:
needs: [test, lint, build-container, integration-tests]
runs-on: ubuntu-latest
if: github.event_name == 'release'
permissions:
id-token: write
steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.x'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install setuptools wheel build
- name: Build distributions
run: python -m build
- name: Publish to pypi
uses: pypa/gh-action-pypi-publish@release/v1