Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
pandyamarut authored Jul 29, 2024
0 parents commit 30a405b
Show file tree
Hide file tree
Showing 12 changed files with 596 additions and 0 deletions.
23 changes: 23 additions & 0 deletions .github/tests.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
[
{
"hardwareConfig": {
"endpointConfig": {
"gpuIds": "ADA_24,AMPERE_16,AMPERE_24,AMPERE_48,AMPERE_80"
}
},
"input": {
"name": "Dolly"
},
"expectedOutput": "Hello, Dolly!"
},
{
"hardwareConfig": {
"endpointConfig": {
"gpuIds": "ADA_24,AMPERE_16,AMPERE_24,AMPERE_48,AMPERE_80"
}
},
"input": {
"name": "DALL-E"
}
}
]
50 changes: 50 additions & 0 deletions .github/workflows/CI-runpod_dep.yml
Original file line number Diff line number Diff line change
@@ -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
44 changes: 44 additions & 0 deletions .github/workflows/CI-test_e2e.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
name: CD | Test End-to-End

on:
push:
branches-ignore:
- "refs/tags/*"

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: Determine Docker tag
id: docker-tag
run: |
if [[ "${{ github.ref }}" == "refs/heads/main" ]]; then
echo "DOCKER_TAG=dev" >> $GITHUB_ENV
else
echo "DOCKER_TAG=${{ github.sha }}" >> $GITHUB_ENV
fi
- name: Build and push
uses: docker/build-push-action@v4
with:
push: true
tags: ${{ vars.DOCKERHUB_REPO }}/${{ vars.DOCKERHUB_IMG }}:${{ env.DOCKER_TAG }}
73 changes: 73 additions & 0 deletions .github/workflows/CI-test_handler.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
name: CI | Test Handler

on:
push:
branches:
- main

pull_request:
branches:
- main

workflow_dispatch:

jobs:
launch_runner_worker:
runs-on: ubuntu-latest

outputs:
id: ${{ steps.extract_id.outputs.runpod_job_id }}

steps:
- name: Deploy Worker
uses: fjogeleit/http-request-action@v1
id: deploy
with:
url: "https://api.runpod.ai/v2/${{ vars.RUNNER_24GB }}/run"
method: "POST"
customHeaders: '{"Content-Type": "application/json"}'
bearerToken: ${{ secrets.RUNPOD_API_KEY }}
data: '{"input":{"github_pat": "${{ secrets.GH_PAT }}", "github_org":"${{ vars.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: launch_runner_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
env:
PIP_ROOT_USER_ACTION: "ignore"
run: |
python -m pip install --upgrade pip
pip install -r builder/requirements.txt
- name: Execute Tests
run: |
python src/handler.py --test_input='{"input": {"key": "value"}}'
cleanup:
if: ${{ always() && !success() }}
needs: launch_runner_worker
runs-on: ubuntu-latest

steps:
- name: Terminate and Shutdown Worker
uses: fjogeleit/http-request-action@v1
with:
url: "https://api.runpod.ai/v2/${{ vars.RUNNER_24GB }}/cancel/${{ needs.launch_runner_worker.outputs.id }}"
method: "POST"
customHeaders: '{"Content-Type": "application/json"}'
bearerToken: ${{ secrets.RUNPOD_API_KEY }}
72 changes: 72 additions & 0 deletions .github/workflows/build-test-release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
name: CD | Build-Test-Release

on:
push:
branches:
- "main"
release:
types: [published]
workflow_dispatch:
inputs:
image_tag:
description: "Docker Image Tag"
required: false
default: "dev"

jobs:
docker-build:
runs-on: DO
# DO is a custom runner deployed on DigitalOcean, only available for workflows under the runpod-workers organization.
# If you would like to use this workflow, you can replace DO with ubuntu-latest or any other runner.

steps:
- 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 }}

# Build and push step
- name: Build and push
uses: docker/build-push-action@v4
with:
push: true
tags: ${{ vars.DOCKERHUB_REPO }}/${{ vars.DOCKERHUB_IMG }}:${{ (github.event_name == 'release' && github.event.release.tag_name) || (github.event_name == 'workflow_dispatch' && github.event.inputs.image_tag) || 'dev' }}

dev-test:
needs: docker-build
runs-on: ubuntu-latest

steps:
# Checkout
- uses: actions/checkout@v4

# Tests
- name: Run Tests
if: github.event_name != 'release'
id: run-tests
uses: direlines/[email protected]
with:
image-tag: ${{ vars.DOCKERHUB_REPO }}/${{ vars.DOCKERHUB_IMG }}:${{ (github.event_name == 'release' && github.event.release.tag_name) || (github.event_name == 'workflow_dispatch' && github.event.inputs.image_tag) || 'dev' }}
runpod-api-key: ${{ secrets.RUNPOD_API_KEY }}
request-timeout: 600

# Pass/Fail
- name: Verify Tests
env:
TOTAL_TESTS: ${{ steps.run-tests.outputs.total-tests }}
SUCCESSFUL_TESTS: ${{ steps.run-tests.outputs.succeeded }}
RESULTS: ${{ steps.run-tests.outputs.results }}
run: |
echo "Total tests: $TOTAL_TESTS"
echo "Successful tests: $SUCCESSFUL_TESTS"
echo "Full results: $RESULTS"
if [ "$TOTAL_TESTS" != "$SUCCESSFUL_TESTS" ]; then
exit 1
fi
Loading

0 comments on commit 30a405b

Please sign in to comment.