Skip to content

Don't run the PyPi job all the time #1363

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

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
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
53 changes: 52 additions & 1 deletion .github/workflows/pypi.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,34 @@
cancel-in-progress: true

jobs:
Copy link
Contributor

Choose a reason for hiding this comment

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

Make zizmor happy about default permissions

Suggested change
jobs:
permissions: {}
jobs:

check_changes:
runs-on: ubuntu-latest
outputs:
should_run: ${{ steps.filter.outputs.any_changed }}
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
should_run: ${{ steps.filter.outputs.any_changed }}
should_run: |
echo "${{ github.event_name == 'release' ||
github.ref == 'refs/heads/auto-release' ||
(
github.ref == 'refs/heads/main' || github.event_name == 'pull_request') &&
steps.filter.outputs.any_changed == 'true'
) }}"

steps:
- uses: actions/checkout@v4

Check warning

Code scanning / zizmor

does not set persist-credentials: false Warning

does not set persist-credentials: false
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
- uses: actions/checkout@v4
- uses: actions/checkout@v4
with:
persist-credentials: false

- uses: dorny/paths-filter@v2
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
- uses: dorny/paths-filter@v2
- uses: dorny/paths-filter@v3

id: filter
with:
filters: |
any_changed:
- '.github/workflows/pypi.yml'
- 'pyproject.toml'
- 'setup.py'
- 'pytensor/_version.py'
- 'pytensor/scan_perform.pyx'
- 'pytensor/scan_perform_ext.py'

# The job to build precompiled pypi wheels.

Check warning

Code scanning / zizmor

default permissions used due to no permissions: block Warning

default permissions used due to no permissions: block
make_sdist:
name: Make SDist
needs: check_changes
# Run if it's a release, auto-release branch, or if relevant files changed on main
if: |
github.event_name == 'release' ||
github.ref == 'refs/heads/auto-release' ||
Copy link
Contributor

Choose a reason for hiding this comment

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

I believe we should delete all references to auto-release AFAIK it predates PyTensor

(github.ref == 'refs/heads/main' && needs.check_changes.outputs.should_run == 'true') ||
(github.event_name == 'pull_request' && needs.check_changes.outputs.should_run == 'true')
Comment on lines +46 to +47
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
(github.ref == 'refs/heads/main' && needs.check_changes.outputs.should_run == 'true') ||
(github.event_name == 'pull_request' && needs.check_changes.outputs.should_run == 'true')
(
(github.ref == 'refs/heads/main' || github.event_name == 'pull_request')
&& needs.check_changes.outputs.should_run == 'true'
)

runs-on: ubuntu-latest
permissions:
# write id-token and attestations are required to attest build provenance
Expand Down Expand Up @@ -49,6 +74,13 @@

run_checks:
name: Build & inspect our package.
needs: check_changes
# Run if it's a release, auto-release branch, or if relevant files changed on main
if: |
github.event_name == 'release' ||
github.ref == 'refs/heads/auto-release' ||
(github.ref == 'refs/heads/main' && needs.check_changes.outputs.should_run == 'true') ||
(github.event_name == 'pull_request' && needs.check_changes.outputs.should_run == 'true')
Comment on lines +82 to +83
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
(github.ref == 'refs/heads/main' && needs.check_changes.outputs.should_run == 'true') ||
(github.event_name == 'pull_request' && needs.check_changes.outputs.should_run == 'true')
(
(github.ref == 'refs/heads/main' || github.event_name == 'pull_request')
&& needs.check_changes.outputs.should_run == 'true'
)

# Note: the resulting builds are not actually published.
# This is purely for additional testing and diagnostic purposes.
runs-on: ubuntu-latest
Expand All @@ -62,6 +94,13 @@

build_wheels:
name: Build wheels for ${{ matrix.platform }}
needs: check_changes
# Run if it's a release, auto-release branch, or if relevant files changed on main
if: |
github.event_name == 'release' ||
github.ref == 'refs/heads/auto-release' ||
(github.ref == 'refs/heads/main' && needs.check_changes.outputs.should_run == 'true') ||
(github.event_name == 'pull_request' && needs.check_changes.outputs.should_run == 'true')
Comment on lines +102 to +103
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
(github.ref == 'refs/heads/main' && needs.check_changes.outputs.should_run == 'true') ||
(github.event_name == 'pull_request' && needs.check_changes.outputs.should_run == 'true')
(
(github.ref == 'refs/heads/main' || github.event_name == 'pull_request')
&& needs.check_changes.outputs.should_run == 'true'
)

runs-on: ${{ matrix.platform }}
permissions:
# write id-token and attestations are required to attest build provenance
Expand Down Expand Up @@ -96,6 +135,13 @@

build_universal_wheel:
name: Build universal wheel for Pyodide
needs: check_changes
# Run if it's a release, auto-release branch, or if relevant files changed on main
if: |
github.event_name == 'release' ||
github.ref == 'refs/heads/auto-release' ||
(github.ref == 'refs/heads/main' && needs.check_changes.outputs.should_run == 'true') ||
(github.event_name == 'pull_request' && needs.check_changes.outputs.should_run == 'true')
Comment on lines +143 to +144
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
(github.ref == 'refs/heads/main' && needs.check_changes.outputs.should_run == 'true') ||
(github.event_name == 'pull_request' && needs.check_changes.outputs.should_run == 'true')
(
(github.ref == 'refs/heads/main' || github.event_name == 'pull_request')
&& needs.check_changes.outputs.should_run == 'true'
)

runs-on: ubuntu-latest
permissions:
# write id-token and attestations are required to attest build provenance
Expand Down Expand Up @@ -133,7 +179,12 @@

check_dist:
name: Check dist
needs: [make_sdist,build_wheels]
needs: [check_changes, make_sdist, build_wheels]
if: |
github.event_name == 'release' ||
github.ref == 'refs/heads/auto-release' ||
(github.ref == 'refs/heads/main' && needs.check_changes.outputs.should_run == 'true') ||
(github.event_name == 'pull_request' && needs.check_changes.outputs.should_run == 'true')
Comment on lines +186 to +187
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
(github.ref == 'refs/heads/main' && needs.check_changes.outputs.should_run == 'true') ||
(github.event_name == 'pull_request' && needs.check_changes.outputs.should_run == 'true')
(
(github.ref == 'refs/heads/main' || github.event_name == 'pull_request')
&& needs.check_changes.outputs.should_run == 'true'
)

runs-on: ubuntu-22.04
steps:
- uses: actions/download-artifact@v4
Expand Down