Update CI-test_handler.yml #5
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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: | | |
apt-get update -y | |
apt-get install git -y | |
python -m pip install --upgrade pip | |
pip install -r builder/requirements.txt | |
- name: Execute Tests | |
run: | | |
python src/handler.py --test_input='{ \ | |
"input": { \ | |
"dataset_url": "https://github.com/runpod-workers/sample-inputs/raw/main/images/runpod_dog2.zip", \ | |
"instance_prompt": "a photo of sks dog", \ | |
"batch_size": 32, \ | |
"training_steps": 1, \ | |
"local_directory": "./cat", \ | |
} \ | |
}' | |
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 }} |