Skip to content
This repository has been archived by the owner on Dec 6, 2023. It is now read-only.

Merge pull request #93 from casperdcl/labels #264

Merge pull request #93 from casperdcl/labels

Merge pull request #93 from casperdcl/labels #264

Workflow file for this run

name: CI
on:
push: {branches: [main]}
pull_request_target:
jobs:
setup:
environment: ${{ github.event_name == 'pull_request_target' && !contains('OWNER,MEMBER,COLLABORATOR', github.event.pull_request.author_association) && 'external' || 'internal' }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
ref: ${{ github.event.pull_request.head.sha || github.ref }}
- id: list
name: List modified models
run: |
git diff --stat HEAD~1
echo "modified=$(
for model in $(ls -d *-*); do
git diff --quiet HEAD~1 -- $model || echo $model
done | sort | jq -Rsc 'split("\n")[:-1]'
)" >> $GITHUB_OUTPUT
- name: Launch self-hosted runners
if: steps.list.outputs.modified != '[]'
run: |
curl -sSL -X POST -H "X-Api-Key: $API_KEY" https://api.paperspace.io/machines/$MACHINE/start
while test $(curl -fsSL -X GET -H "X-Api-Key: $API_KEY" https://api.paperspace.io/machines/getMachinePublic?machineId=$MACHINE | jq -r .state) != ready; do
sleep 5
done
IP=$(curl -fsSL -X GET -H "X-Api-Key: $API_KEY" https://api.paperspace.io/machines/getMachinePublic?machineId=$MACHINE | jq -r .publicIpAddress)
echo "$SSH_KEY" > key; chmod 600 key
ssh -o "StrictHostKeyChecking no" -i key paperspace@$IP 'touch "gha-run-${{ github.run_id }}.lock"'
env:
SSH_KEY: ${{ secrets.PAPERSPACE_SSH_KEY }}
API_KEY: ${{ secrets.PAPERSPACE_API_KEY }}
MACHINE: ${{ secrets.PAPERSPACE_MACHINE }}
outputs:
models: ${{ steps.list.outputs.modified }}
build-test-push:
concurrency: # terminate on new commits to PRs
group: ${{ github.workflow }}-${{ github.head_ref || github.ref }}
cancel-in-progress: true
needs: setup
runs-on: [self-hosted, gpu]
strategy:
fail-fast: false
matrix:
model: ${{ fromJson(needs.setup.outputs.models) }}
# if nothing to do, skip without failing
if: needs.setup.outputs.models != '[]'
env:
VERSION: '1.0.0'
DOCKER_BUILDKIT: 1
DOCKER_CLI_EXPERIMENTAL: enabled
COMPOSE_DOCKER_CLI_BUILD: 1
permissions:
packages: write
steps:
- uses: actions/checkout@v3
- name: Login to GitHub Container Registry
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ github.token }}
- run: ./build.sh ${{ github.event_name == 'push' && '--push' || '--load' }}
working-directory: ${{ matrix.model }}
env:
# can't load cross-CPU-platform
BUILDX_PLATFORM: ${{ github.event_name == 'push' && 'linux/arm64,linux/amd64' || 'linux/amd64' }}
# can't test cross-CPU-platform
TESTS_SKIP_CPU: ${{ github.event_name == 'push' && '1' || '' }}
# avoid OoM errors (TODO: remove when using larger GPU)
TESTS_SKIP_GPU: ${{ contains(fromJSON('["a2t-whisper","cht-dolly-v2","cht-gorilla","cht-llama-v2","cht-mpt","cht-xgen","dfs-dalle","dfs-diffusers"]'), matrix.model) && '1' || '' }}
pass: # convenient single job to apply branch protection to
needs: build-test-push
runs-on: ubuntu-latest
steps:
- run: echo success
teardown:
environment: ${{ github.event_name == 'pull_request_target' && !contains('OWNER,MEMBER,COLLABORATOR', github.event.pull_request.author_association) && 'external' || 'internal' }}
needs: build-test-push
if: always()
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Stop self-hosted runners
run: |
IP=$(curl -fsSL -X GET -H "X-Api-Key: $API_KEY" https://api.paperspace.io/machines/getMachinePublic?machineId=$MACHINE | jq -r .publicIpAddress)
echo "$SSH_KEY" > key; chmod 600 key
ssh -o "StrictHostKeyChecking no" -i key paperspace@$IP \
'rm -f "gha-run-${{ github.run_id }}.lock"; sleep 10; ls gha-run-*.lock' || \
curl -sSL -X POST -H "X-Api-Key: $API_KEY" https://api.paperspace.io/machines/$MACHINE/stop
env:
SSH_KEY: ${{ secrets.PAPERSPACE_SSH_KEY }}
API_KEY: ${{ secrets.PAPERSPACE_API_KEY }}
MACHINE: ${{ secrets.PAPERSPACE_MACHINE }}