From db15fb5c8ba2993816e2ecee81466e2b13e9035d Mon Sep 17 00:00:00 2001 From: fabiocat93 Date: Wed, 18 Sep 2024 08:42:16 +0200 Subject: [PATCH] matrix on the entire ubuntu-tests wf #3 --- ...buntu_tests.yaml => ubuntu_tests_310.yaml} | 11 +- .github/workflows/ubuntu_tests_311.yaml | 106 ++++++++++++++++++ 2 files changed, 111 insertions(+), 6 deletions(-) rename .github/workflows/{ubuntu_tests.yaml => ubuntu_tests_310.yaml} (94%) create mode 100644 .github/workflows/ubuntu_tests_311.yaml diff --git a/.github/workflows/ubuntu_tests.yaml b/.github/workflows/ubuntu_tests_310.yaml similarity index 94% rename from .github/workflows/ubuntu_tests.yaml rename to .github/workflows/ubuntu_tests_310.yaml index 20a6ce7..9a6554b 100644 --- a/.github/workflows/ubuntu_tests.yaml +++ b/.github/workflows/ubuntu_tests_310.yaml @@ -1,4 +1,4 @@ -name: ubuntu-tests +name: ubuntu-tests-python-3.10 on: workflow_run: @@ -6,15 +6,11 @@ on: types: - completed -# Define the matrix at the top level jobs: start-runner: if: ${{ github.event.workflow_run.conclusion == 'success' }} # Trigger only if macOS tests succeed name: start-runner runs-on: ubuntu-latest - strategy: - matrix: - python-version: ['3.10', '3.11'] # Define matrix at the top level outputs: label: ${{ steps.start-ec2-runner.outputs.label }} ec2-instance-id: ${{ steps.start-ec2-runner.outputs.ec2-instance-id }} @@ -40,6 +36,9 @@ jobs: name: ubuntu-tests needs: start-runner runs-on: ${{ needs.start-runner.outputs.label }} + strategy: + matrix: + python-version: ['3.10'] env: POETRY_CACHE_DIR: ${{ vars.POETRY_CACHE_DIR }} steps: @@ -79,7 +78,7 @@ jobs: - name: Run unit tests run: poetry run pytest shell: bash - - name: Delete poetry env with python ${{ matrix.python-version }} + - name: Delete poetry env with python {{ matrix.python-version }} run: | poetry env remove ${{ matrix.python-version }} shell: bash diff --git a/.github/workflows/ubuntu_tests_311.yaml b/.github/workflows/ubuntu_tests_311.yaml new file mode 100644 index 0000000..0a65f88 --- /dev/null +++ b/.github/workflows/ubuntu_tests_311.yaml @@ -0,0 +1,106 @@ +name: ubuntu-tests-python-3.11 + +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-runner + 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 }} + + ubuntu-tests: + name: ubuntu-tests + needs: start-runner + runs-on: ${{ needs.start-runner.outputs.label }} + strategy: + matrix: + python-version: ['3.11'] + env: + POETRY_CACHE_DIR: ${{ vars.POETRY_CACHE_DIR }} + 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: Install Poetry + uses: snok/install-poetry@v1 + with: + version: 1.7.1 + - name: Check space + run: | + echo "available space: " + df -h + - name: Install dependencies with Poetry + run: | + poetry env use ${{ matrix.python-version }} + poetry install --no-interaction --no-root + shell: bash + - name: Check poetry version + run: | + poetry env info + poetry --version + - 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-runner + needs: + - start-runner # waits for the EC2 instance to be created + - ubuntu-tests # 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 }}