ubuntu-tests #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: ubuntu Tests | |
on: | |
workflow_run: | |
workflows: ["macOS Tests"] | |
types: | |
- completed | |
jobs: | |
start-runner: | |
if: ${{ github.event.workflow_run.conclusion == 'success' }} # Trigger only if macOS tests succeed | |
name: Start self-hosted EC2 runner for GPU | |
runs-on: ubuntu-latest | |
outputs: | |
label: ${{ steps.start-ec2-runner.outputs.label }} | |
ec2-instance-id: ${{ steps.start-ec2-runner.outputs.ec2-instance-id }} | |
steps: | |
- name: Configure AWS credentials | |
uses: aws-actions/configure-aws-credentials@v1 | |
with: | |
aws-access-key-id: ${{ secrets.AWS_KEY_ID }} | |
aws-secret-access-key: ${{ secrets.AWS_KEY_SECRET }} | |
aws-region: ${{ vars.AWS_REGION }} | |
- name: Start EC2 runner | |
id: start-ec2-runner | |
uses: machulav/ec2-github-runner@v2 | |
with: | |
mode: start | |
github-token: ${{ secrets.GH_TOKEN }} | |
ec2-image-id: ${{ vars.AWS_IMAGE_ID }} | |
ec2-instance-type: ${{ vars.AWS_INSTANCE_TYPE }} | |
subnet-id: ${{ vars.AWS_SUBNET }} | |
security-group-id: ${{ vars.AWS_SECURITY_GROUP }} | |
do-the-job: | |
name: Run GPU Tests on the runner | |
needs: start-runner | |
runs-on: ${{ needs.start-runner.outputs.label }} | |
strategy: | |
matrix: | |
python-version: ['3.10', '3.11'] | |
env: | |
POETRY_CACHE_DIR: /dev/shm # TODO: make this as a github variable! | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
fetch-depth: 1 | |
- name: Set up Python ${{ matrix.python-version }} | |
uses: actions/setup-python@v5 | |
with: | |
python-version: ${{ matrix.python-version }} | |
- name: Echo python version | |
run: | | |
python --version | |
which python | |
- name: Check if Poetry is installed | |
id: check-poetry | |
run: | | |
if command -v poetry &> /dev/null; then | |
echo "::set-output name=poetry_installed::true" | |
else | |
echo "::set-output name=poetry_installed::false" | |
fi | |
- name: Install Poetry | |
if: steps.check-poetry.outputs.poetry_installed == 'false' | |
uses: snok/install-poetry@v1 | |
with: | |
poetry-version: latest | |
- name: Check space | |
run: | | |
echo "available space: " | |
df -h | |
- name: Check poetry version | |
run: | | |
poetry env info | |
poetry --version | |
- name: Install dependencies with Poetry | |
run: | | |
poetry env use ${{ matrix.python-version }} | |
poetry install | |
shell: bash | |
- name: Display NVIDIA SMI details | |
run: | | |
poetry run nvidia-smi | |
poetry run nvidia-smi -L | |
poetry run nvidia-smi -q -d Memory | |
- name: Run unit tests | |
run: poetry run pytest | |
shell: bash | |
- name: Delete poetry env with python {{ matrix.python-version }} | |
run: | | |
poetry env remove ${{ matrix.python-version }} | |
shell: bash | |
stop-runner: | |
name: Stop self-hosted EC2 runner | |
needs: | |
- start-runner # waits for the EC2 instance to be created | |
- do-the-job # waits for the actual job to finish | |
runs-on: ubuntu-latest | |
if: ${{ always() }} # required to stop the runner even if an error occurred in previous jobs | |
steps: | |
- name: Configure AWS credentials | |
uses: aws-actions/configure-aws-credentials@v1 | |
with: | |
aws-access-key-id: ${{ secrets.AWS_KEY_ID }} | |
aws-secret-access-key: ${{ secrets.AWS_KEY_SECRET }} | |
aws-region: ${{ vars.AWS_REGION }} | |
- name: Stop EC2 runner | |
uses: machulav/ec2-github-runner@v2 | |
with: | |
mode: stop | |
github-token: ${{ secrets.GH_TOKEN }} | |
label: ${{ needs.start-runner.outputs.label }} | |
ec2-instance-id: ${{ needs.start-runner.outputs.ec2-instance-id }} |