-
Notifications
You must be signed in to change notification settings - Fork 2.8k
Unify GitHub Actions branch-protection run logic #15794
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,196 @@ | ||
| --- | ||
|
|
||
| # This is the shared configuration that defines all the jobs we include in branch protection. This | ||
| # needs to be run both by PRs and by the merge queue. | ||
| # | ||
| # All required branch-protection rules should be in here, and everything in here should listed in | ||
| # the branch-protection rules (in the `finalize` job). | ||
|
|
||
| name: Branch Protection | ||
|
|
||
| on: | ||
| merge_group: | ||
| pull_request: | ||
| branches: ["main", "stable/*"] | ||
|
|
||
| concurrency: | ||
| group: ${{ github.repository }}-${{ github.ref }}-${{ github.workflow }} | ||
| cancel-in-progress: true | ||
|
|
||
| jobs: | ||
| # Shared configuration values. It's also possible to specify these in the GitHub web interface, | ||
| # but that separates them from the rest of the configuration logic and means that the changes to | ||
| # the configuration do not appear in the git history. | ||
| config: | ||
| name: Configure | ||
| runs-on: 'ubuntu-latest' | ||
| steps: | ||
| - run: ':' | ||
| outputs: | ||
| python-old: '3.10' | ||
| python-new: '3.13' | ||
| runner-linux-x86_64: 'ubuntu-latest' | ||
| runner-linux-arm64: 'ubuntu-24.04-arm' | ||
| runner-macos-arm64: 'macos-15' | ||
| runner-windows-x86_64: 'windows-latest' | ||
|
|
||
| # This 'finalize' job is a no-op; its sole purpose is to depend on all the other jobs and provide | ||
| # a single in-code determination of whether the branch-protection rules have been passed. The | ||
| # branch-protection rules in the GitHub web interface can then depend only on this job. | ||
| finalize: | ||
| name: Finalize | ||
| runs-on: 'ubuntu-latest' | ||
| steps: | ||
| - run: ':' | ||
| # This list should contain every other job in this file. | ||
| needs: | ||
| - docs | ||
| - lint | ||
| - test-linux | ||
| - test-macos | ||
| - test-windows | ||
| - test-rust | ||
| - test-c | ||
| - test-images | ||
| - miri | ||
| - qpy | ||
| - neko | ||
|
|
||
| docs: | ||
| name: Documentation | ||
| needs: config | ||
| uses: ./.github/workflows/docs.yml | ||
| with: | ||
| python-version: ${{ needs.config.outputs.python-new }} | ||
| runner: ${{ needs.config.outputs.runner-linux-x86_64 }} | ||
| secrets: inherit | ||
|
|
||
| lint: | ||
| name: Lint | ||
| needs: config | ||
| uses: ./.github/workflows/lint.yml | ||
| with: | ||
| python-version: ${{ needs.config.outputs.python-old }} | ||
| runner: ${{ needs.config.outputs.runner-linux-x86_64 }} | ||
|
|
||
| test-linux: | ||
| name: Unit Python / Linux / ${{ matrix.config.id }} - ${{ matrix.runner }} | ||
| needs: config | ||
| uses: ./.github/workflows/test-linux.yml | ||
| with: | ||
| runner: ${{ matrix.runner }} | ||
| python-version: ${{ matrix.config.python }} | ||
| install-optionals: ${{ matrix.config.install-optionals }} | ||
| install-from-sdist: ${{ matrix.config.install-from-sdist }} | ||
| qiskit-pycache: ${{ matrix.config.qiskit-pycache }} | ||
| strategy: | ||
| fail-fast: false | ||
| matrix: | ||
| runner: | ||
| - ${{ needs.config.outputs.runner-linux-x86_64 }} | ||
| - ${{ needs.config.outputs.runner-linux-arm64 }} | ||
| config: | ||
| - id: "Python oldest" | ||
| python: ${{ needs.config.outputs.python-old }} | ||
| install-optionals: true | ||
| install-from-sdist: false | ||
| qiskit-pycache: false | ||
| - id: "Python newest" | ||
| python: ${{ needs.config.outputs.python-new }} | ||
| install-optionals: false | ||
| install-from-sdist: true | ||
| qiskit-pycache: true | ||
|
|
||
| test-macos: | ||
| name: Unit Python / macOS / ${{ matrix.config.id }} | ||
| needs: config | ||
| uses: ./.github/workflows/test-mac.yml | ||
| with: | ||
| runner: ${{ needs.config.outputs.runner-macos-arm64 }} | ||
| python-version: ${{ matrix.config.python }} | ||
| install-optionals: ${{ matrix.config.install-optionals }} | ||
| strategy: | ||
| fail-fast: false | ||
| matrix: | ||
| config: | ||
| - id: "Python oldest" | ||
| python: ${{ needs.config.outputs.python-old }} | ||
| install-optionals: true | ||
| - id: "Python newest" | ||
| python: ${{ needs.config.outputs.python-new }} | ||
| install-optionals: false | ||
|
|
||
| test-windows: | ||
| name: Unit Python / Windows / ${{ matrix.config.id }} | ||
| needs: config | ||
| uses: ./.github/workflows/test-windows.yml | ||
| with: | ||
| runner: ${{ needs.config.outputs.runner-windows-x86_64 }} | ||
| python-version: ${{ matrix.config.python }} | ||
| install-optionals: ${{ matrix.config.install-optionals }} | ||
| strategy: | ||
| fail-fast: false | ||
| matrix: | ||
| config: | ||
| - id: "Python oldest" | ||
| python: ${{ needs.config.outputs.python-old }} | ||
| install-optionals: true | ||
| - id: "Python newest" | ||
| python: ${{ needs.config.outputs.python-new }} | ||
| install-optionals: false | ||
|
|
||
| test-rust: | ||
| name: Unit Rust | ||
| needs: config | ||
| uses: ./.github/workflows/rust-tests.yml | ||
| with: | ||
| python-version: ${{ needs.config.outputs.python-old }} | ||
| runner: ${{ needs.config.outputs.runner-linux-x86_64 }} | ||
|
|
||
| miri: | ||
| name: Miri | ||
| needs: config | ||
| uses: ./.github/workflows/miri.yml | ||
| with: | ||
| runner: ${{ needs.config.outputs.runner-linux-x86_64 }} | ||
|
|
||
| test-c: | ||
| name: Unit C / ${{ matrix.runner }} | ||
| needs: config | ||
| uses: ./.github/workflows/ctests.yml | ||
| with: | ||
| python-version: ${{ needs.config.outputs.python-new }} | ||
| runner: ${{ matrix.runner }} | ||
| strategy: | ||
| fail-fast: false | ||
| matrix: | ||
| runner: | ||
| - ${{ needs.config.outputs.runner-linux-x86_64 }} | ||
| - ${{ needs.config.outputs.runner-linux-arm64 }} | ||
| - ${{ needs.config.outputs.runner-macos-arm64 }} | ||
| - ${{ needs.config.outputs.runner-windows-x86_64 }} | ||
|
|
||
| test-images: | ||
| name: Image | ||
| needs: config | ||
| uses: ./.github/workflows/image-tests.yml | ||
| with: | ||
| python-version: ${{ needs.config.outputs.python-old }} | ||
| runner: ${{ needs.config.outputs.runner-linux-x86_64 }} | ||
|
|
||
| qpy: | ||
| name: QPY | ||
| needs: config | ||
| uses: ./.github/workflows/qpy.yml | ||
| with: | ||
| python-version: ${{ needs.config.outputs.python-old }} | ||
| runner: ${{ needs.config.outputs.runner-linux-x86_64 }} | ||
|
|
||
| neko: | ||
| name: Integration Neko | ||
| needs: config | ||
| runs-on: ${{ needs.config.outputs.runner-linux-x86_64 }} | ||
| steps: | ||
| - uses: Qiskit/qiskit-neko@main | ||
| with: | ||
| test_selection: "terra" | ||
|
Comment on lines
+190
to
+196
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I guess you didn't feel like this needed it's own file anymore since it's just calling a single action?
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I mean, it already is its own file, it's just that the file is in a different repo haha. The old |
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,43 @@ | ||
| --- | ||
| name: Docs | ||
| on: | ||
| workflow_call: | ||
| inputs: | ||
| python-version: | ||
| description: Python version to test. | ||
| type: string | ||
| required: true | ||
| runner: | ||
| description: Runner image to use. Expects an Ubuntu image. | ||
| type: string | ||
| required: true | ||
|
|
||
| jobs: | ||
| docs: | ||
| name: Docs | ||
| runs-on: ${{ inputs.runner }} | ||
| timeout-minutes: 60 | ||
| steps: | ||
| - uses: actions/checkout@v6 | ||
| with: | ||
| # We need to fetch the whole history so 'reno' can do its job and we can inspect tags. | ||
| fetch-depth: 0 | ||
| - name: Set up Python | ||
| uses: actions/setup-python@v6 | ||
| with: | ||
| python-version: ${{ inputs.python-version }} | ||
| - name: Install ubuntu docs dependencies | ||
| run: tools/install_ubuntu_docs_dependencies.sh | ||
| env: | ||
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
| - name: Run docs | ||
| run: tox -e docs | ||
| - name: Clean up docs detritus | ||
| run: rm -rf docs/_build/html/{.doctrees,.buildinfo} | ||
| - name: Store built documentation artifact | ||
| uses: actions/upload-artifact@v7 | ||
| with: | ||
| name: qiskit-docs | ||
| path: | | ||
| ./docs/_build/html/* | ||
| if-no-files-found: error |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,35 @@ | ||
| --- | ||
| name: Lint | ||
| on: | ||
| workflow_call: | ||
| inputs: | ||
| python-version: | ||
| description: Python version to test. | ||
| type: string | ||
| required: true | ||
| runner: | ||
| description: Runner image to use. | ||
| type: string | ||
| required: true | ||
|
|
||
| jobs: | ||
| lint: | ||
| name: Lint | ||
| runs-on: ${{ inputs.runner }} | ||
| timeout-minutes: 60 | ||
| steps: | ||
| - uses: actions/checkout@v6 | ||
| with: | ||
| # We need to fetch the whole history so 'reno' can do its job and we can inspect tags. | ||
| fetch-depth: 0 | ||
| - name: Set up Python | ||
| uses: actions/setup-python@v6 | ||
| with: | ||
| python-version: ${{ inputs.python-version }} | ||
| - name: Install dependencies | ||
| run: python -m pip install --upgrade tox | ||
| - name: Run lint | ||
| run: | | ||
| set -e | ||
| make cformat | ||
| tox -e lint |
This file was deleted.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess maybe for a follow up something we could add is a user input trigger on this to enable manually running a job with different options if we wanted. But definitely not in scope for this PR and probably not even in this rule. But the comment about the web interface made met think about it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
oh that's an interesting idea. I'll have to think about it, but there might be a way. The next step after this one is probably to move this "job" into its own file so other files can depend on it too, and maybe part of that will make it easier.