Skip to content

CI | Test Worker

CI | Test Worker #16

name: CI | Test Worker
on:
push:
branches:
- main
workflow_dispatch:
jobs:
api_call:
runs-on: ubuntu-latest
outputs:
id: ${{ steps.get_id.outputs.id }}
steps:
- name: Send API Call
id: api_call
uses: fjogeleit/http-request-action@v1
with:
url: "https://api.runpod.ai/v2/ja1wwbebuah7t5/run"
method: "POST"
customHeaders: '{"Content-Type": "application/json"}'
bearerToken: ${{ secrets.RUNPOD_API_KEY }}
data: '{"input":{"start": true}}'
- name: Get ID
id: get_id
run: |
ID=$(echo '${{ steps.api_call.outputs.response }}' | jq -r '.id')
echo "::set-output name=runpod_job_id::$ID"
test:
needs: api_call
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"
- run: |
python -m pip install --upgrade pip
pip install -r builder/requirements.txt
- name: Test Worker
run: |
python src/handler.py --test_input='{"input": "test"}'
cleanup:
if: ${{ cancelled() }}
needs: api_call
runs-on: ubuntu-latest
steps:
- name: Cancel Worker
uses: fjogeleit/http-request-action@v1
with:
url: "https://api.runpod.ai/v2/ja1wwbebuah7t5/cancel/${{ needs.api_call.outputs.runpod_job_id }}"
method: "POST"
customHeaders: '{"Content-Type": "application/json"}'
bearerToken: ${{ secrets.RUNPOD_API_KEY }}