-
Notifications
You must be signed in to change notification settings - Fork 0
220 lines (185 loc) · 6.57 KB
/
run.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
# On every push this script is executed
on:
workflow_dispatch:
schedule:
- cron: "0 3 * * *"
concurrency: data
name: Build data
jobs:
generate-matrix:
runs-on: ubuntu-latest
env:
UV_CACHE_DIR: /tmp/.uv-cache
steps:
- name: checkout
uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: '3.11'
cache: pip
- name: Set up uv
# Install latest uv version using the installer
run: curl -LsSf https://astral.sh/uv/install.sh | sh
- name: Restore uv cache
uses: actions/cache@v4
with:
path: /tmp/.uv-cache
key: uv-${{ runner.os }}-${{ hashFiles('uv.lock') }}
restore-keys: |
uv-${{ runner.os }}-${{ hashFiles('uv.lock') }}
uv-${{ runner.os }}
- name: Generate token
id: generate_token
uses: pypi-data/github-app-token@v1
with:
app_id: ${{ secrets.APP_ID }}
private_key: ${{ secrets.APP_PRIVATE_KEY }}
- name: Install deps
run: uv sync --frozen
- env:
GITHUB_TOKEN: ${{ steps.generate_token.outputs.token }}
run: |
uv run pypi-data print-git-urls > links/repositories.txt
uv run pypi-data print-git-urls --ssh-urls > links/repositories_ssh.txt
- uses: EndBug/add-and-commit@v9
with:
add: |
links/repositories.txt
links/repositories_ssh.txt
author_email: "41898282+github-actions[bot]@users.noreply.github.com"
author_name: "commit-bot"
message: "Add repository URLs"
push: true
fetch: true
pull: '--rebase --autostash'
- env:
GITHUB_TOKEN: ${{ steps.generate_token.outputs.token }}
id: groups
run: |
mkdir output/
uv run pypi-data group-index-urls output/
echo "matrix=$(cat output/groups.json)" >> "$GITHUB_OUTPUT"
- uses: actions/upload-artifact@v4
with:
name: groups
path: output/groups/
retention-days: 1
- name: "Set current date as env variable"
run: |
echo "tag_name=$(date +'%Y-%m-%d-%H-%M')" >> $GITHUB_OUTPUT
id: version
- name: Create Release
id: create-release
uses: shogo82148/actions-create-release@v1
with:
draft: true
release_name: ${{ steps.version.outputs.tag_name }}
tag_name: ${{ steps.version.outputs.tag_name }}
commitish: ${{ github.sha }}
- name: Release URL
run: echo ${{ steps.create-release.html_url }}
- name: Minimize uv cache
run: uv cache prune --ci
outputs:
matrix: ${{ steps.groups.outputs.matrix }}
upload_url: ${{ steps.create-release.outputs.upload_url }}
release_id: ${{ steps.create-release.outputs.id }}
combine:
needs: [generate-matrix]
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
index: ${{fromJson(needs.generate-matrix.outputs.matrix)}}
steps:
- name: Maximize build space
uses: easimon/maximize-build-space@master
with:
remove-dotnet: 'true'
remove-android: 'true'
remove-haskell: 'true'
remove-codeql: 'true'
remove-docker-images: 'true'
- name: checkout
uses: actions/checkout@v4
- uses: actions/download-artifact@v4
with:
name: groups
- uses: actions-rust-lang/setup-rust-toolchain@v1
with:
cache-on-failure: 'false'
- name: Install parquet cli from crates.io
uses: baptiste0928/cargo-install@v3
with:
crate: parquet
features: cli
- name: Download links
run: cat ${{ matrix.index }} | jq -rc '.[]'
- name: Debug
run: |
echo "Links for ${{ matrix.index }}"
cat ${{ matrix.index }} | jq -rc '.[] | [.name, .id] | @tsv'
- name: Download
run: |
mkdir input/
cat ${{ matrix.index }} | jq -rc '.[] | [.name, .id] | @tsv' | parallel --colsep '\t' wget --tries=2 -nv -O input/{2}.parquet {1}
- run: ls -la ${{ github.workspace }}/input/
- name: Combine
run: parquet-concat ${{ github.workspace }}/merged.parquet ${{ github.workspace }}/input/*.parquet
- name: Merged size
run: du -hs ${{ github.workspace }}/merged.parquet
- name: Rewrite
run: |
parquet-rewrite \
--compression=zstd \
--writer-version=2.0 \
--dictionary-enabled=true \
--statistics-enabled=page \
--bloom-filter-enabled=true \
--bloom-filter-fpp 0.2 \
--input=${{ github.workspace }}/merged.parquet \
--output=${{ github.workspace }}/output.parquet
- name: Output size
run: du -hs ${{ github.workspace }}/output.parquet
- name: Upload Assets
uses: shogo82148/actions-upload-release-asset@v1
with:
upload_url: ${{ needs.generate-matrix.outputs.upload_url }}
asset_path: ${{ github.workspace }}/output.parquet
asset_name: index-${{ matrix.index }}.parquet
makepublic:
needs: [generate-matrix, combine]
runs-on: ubuntu-latest
steps:
- name: checkout
uses: actions/checkout@v4
- name: Publish release
uses: StuYarrow/[email protected]
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
id: ${{ needs.generate-matrix.outputs.release_id }}
- name: Get download links
id: get_download_links
uses: actions/github-script@v7
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
const response = await github.rest.repos.listReleaseAssets({
owner: context.repo.owner,
repo: context.repo.repo,
release_id: ${{ needs.generate-matrix.outputs.release_id }},
});
const assets = response.data;
// Save the download links to a file
require('fs').writeFileSync('links/dataset.txt', assets.map(asset => asset.browser_download_url).join('\n'));
- run: cat links/dataset.txt
- uses: EndBug/add-and-commit@v9
with:
add: 'links/dataset.txt'
author_email: "41898282+github-actions[bot]@users.noreply.github.com"
author_name: "commit-bot"
message: "Add download links for asset ${{ needs.generate-matrix.outputs.release_id }}"
push: true
fetch: true
pull: '--rebase --autostash'