96 lines
2.8 KiB
YAML
96 lines
2.8 KiB
YAML
name: Update Tinygrad
|
|
|
|
on:
|
|
workflow_dispatch:
|
|
inputs:
|
|
runner:
|
|
description: "Select runner"
|
|
type: choice
|
|
options:
|
|
- c3
|
|
- c3x
|
|
default: "c3"
|
|
required: true
|
|
|
|
env:
|
|
GIT_EMAIL: "91348155+FrogAi@users.noreply.github.com"
|
|
GIT_NAME: "James"
|
|
GITLAB_REPO_DIR: "StarPilot-Resources"
|
|
GITLAB_URL: "gitlab.com/FrogAi/StarPilot-Resources.git"
|
|
OPENPILOT_DIR: "/data/openpilot"
|
|
|
|
jobs:
|
|
update_tinygrad:
|
|
runs-on: [self-hosted, "${{ inputs.runner }}"]
|
|
steps:
|
|
- name: Get Version
|
|
id: get_version
|
|
run: |
|
|
VERSION=$(grep -oP '^VERSION\s*=\s*"\K[^"]+' "$OPENPILOT_DIR/starpilot/assets/model_manager.py")
|
|
echo "VERSION=$VERSION"
|
|
echo "version=$VERSION" >> "$GITHUB_OUTPUT"
|
|
|
|
- name: Setup Workspace and Clone GitLab
|
|
id: setup
|
|
env:
|
|
GITLAB_TOKEN: ${{ secrets.GITLAB_TOKEN }}
|
|
run: |
|
|
WORK_DIR="$RUNNER_TEMP/starpilot_tinygrad"
|
|
rm -rf "$WORK_DIR" && mkdir -p "$WORK_DIR"
|
|
echo "work_dir=$WORK_DIR" >> "$GITHUB_OUTPUT"
|
|
|
|
cd "$WORK_DIR"
|
|
git clone --depth 1 --branch Tinygrad "https://oauth2:${GITLAB_TOKEN}@$GITLAB_URL"
|
|
|
|
- name: Create Tinygrad Archive
|
|
working-directory: ${{ env.OPENPILOT_DIR }}
|
|
env:
|
|
WORK_DIR: ${{ steps.setup.outputs.work_dir }}
|
|
VERSION: ${{ steps.get_version.outputs.version }}
|
|
run: |
|
|
set -euo pipefail
|
|
|
|
ARCHIVE_DEST="$WORK_DIR/$GITLAB_REPO_DIR"
|
|
ARCHIVE_NAME="Tinygrad_$VERSION.tar.gz"
|
|
|
|
DUMMY_DIR=$(mktemp -d)
|
|
touch "$DUMMY_DIR/SConscript"
|
|
|
|
tar -czf "$ARCHIVE_DEST/$ARCHIVE_NAME" \
|
|
--exclude="*.a" \
|
|
--exclude="*.o" \
|
|
--exclude="*.onnx" \
|
|
--exclude="*__pycache__*" \
|
|
--exclude="*tests*" \
|
|
--exclude="selfdrive/modeld/SConscript" \
|
|
selfdrive/modeld tinygrad_repo \
|
|
-C "$DUMMY_DIR" \
|
|
--transform 's|^SConscript$|selfdrive/modeld/SConscript|' \
|
|
SConscript
|
|
|
|
rm -rf "$DUMMY_DIR"
|
|
|
|
- name: Push Updated Tinygrad
|
|
working-directory: ${{ steps.setup.outputs.work_dir }}/${{ env.GITLAB_REPO_DIR }}
|
|
env:
|
|
VERSION: ${{ steps.get_version.outputs.version }}
|
|
run: |
|
|
git config user.name "$GIT_NAME"
|
|
git config user.email "$GIT_EMAIL"
|
|
|
|
git add Tinygrad_*.tar.gz
|
|
|
|
if git diff --staged --quiet; then
|
|
echo "No changes to commit."
|
|
else
|
|
git commit -m "Updated Tinygrad: $VERSION"
|
|
git push origin Tinygrad
|
|
fi
|
|
|
|
- name: Cleanup Temporary Files
|
|
if: always()
|
|
env:
|
|
WORK_DIR: ${{ steps.setup.outputs.work_dir }}
|
|
run: |
|
|
rm -rf "$WORK_DIR"
|