Initial commit

This commit is contained in:
Jorg Doku
2023-07-03 13:42:43 -05:00
committed by GitHub
commit 38829c2720
11 changed files with 476 additions and 0 deletions
+35
View File
@@ -0,0 +1,35 @@
name: CD | Dev Docker Image
on:
push:
branches:
- "main"
jobs:
docker:
runs-on: ubuntu-latest
steps:
- name: Clear Space
run: |
rm -rf /usr/share/dotnet
rm -rf /opt/ghc
rm -rf "/usr/local/share/boost"
rm -rf "$AGENT_TOOLSDIRECTORY"
- name: Set up QEMU
uses: docker/setup-qemu-action@v2
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Login to Docker Hub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Build and push
uses: docker/build-push-action@v4
with:
push: true
tags: ${{ vars.DOCKERHUB_REPO }}/${{ vars.DOCKERHUB_IMG }}:dev
+34
View File
@@ -0,0 +1,34 @@
name: CD | Release Docker Image
on:
release:
types: [published]
jobs:
docker:
runs-on: ubuntu-latest
steps:
- name: Clear Space
run: |
rm -rf /usr/share/dotnet
rm -rf /opt/ghc
rm -rf "/usr/local/share/boost"
rm -rf "$AGENT_TOOLSDIRECTORY"
- name: Set up QEMU
uses: docker/setup-qemu-action@v2
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Login to Docker Hub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Build and push
uses: docker/build-push-action@v4
with:
push: true
tags: ${{ secrets.DOCKERHUB_REPO }}/${{ secrets.DOCKERHUB_IMG }}:${{ github.event.release.tag_name }}
+50
View File
@@ -0,0 +1,50 @@
name: CI | Update runpod package version
on:
repository_dispatch:
types: [python-package-release]
push:
branches: ["main"]
workflow_dispatch:
jobs:
check_dep:
runs-on: ubuntu-latest
name: Check python requirements file and update
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Check for new package version and update
run: |
# Get current version
current_version=$(grep -oP 'runpod==\K[^"]+' ./builder/requirements.txt)
# Get new version
new_version=$(curl -s https://pypi.org/pypi/runpod/json | jq -r .info.version)
echo "NEW_VERSION_ENV=$new_version" >> $GITHUB_ENV
if [ -z "$new_version" ]; then
echo "Failed to fetch the new version."
exit 1
fi
# Check if the version is already up-to-date
if [ "$current_version" = "$new_version" ]; then
echo "The package version is already up-to-date."
exit 0
fi
# Update requirements.txt
sed -i "s/runpod==.*/runpod==$new_version/" ./builder/requirements.txt
- name: Create Pull Request
uses: peter-evans/create-pull-request@v3
with:
token: ${{ secrets.GITHUB_TOKEN }}
commit-message: Update package version
title: Update runpod package version
body: The package version has been updated to ${{ env.NEW_VERSION_ENV }}
branch: runpod-package-update
+70
View File
@@ -0,0 +1,70 @@
name: CI | Test Worker
on:
push:
branches:
- main
pull_request:
branches:
- main
workflow_dispatch:
jobs:
initialize_worker:
runs-on: ubuntu-latest
outputs:
id: ${{ steps.extract_id.outputs.runpod_job_id }}
steps:
- name: Deploy Worker
id: deploy
uses: fjogeleit/http-request-action@v1
with:
url: "https://api.runpod.ai/v2/${{ secrets.RUNPOD_ENDPOINT }}/run"
method: "POST"
customHeaders: '{"Content-Type": "application/json"}'
bearerToken: ${{ secrets.RUNPOD_API_KEY }}
data: '{"input":{"github_pat": "${{ secrets.GH_PAT }}", "github_org":"${{ secrets.GH_ORG }}"}}'
- name: Extract Job ID
id: extract_id
run: |
ID=$(echo '${{ steps.deploy.outputs.response }}' | jq -r '.id')
echo "::set-output name=runpod_job_id::$ID"
run_tests:
needs: initialize_worker
runs-on: runpod
steps:
- uses: actions/checkout@v3
- name: Set up Python 3.11 & install dependencies
uses: actions/setup-python@v4
with:
python-version: "3.11"
- name: Install Dependencies
run: |
python -m pip install --upgrade pip
pip install -r builder/requirements.txt
- name: Execute Tests
run: |
python src/handler.py --test_input='{"input": "test"}'
terminate_worker:
if: ${{ always() && !success() }}
needs: initialize_worker
runs-on: ubuntu-latest
steps:
- name: Shutdown Worker
uses: fjogeleit/http-request-action@v1
with:
url: "https://api.runpod.ai/v2/${{ secrets.RUNPOD_ENDPOINT }}/cancel/${{ needs.initialize_worker.outputs.id }}"
method: "POST"
customHeaders: '{"Content-Type": "application/json"}'
bearerToken: ${{ secrets.RUNPOD_API_KEY }}