Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added ability to run linux workflows on large runners #6273

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion .github/workflows/benchmarks.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
name: Benchmarks
on:
pull_request:
workflow_call:
inputs:
ref_branch:
Expand Down
49 changes: 49 additions & 0 deletions .github/workflows/determine-workflow-runner.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
name: Determine Workflow Runner group

on:
workflow_call:
inputs:
default_runner:
description: The runner type that is used by the calling workflow by default
required: true
type: string
outputs:
runner_group:
description: The runner all subsequent jobs within the calling workflow should run on
value: ${{ jobs.determine_workflow_runner.outputs.runner_group || inputs.default_runner }}

env:
LARGE_RUNNER_GROUP_NAME: pl-4-core-large-runner

jobs:
determine_workflow_runner:
runs-on: >-
${{
(
github.event_name == 'pull_request'
&& contains(github.event.pull_request.labels.*.name, 'urgent')
) && 'pl-4-core-large-runner' || 'ubuntu-latest'
}}

outputs:
runner_group: ${{ steps.runner_group.outputs.runner_group }}

steps:
- name: Output Runner Group name
if: >-
${{
github.event_name == 'pull_request'
&& startsWith(inputs.default_runner, 'ubuntu')
}}
id: runner_group
env:
# We are not able to use \d to check numeric values as bash does not allow them (not POSIX compliant)
RC_BRANCH_FORMAT_REGEX: v[0-9]+\.[0-9]+\.[0-9]+-rc[0-9]?
REPO_FULL_NAME: PennyLaneAI/pennylane
run: |
if [[ '${{ contains(github.event.pull_request.labels.*.name, 'urgent') }}' == 'true' || ('${{ github.event.pull_request.head.repo.full_name }}' == "$REPO_FULL_NAME" && '${{ github.event.pull_request.head.ref }}' =~ $RC_BRANCH_FORMAT_REGEX) ]]; then
echo "This job requires usage of the large runner group '$LARGE_RUNNER_GROUP_NAME'";
echo "runner_group=$LARGE_RUNNER_GROUP_NAME" >> $GITHUB_OUTPUT
else
echo "This job does not require usage of large runners ...";
fi
10 changes: 9 additions & 1 deletion .github/workflows/docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,19 @@ on:
- ready_for_review

jobs:
determine_runner:
if: github.event.pull_request.draft == false
name: Determine runner type to use
uses: ./.github/workflows/determine-workflow-runner.yml
with:
default_runner: ubuntu-latest

sphinx:
if: github.event.pull_request.draft == false
env:
DEPS_BRANCH: bot/stable-deps-update
runs-on: ubuntu-latest
needs: [determine_runner]
runs-on: ${{ needs.determine_runner.outputs.runner_group }}
steps:
- uses: actions/checkout@v3
- uses: PennyLaneAI/sphinx-action@master
Expand Down
19 changes: 13 additions & 6 deletions .github/workflows/format.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,24 @@ on:
- synchronize
- ready_for_review

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
determine_runner:
if: github.event.pull_request.draft == false
name: Determine runner type to use
uses: ./.github/workflows/determine-workflow-runner.yml
with:
default_runner: ubuntu-latest
Comment on lines +15 to +20
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure it make sense to potentially use the large runners for running black and pylint?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would you say we should exclude format/docs_check/upload to codecov from large runners?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Excluding upload-to-codecov and format makes sense to me. I think including docs has some merit, considering that it's actually very useful for new features or big refactors to verify that the sphinx build passes without issues.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The more I think about it, the more sense it makes to me to use the large runners for the actions above. If a PR is marked as urgent, we should treat all workflows as such.


black-pylint:
if: github.event.pull_request.draft == false
runs-on: ubuntu-latest
needs: [determine_runner]
runs-on: ${{ needs.determine_runner.outputs.runner_group }}

steps:
- name: Cancel Previous Runs
uses: styfle/[email protected]
with:
access_token: ${{ github.token }}

- name: Set up Python
uses: actions/setup-python@v2
with:
Expand Down
31 changes: 31 additions & 0 deletions .github/workflows/interface-unit-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,13 @@ on:
default: false

jobs:
determine_runner:
if: github.event.pull_request.draft == false
name: Determine runner type to use
uses: ./.github/workflows/determine-workflow-runner.yml
with:
default_runner: ubuntu-latest

setup-ci-load:
runs-on: ubuntu-latest

Expand Down Expand Up @@ -140,6 +147,7 @@ jobs:
torch-tests:
needs:
- setup-ci-load
- determine_runner
strategy:
max-parallel: >-
${{
Expand All @@ -156,6 +164,7 @@ jobs:
uses: ./.github/workflows/unit-test.yml
with:
job_name: torch-tests (${{ matrix.python-version }})
job_runner_name: ${{ needs.determine_runner.outputs.runner_group }}
branch: ${{ inputs.branch }}
coverage_artifact_name: core-interfaces-coverage-torch-${{ matrix.python-version }}
python_version: ${{ matrix.python-version }}
Expand All @@ -173,6 +182,7 @@ jobs:
autograd-tests:
needs:
- setup-ci-load
- determine_runner
strategy:
max-parallel: >-
${{
Expand All @@ -189,6 +199,7 @@ jobs:
uses: ./.github/workflows/unit-test.yml
with:
job_name: autograd-tests (${{ matrix.python-version }})
job_runner_name: ${{ needs.determine_runner.outputs.runner_group }}
branch: ${{ inputs.branch }}
coverage_artifact_name: core-interfaces-coverage-autograd-${{ matrix.python-version }}
python_version: ${{ matrix.python-version }}
Expand All @@ -205,6 +216,7 @@ jobs:
tf-tests:
needs:
- setup-ci-load
- determine_runner
strategy:
max-parallel: >-
${{
Expand All @@ -222,6 +234,7 @@ jobs:
uses: ./.github/workflows/unit-test.yml
with:
job_name: tf-tests (${{ matrix.group }}, ${{ matrix.python-version }})
job_runner_name: ${{ needs.determine_runner.outputs.runner_group }}
branch: ${{ inputs.branch }}
coverage_artifact_name: core-interfaces-coverage-tf-${{ matrix.python-version }}-${{ matrix.group }}
python_version: ${{ matrix.python-version }}
Expand All @@ -243,6 +256,7 @@ jobs:
jax-tests:
needs:
- setup-ci-load
- determine_runner
strategy:
max-parallel: >-
${{
Expand All @@ -260,6 +274,7 @@ jobs:
uses: ./.github/workflows/unit-test.yml
with:
job_name: jax-tests (${{ matrix.group }}, ${{ matrix.python-version }})
job_runner_name: ${{ needs.determine_runner.outputs.runner_group }}
branch: ${{ inputs.branch }}
coverage_artifact_name: core-interfaces-coverage-jax-${{ matrix.python-version }}-${{ matrix.group }}
python_version: ${{ matrix.python-version }}
Expand All @@ -281,6 +296,7 @@ jobs:
core-tests:
needs:
- setup-ci-load
- determine_runner
strategy:
max-parallel: >-
${{
Expand All @@ -298,6 +314,7 @@ jobs:
uses: ./.github/workflows/unit-test.yml
with:
job_name: core-tests (${{ matrix.group }}, ${{ matrix.python-version }})
job_runner_name: ${{ needs.determine_runner.outputs.runner_group }}
branch: ${{ inputs.branch }}
coverage_artifact_name: core-interfaces-coverage-core-${{ matrix.python-version }}-${{ matrix.group }}
python_version: ${{ matrix.python-version }}
Expand All @@ -319,6 +336,7 @@ jobs:
all-interfaces-tests:
needs:
- setup-ci-load
- determine_runner
strategy:
max-parallel: >-
${{
Expand All @@ -335,6 +353,7 @@ jobs:
uses: ./.github/workflows/unit-test.yml
with:
job_name: all-interfaces-tests (${{ matrix.python-version }})
job_runner_name: ${{ needs.determine_runner.outputs.runner_group }}
branch: ${{ inputs.branch }}
coverage_artifact_name: all-interfaces-coverage
python_version: ${{ matrix.python-version }}
Expand All @@ -352,6 +371,7 @@ jobs:
external-libraries-tests:
needs:
- setup-ci-load
- determine_runner
strategy:
max-parallel: >-
${{
Expand All @@ -368,6 +388,7 @@ jobs:
uses: ./.github/workflows/unit-test.yml
with:
job_name: external-libraries-tests (${{ matrix.python-version }})
job_runner_name: ${{ needs.determine_runner.outputs.runner_group }}
branch: ${{ inputs.branch }}
coverage_artifact_name: external-libraries-tests-coverage
python_version: ${{ matrix.python-version }}
Expand All @@ -390,6 +411,7 @@ jobs:
qcut-tests:
needs:
- setup-ci-load
- determine_runner
strategy:
max-parallel: >-
${{
Expand All @@ -406,6 +428,7 @@ jobs:
uses: ./.github/workflows/unit-test.yml
with:
job_name: qcut-tests (${{ matrix.python-version }})
job_runner_name: ${{ needs.determine_runner.outputs.runner_group }}
branch: ${{ inputs.branch }}
coverage_artifact_name: qcut-coverage
python_version: ${{ matrix.python-version }}
Expand All @@ -423,6 +446,7 @@ jobs:
qchem-tests:
needs:
- setup-ci-load
- determine_runner
strategy:
max-parallel: >-
${{
Expand All @@ -439,6 +463,7 @@ jobs:
uses: ./.github/workflows/unit-test.yml
with:
job_name: qchem-tests (${{ matrix.python-version }})
job_runner_name: ${{ needs.determine_runner.outputs.runner_group }}
branch: ${{ inputs.branch }}
coverage_artifact_name: qchem-coverage
python_version: ${{ matrix.python-version }}
Expand All @@ -455,6 +480,7 @@ jobs:
gradients-tests:
needs:
- setup-ci-load
- determine_runner
strategy:
max-parallel: >-
${{
Expand All @@ -474,6 +500,7 @@ jobs:
uses: ./.github/workflows/unit-test.yml
with:
job_name: gradients-tests (${{ matrix.config.suite }}, ${{ matrix.python-version }})
job_runner_name: ${{ needs.determine_runner.outputs.runner_group }}
branch: ${{ inputs.branch }}
coverage_artifact_name: gradients-${{ matrix.config.suite }}-coverage
python_version: ${{ matrix.python-version }}
Expand All @@ -490,6 +517,7 @@ jobs:
data-tests:
needs:
- setup-ci-load
- determine_runner
strategy:
max-parallel: >-
${{
Expand All @@ -506,6 +534,7 @@ jobs:
uses: ./.github/workflows/unit-test.yml
with:
job_name: data-tests (${{ matrix.python-version }})
job_runner_name: ${{ needs.determine_runner.outputs.runner_group }}
branch: ${{ inputs.branch }}
coverage_artifact_name: data-coverage-${{ matrix.python-version }}
python_version: ${{ matrix.python-version }}
Expand All @@ -523,6 +552,7 @@ jobs:
device-tests:
needs:
- setup-ci-load
- determine_runner
strategy:
max-parallel: >-
${{
Expand All @@ -546,6 +576,7 @@ jobs:
uses: ./.github/workflows/unit-test.yml
with:
job_name: device-tests (${{ matrix.config.device }}, ${{ matrix.config.shots }}, ${{ matrix.python-version }})
job_runner_name: ${{ needs.determine_runner.outputs.runner_group }}
branch: ${{ inputs.branch }}
coverage_artifact_name: devices-coverage-${{ matrix.config.device }}-${{ matrix.config.shots }}
python_version: ${{ matrix.python-version }}
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,9 @@ jobs:
pytest_store_durations: false

upload-stable-deps:
needs: tests
needs: [tests]
runs-on: ubuntu-latest
if: ${{ github.event_name == 'push' }}
if: ${{ github.event_name == 'schedule' }}
steps:
- name: Checkout
uses: actions/checkout@v3
Expand Down
7 changes: 6 additions & 1 deletion .github/workflows/unit-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,11 @@ on:
description: Name of the artifact file that will contain the coverage file for codevoc
required: true
type: string
job_runner_name:
description: The name of the runner to use for the job
required: false
type: string
default: 'ubuntu-latest'
checkout_fetch_depth:
description: How many commits to checkout from HEAD of branch passed
required: false
Expand Down Expand Up @@ -118,7 +123,7 @@ on:
jobs:
test:
name: ${{ inputs.job_name }}
runs-on: ubuntu-latest
runs-on: ${{ inputs.job_runner_name }}

steps:
- name: Checkout
Expand Down
Loading