-
Notifications
You must be signed in to change notification settings - Fork 804
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[CICD] github workflow to push nightly package to testpypi #734
Changes from all commits
bc27343
074d856
665c088
efb14c1
94d619b
87e2cb8
e855291
c7becda
a6e1740
8ffdff1
8640a30
10b1360
3ce9601
6c3b9fa
a45ce85
b8df87b
45cf46e
20dc186
8527b79
6202503
16af87c
7ca2f5e
ccd3ec1
1988713
2644e09
df55ec6
0b0446f
d8c9798
63232d7
cca2781
dc74675
4387863
5f051b2
2847d70
1ea4666
97d31d7
7cdd8b9
650016f
7e57441
cbc2886
c02b706
dc9148b
697df3e
d9f14e2
0f7016a
de3161f
3df88b8
cf673be
74babf8
f9c309d
5f04869
58ed2d2
74c6c9e
0086734
5b8b809
8366230
00fa4ca
6aaab0d
9baedf6
07bbfad
285d8e1
99c7352
040c643
ee80853
27be071
bef7e5b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,219 @@ | ||
name: Publish Python 🐍 distribution 📦 to TestPyPI | ||
|
||
on: | ||
workflow_dispatch: # Keep manual trigger | ||
inputs: | ||
version: | ||
description: 'Version number (e.g. 0.0.63.dev20250111)' | ||
required: true | ||
type: string | ||
schedule: | ||
- cron: "0 0 * * *" # Run every day at midnight | ||
|
||
jobs: | ||
trigger-client-and-models-build: | ||
name: Trigger llama-stack-client and llama-models build | ||
runs-on: ubuntu-latest | ||
outputs: | ||
version: ${{ steps.version.outputs.version }} | ||
client_run_id: ${{ steps.trigger-client.outputs.workflow_id }} | ||
model_run_id: ${{ steps.trigger-models.outputs.workflow_id }} | ||
steps: | ||
- uses: actions/checkout@v4 | ||
with: | ||
persist-credentials: false | ||
- name: Get date | ||
id: date | ||
run: echo "date=$(date +'%Y%m%d')" >> $GITHUB_OUTPUT | ||
- name: Compute version based on dispatch event | ||
id: version | ||
run: | | ||
# Read base version from pyproject.toml | ||
version=$(sed -n 's/.*version="\([^"]*\)".*/\1/p' setup.py) | ||
if [ "${{ github.event_name }}" = "schedule" ]; then | ||
echo "version=${version}.dev${{ steps.date.outputs.date }}" >> $GITHUB_OUTPUT | ||
elif [ "${{ github.event_name }}" = "workflow_dispatch" ]; then | ||
echo "version=${{ inputs.version }}" >> $GITHUB_OUTPUT | ||
else | ||
echo "version=${version}.dev$(shuf -i 10000000-99999999 -n 1)" >> $GITHUB_OUTPUT | ||
fi | ||
- name: Trigger llama-stack-client workflow | ||
id: trigger-client | ||
run: | | ||
response=$(curl -X POST https://api.github.com/repos/meta-llama/llama-stack-client-python/dispatches \ | ||
-H 'Accept: application/vnd.github.everest-preview+json' \ | ||
-H "authorization: Bearer ${{ secrets.PAT_TOKEN }}" \ | ||
--data "{\"event_type\": \"build-client-package\", \"client_payload\": {\"source\": \"llama-stack-nightly\", \"version\": \"${{ steps.version.outputs.version }}\"}}" \ | ||
-w "\n%{http_code}") | ||
|
||
http_code=$(echo "$response" | tail -n1) | ||
if [ "$http_code" != "204" ]; then | ||
echo "Failed to trigger client workflow" | ||
exit 1 | ||
fi | ||
|
||
# Get the run ID of the triggered workflow | ||
sleep 5 # Wait for workflow to be created | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. is the number "5" recommended? curious. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Could probably add a while loop here as well to wait for workflow to be created, like this action (e.g. https://github.com/convictional/trigger-workflow-and-wait/blob/f69fa9eedd3c62a599220f4d5745230e237904be/entrypoint.sh#L137-L142) |
||
run_id=$(curl -s -H "authorization: Bearer ${{ secrets.PAT_TOKEN }}" \ | ||
"https://api.github.com/repos/meta-llama/llama-stack-client-python/actions/runs?event=repository_dispatch" \ | ||
| jq '.workflow_runs[0].id') | ||
echo "workflow_id=$run_id" >> $GITHUB_OUTPUT | ||
|
||
- name: Trigger llama-models workflow | ||
id: trigger-models | ||
run: | | ||
response=$(curl -X POST https://api.github.com/repos/meta-llama/llama-models/dispatches \ | ||
-H 'Accept: application/vnd.github.everest-preview+json' \ | ||
-H "authorization: Bearer ${{ secrets.PAT_TOKEN }}" \ | ||
--data "{\"event_type\": \"build-models-package\", \"client_payload\": {\"source\": \"llama-stack-nightly\", \"version\": \"${{ steps.version.outputs.version }}\"}}" \ | ||
-w "\n%{http_code}") | ||
|
||
http_code=$(echo "$response" | tail -n1) | ||
if [ "$http_code" != "204" ]; then | ||
echo "Failed to trigger models workflow" | ||
exit 1 | ||
fi | ||
|
||
# Get the run ID of the triggered workflow | ||
sleep 5 # Wait for workflow to be created | ||
run_id=$(curl -s -H "authorization: Bearer ${{ secrets.PAT_TOKEN }}" \ | ||
"https://api.github.com/repos/meta-llama/llama-models/actions/runs?event=repository_dispatch" \ | ||
| jq '.workflow_runs[0].id') | ||
echo "workflow_id=$run_id" >> $GITHUB_OUTPUT | ||
|
||
wait-for-workflows: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. might be able to replace with this action: https://github.com/marketplace/actions/trigger-workflow-and-wait , but keeping it raw and explicit for now. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @yanxi0830 yeah I read about some stuff; sounds good to me |
||
name: Wait for triggered workflows | ||
needs: trigger-client-and-models-build | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Wait for client workflow | ||
run: | | ||
while true; do | ||
status=$(curl -s -H "authorization: Bearer ${{ secrets.PAT_TOKEN }}" \ | ||
"https://api.github.com/repos/meta-llama/llama-stack-client-python/actions/runs/${{ needs.trigger-client-and-models-build.outputs.client_run_id }}" \ | ||
| jq -r '.status') | ||
conclusion=$(curl -s -H "authorization: Bearer ${{ secrets.PAT_TOKEN }}" \ | ||
"https://api.github.com/repos/meta-llama/llama-stack-client-python/actions/runs/${{ needs.trigger-client-and-models-build.outputs.client_run_id }}" \ | ||
| jq -r '.conclusion') | ||
|
||
echo "llama-stack-client-python workflow status: $status, conclusion: $conclusion" | ||
|
||
if [ "$status" = "completed" ]; then | ||
if [ "$conclusion" != "success" ]; then | ||
echo "llama-stack-client-python workflow failed" | ||
exit 1 | ||
fi | ||
break | ||
fi | ||
|
||
sleep 10 | ||
done | ||
|
||
- name: Wait for models workflow | ||
run: | | ||
while true; do | ||
status=$(curl -s -H "authorization: Bearer ${{ secrets.PAT_TOKEN }}" \ | ||
"https://api.github.com/repos/meta-llama/llama-models/actions/runs/${{ needs.trigger-client-and-models-build.outputs.model_run_id }}" \ | ||
| jq -r '.status') | ||
conclusion=$(curl -s -H "authorization: Bearer ${{ secrets.PAT_TOKEN }}" \ | ||
"https://api.github.com/repos/meta-llama/llama-models/actions/runs/${{ needs.trigger-client-and-models-build.outputs.model_run_id }}" \ | ||
| jq -r '.conclusion') | ||
|
||
echo "llama-models workflow status: $status, conclusion: $conclusion" | ||
|
||
if [ "$status" = "completed" ]; then | ||
if [ "$conclusion" != "success" ]; then | ||
echo "llama-models workflow failed" | ||
exit 1 | ||
fi | ||
break | ||
fi | ||
|
||
sleep 10 | ||
done | ||
|
||
build: | ||
name: Build distribution 📦 | ||
needs: | ||
- wait-for-workflows | ||
- trigger-client-and-models-build | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- uses: actions/checkout@v4 | ||
with: | ||
persist-credentials: false | ||
- name: Get date | ||
id: date | ||
run: echo "date=$(date +'%Y%m%d')" >> $GITHUB_OUTPUT | ||
- name: Update version for nightly | ||
run: | | ||
sed -i 's/version="\([^"]*\)"/version="${{ needs.trigger-client-and-models-build.outputs.version }}"/' setup.py | ||
sed -i 's/llama-stack-client>=\([^"]*\)/llama-stack-client==${{ needs.trigger-client-and-models-build.outputs.version }}/' requirements.txt | ||
sed -i 's/llama-models>=\([^"]*\)/llama-models==${{ needs.trigger-client-and-models-build.outputs.version }}/' requirements.txt | ||
- name: Set up Python | ||
uses: actions/setup-python@v5 | ||
with: | ||
python-version: "3.11" | ||
- name: Install pypa/build | ||
run: >- | ||
python3 -m | ||
pip install | ||
build | ||
--user | ||
- name: Build a binary wheel and a source tarball | ||
run: python3 -m build | ||
yanxi0830 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
- name: Store the distribution packages | ||
uses: actions/upload-artifact@v4 | ||
with: | ||
name: python-package-distributions | ||
path: dist/ | ||
|
||
publish-to-testpypi: | ||
name: Publish Python 🐍 distribution 📦 to TestPyPI | ||
needs: | ||
- build | ||
runs-on: ubuntu-latest | ||
|
||
environment: | ||
name: testrelease | ||
url: https://test.pypi.org/p/llama-stack | ||
|
||
permissions: | ||
id-token: write # IMPORTANT: mandatory for trusted publishing | ||
|
||
steps: | ||
- name: Download all the dists | ||
uses: actions/download-artifact@v4 | ||
with: | ||
name: python-package-distributions | ||
path: dist/ | ||
- name: Publish distribution 📦 to TestPyPI | ||
uses: pypa/gh-action-pypi-publish@release/v1 | ||
with: | ||
repository-url: https://test.pypi.org/legacy/ | ||
|
||
test-published-package: | ||
name: Test published package | ||
needs: | ||
- publish-to-testpypi | ||
- trigger-client-and-models-build | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Install the package | ||
run: | | ||
sleep 10 | ||
pip install --index-url https://pypi.org/simple/ --extra-index-url https://test.pypi.org/simple/ llama-stack==${{ needs.trigger-client-and-models-build.outputs.version }} | ||
- name: Test the package versions | ||
run: | | ||
pip list | grep llama_ | ||
- name: Test CLI commands | ||
run: | | ||
llama model list | ||
llama stack build --list-templates | ||
llama model prompt-format -m Llama3.2-11B-Vision-Instruct | ||
llama stack list-apis | ||
llama stack list-providers inference | ||
llama stack list-providers telemetry | ||
|
||
# TODO: add trigger for integration test workflow & docker builds | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. cc @sixianyi0721 we can add a step to trigger integration test flow here using the built package |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this case happens when you run the workflow adhoc by pressing a button from the UI, for example?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, this case only happens with testing (e.g. on push). If you press the button, you will need to enter the version: