-
Notifications
You must be signed in to change notification settings - Fork 5
218 lines (185 loc) · 6.39 KB
/
Copy pathcd.yml
File metadata and controls
218 lines (185 loc) · 6.39 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
name: CD
on:
workflow_dispatch:
pull_request:
push:
branches:
- main
release:
types:
- published
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
env:
FORCE_COLOR: 3
jobs:
generate-indices:
name: Generate index artifacts
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
with:
fetch-depth: 0
- name: Set up Python
uses: actions/setup-python@v6
with:
python-version: "3.12"
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install db-dtypes duckdb google-cloud-bigquery google-cloud-bigquery-storage pandas pyarrow requests
- name: Authorize Google Cloud
uses: google-github-actions/auth@v3
with:
credentials_json: "${{ secrets.SERVICE_ACCOUNT_KEY }}"
create_credentials_file: true
export_environment_variables: true
- name: Execute SQL Query and Generate Parquet Files
run: |
python scripts/python/idc_index_data_manager.py \
--generate-parquet \
--output-dir release_artifacts
env:
GCP_PROJECT: ${{ env.GCP_PROJECT }}
- name: Generate GDC patient check parquet
run: |
python scripts/gdc/gdc_parquet_generator.py
mv gdc_idc_mapping.parquet release_artifacts/
env:
GCP_PROJECT: ${{ env.GCP_PROJECT }}
- name: Generate TCIA subset parquet
run: |
python scripts/tcia/tcia_parquet_generator.py \
release_artifacts/idc_index.parquet \
-o release_artifacts/tcia_idc_subset.parquet
- name: Report generated index sizes
run:
python scripts/python/report_index_sizes.py release_artifacts | tee -a
$GITHUB_STEP_SUMMARY
- name: Upload index artifacts
uses: actions/upload-artifact@v7
with:
name: idc-index-artifacts
path: release_artifacts/
retention-days: 14
if-no-files-found: error
dist:
name: Distribution build
runs-on: ubuntu-latest
needs: [generate-indices]
steps:
- uses: actions/checkout@v6
with:
fetch-depth: 0
- name: Download pre-generated index artifacts
uses: actions/download-artifact@v8
with:
name: idc-index-artifacts
path: release_artifacts/
- name: Move artifacts to project root for packaging
run: |
mv release_artifacts/*.parquet ./src/idc_index_data || true
mv release_artifacts/*.json ./src/idc_index_data || true
mv release_artifacts/*.sql ./src/idc_index_data || true
mv release_artifacts/*.zip ./src/idc_index_data || true
ls -la ./src/idc_index_data
- name: Build distribution package
run: |
# Unset GCP_PROJECT to prevent build hook from regenerating files
# Files already exist from the generate-indices job
unset GCP_PROJECT
python -m pip install --upgrade build
python -m build
env:
# Explicitly unset GCP_PROJECT to skip data generation in build hook
GCP_PROJECT: ""
- name: Upload distribution artifacts
uses: actions/upload-artifact@v7
with:
name: Packages
path: dist/
retention-days: 14
- name: Inspect package contents
run: |
python -m pip install --upgrade check-wheel-contents
ls -lh dist/
check-wheel-contents dist/*.whl
attach-to-release:
name: Attach artifacts to release
needs: [generate-indices]
runs-on: ubuntu-latest
if: github.event_name == 'release' && github.event.action == 'published'
steps:
- name: Download index artifacts
uses: actions/download-artifact@v8
with:
name: idc-index-artifacts
path: release_artifacts/
- name: Attach artifacts to release
uses: ncipollo/release-action@v1
with:
artifacts: "release_artifacts/*.parquet,release_artifacts/*.json,release_artifacts/*.sql"
allowUpdates: true
omitBodyDuringUpdate: true
upload-to-gcs:
name: Upload artifacts to GCS
needs: [generate-indices]
runs-on: ubuntu-latest
if: github.event_name == 'release' && github.event.action == 'published'
steps:
- name: Download index artifacts
uses: actions/download-artifact@v8
with:
name: idc-index-artifacts
path: release_artifacts/
- name: Authorize Google Cloud
uses: google-github-actions/auth@v3
with:
credentials_json: "${{ secrets.GCS_SERVICE_ACCOUNT_KEY }}"
- name: Upload artifacts to GCS bucket
uses: google-github-actions/upload-cloud-storage@v3
with:
path: release_artifacts
destination:
idc-index-data-artifacts/${{ github.event.release.tag_name }}
- name: Update current/ folder with latest release
run: |
gcloud storage rm -r gs://idc-index-data-artifacts/current/ || true
gcloud storage cp -r \
gs://idc-index-data-artifacts/${{ github.event.release.tag_name }}/* \
gs://idc-index-data-artifacts/current/
- name: Ensure bucket is publicly readable
run: |
gcloud storage buckets add-iam-policy-binding gs://idc-index-data-artifacts \
--member=allUsers --role=roles/storage.objectViewer
- name: Ensure CORS policy is set
run: |
cat > /tmp/cors.json << 'CORS'
[
{
"origin": [
"https://localhost.gdc.cancer.gov:3010",
"https://portal.gdc.cancer.gov"
],
"method": ["GET", "HEAD"],
"responseHeader": ["Content-Type", "Content-Length", "Content-Range"],
"maxAgeSeconds": 3600
}
]
CORS
gcloud storage buckets update gs://idc-index-data-artifacts --cors-file=/tmp/cors.json
publish:
needs: [dist]
name: Publish to PyPI
environment: pypi
permissions:
id-token: write
runs-on: ubuntu-latest
if: github.event_name == 'release' && github.event.action == 'published'
steps:
- uses: actions/download-artifact@v8
with:
name: Packages
path: dist
- uses: pypa/gh-action-pypi-publish@release/v1