Skip to content

Commit d781303

Browse files
committed
changes
1 parent 21baacb commit d781303

2 files changed

Lines changed: 148 additions & 0 deletions

File tree

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
name: PR wheel preview build
2+
3+
on:
4+
pull_request:
5+
branches: [main]
6+
7+
concurrency:
8+
group: pr-wheel-build-${{ github.event.pull_request.number }}-${{ github.head_ref || github.run_id }}
9+
cancel-in-progress: true
10+
11+
permissions: {}
12+
13+
jobs:
14+
build:
15+
runs-on: ubuntu-latest
16+
permissions:
17+
contents: read
18+
pull-requests: read
19+
steps:
20+
- uses: actions/checkout@v4
21+
22+
- uses: actions/setup-python@v4
23+
with:
24+
python-version: "3.10"
25+
26+
- uses: actions/setup-node@v4
27+
with:
28+
node-version: "20"
29+
cache: npm
30+
cache-dependency-path: trackio/frontend/package-lock.json
31+
32+
- name: Build frontend
33+
run: |
34+
cd trackio/frontend
35+
npm ci
36+
npm run build
37+
38+
- name: Install build
39+
run: python -m pip install build
40+
41+
- name: Build wheel
42+
env:
43+
SKIP_FRONTEND_BUILD: "1"
44+
run: python -m build -w
45+
46+
- name: Write metadata
47+
run: |
48+
python3 << 'PY'
49+
import json
50+
from pathlib import Path
51+
52+
wheels = sorted(Path("dist").glob("trackio-*.whl"))
53+
if len(wheels) != 1:
54+
raise SystemExit(f"expected one trackio wheel, got {[p.name for p in wheels]}")
55+
meta = {
56+
"pr_number": ${{ github.event.pull_request.number }},
57+
"sha": "${{ github.event.pull_request.head.sha }}",
58+
"wheel_basename": wheels[0].name,
59+
}
60+
Path("output.json").write_text(json.dumps(meta))
61+
PY
62+
63+
- name: Upload wheel
64+
uses: actions/upload-artifact@v4
65+
with:
66+
name: trackio-wheel
67+
path: dist/*.whl
68+
69+
- name: Upload metadata
70+
uses: actions/upload-artifact@v4
71+
with:
72+
name: pr-wheel-preview-metadata
73+
path: output.json
Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
name: PR wheel preview deploy
2+
3+
on:
4+
workflow_run:
5+
workflows: ["PR wheel preview build"]
6+
types:
7+
- completed
8+
9+
concurrency:
10+
group: pr-wheel-deploy-${{ github.event.workflow_run.head_sha }}
11+
cancel-in-progress: true
12+
13+
jobs:
14+
deploy:
15+
if: github.event.workflow_run.conclusion == 'success' && github.event.workflow_run.event == 'pull_request'
16+
runs-on: ubuntu-latest
17+
permissions:
18+
actions: read
19+
outputs:
20+
pr_number: ${{ steps.meta.outputs.pr_number }}
21+
sha: ${{ steps.meta.outputs.sha }}
22+
wheel_basename: ${{ steps.meta.outputs.wheel_basename }}
23+
steps:
24+
- name: Download metadata
25+
uses: actions/download-artifact@v4
26+
with:
27+
name: pr-wheel-preview-metadata
28+
path: metadata
29+
github-token: ${{ secrets.GITHUB_TOKEN }}
30+
repository: ${{ github.repository }}
31+
run-id: ${{ github.event.workflow_run.id }}
32+
33+
- name: Download wheel
34+
uses: actions/download-artifact@v4
35+
with:
36+
name: trackio-wheel
37+
path: wheel
38+
github-token: ${{ secrets.GITHUB_TOKEN }}
39+
repository: ${{ github.repository }}
40+
run-id: ${{ github.event.workflow_run.id }}
41+
42+
- name: Parse metadata
43+
id: meta
44+
run: |
45+
echo "pr_number=$(jq -r .pr_number metadata/output.json)" >> $GITHUB_OUTPUT
46+
echo "sha=$(jq -r .sha metadata/output.json)" >> $GITHUB_OUTPUT
47+
echo "wheel_basename=$(jq -r .wheel_basename metadata/output.json)" >> $GITHUB_OUTPUT
48+
49+
- name: Install hf CLI
50+
run: curl -LsSf https://hf.co/cli/install.sh | bash
51+
52+
- name: Upload wheel to Hugging Face bucket
53+
env:
54+
HF_TOKEN: ${{ secrets.HF_PYPI_PREVIEWS_TOKEN }}
55+
run: |
56+
echo "$HOME/.local/bin" >> $GITHUB_PATH
57+
wheel_file=$(find wheel -maxdepth 1 -type f -name "*.whl" -print -quit)
58+
hf buckets cp "$wheel_file" "hf://buckets/trackio/trackio-wheels/${{ steps.meta.outputs.sha }}/"
59+
60+
comment:
61+
needs: deploy
62+
if: needs.deploy.result == 'success'
63+
uses: ./.github/workflows/comment-queue.yml
64+
secrets:
65+
gh_token: ${{ secrets.COMMENT_BOT_TOKEN }}
66+
with:
67+
pr_number: ${{ needs.deploy.outputs.pr_number }}
68+
tag: trackio-pr-wheel
69+
message: trackio-wheel~success~null
70+
additional_text: |
71+
**Install Trackio from this PR (includes built frontend)**
72+
73+
```bash
74+
pip install "https://huggingface.co/buckets/trackio/trackio-wheels/resolve/${{ needs.deploy.outputs.sha }}/${{ needs.deploy.outputs.wheel_basename }}"
75+
```

0 commit comments

Comments
 (0)