Skip to content

Commit

Permalink
use explicit setup-python versions over implicit expose- (Cherry-pick…
Browse files Browse the repository at this point in the history
… of #21568, #21582) (#21668)

The project is currently using a mix of the GitHub supplied
`setup-python` action and `pantsbuild/actions/expose-pythons`. On GitHub
managed runners they behave similarly:
* `setup-python` will install a version of Python if missing, or add it
to the PATH if already present at the expected location (managed runners
historically have multiple Pythons baked into the image)
* `expose-pythons` will add all Python's at the expected GitHub location
to the PATH. (Which ones is up to GitHub.)

So today the invocation of `setup-python` followed by `expose-pythons`
is redundant.

Consolidating on `setup-python` let's us be explicit about expected
versions (more like the ARM image) and reduces the number of custom
actions the project manages while still making multiple Python versions
available.

NOTE: The awkward double newlines in the final yaml are a pre-existing
issue

https://stackoverflow.com/questions/45004464/yaml-dump-adding-unwanted-newlines-in-multiline-strings

See #21552 for some history regarding the `setup-` vs `expose-` actions.

---------

Co-authored-by: cburroughs <chris.burroughs@gmail.com>
  • Loading branch information
huonw and cburroughs authored Nov 21, 2024
1 parent 6fad8c6 commit 3413de5
Show file tree
Hide file tree
Showing 5 changed files with 213 additions and 90 deletions.
16 changes: 12 additions & 4 deletions .github/workflows/cache_comparison.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,20 @@ jobs:
uses: actions/checkout@v4
with:
fetch-depth: 10
- name: Set up Python 3.9
- name: Set up Python 3.7, 3.8, 3.9, 3.10, 3.12, 3.11
uses: actions/setup-python@v5
with:
python-version: '3.9'
- name: Expose Pythons
uses: pantsbuild/actions/expose-pythons@v9
python-version: '3.7
3.8
3.9
3.10
3.12
3.11'
- env:
BASE_REF: ${{ github.event.inputs.base_ref }}
BUILD_COMMIT: ${{ github.event.inputs.build_commit }}
Expand Down
16 changes: 12 additions & 4 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -374,12 +374,20 @@ jobs:
fetch-depth: '0'
fetch-tags: true
ref: ${{ needs.release_info.outputs.build-ref }}
- name: Set up Python 3.9
- name: Set up Python 3.7, 3.8, 3.9, 3.10, 3.12, 3.11
uses: actions/setup-python@v5
with:
python-version: '3.9'
- name: Expose Pythons
uses: pantsbuild/actions/expose-pythons@v9
python-version: '3.7
3.8
3.9
3.10
3.12
3.11'
- name: Install Protoc
uses: arduino/setup-protoc@9b1ee5b22b0a3f1feb8c2ff99b32c89b3c3191e9
with:
Expand Down
218 changes: 168 additions & 50 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -118,10 +118,20 @@ jobs:
uses: actions/checkout@v4
with:
fetch-depth: 10
- name: Set up Python 3.9
- name: Set up Python 3.7, 3.8, 3.9, 3.10, 3.12, 3.11
uses: actions/setup-python@v5
with:
python-version: '3.9'
python-version: '3.7
3.8
3.9
3.10
3.12
3.11'
- name: Install Protoc
uses: arduino/setup-protoc@9b1ee5b22b0a3f1feb8c2ff99b32c89b3c3191e9
with:
Expand Down Expand Up @@ -221,10 +231,20 @@ jobs:
uses: actions/checkout@v4
with:
fetch-depth: 10
- name: Set up Python 3.9
- name: Set up Python 3.7, 3.8, 3.9, 3.10, 3.12, 3.11
uses: actions/setup-python@v5
with:
python-version: '3.9'
python-version: '3.7
3.8
3.9
3.10
3.12
3.11'
- name: Install Protoc
uses: arduino/setup-protoc@9b1ee5b22b0a3f1feb8c2ff99b32c89b3c3191e9
with:
Expand Down Expand Up @@ -670,10 +690,20 @@ jobs:
\ --max_size 30\necho \"PANTS_REMOTE_STORE_ADDRESS=grpc://localhost:9092\" >> \"$GITHUB_ENV\"\necho\
\ \"PANTS_REMOTE_CACHE_READ=true\" >> \"$GITHUB_ENV\"\necho \"PANTS_REMOTE_CACHE_WRITE=${CACHE_WRITE}\" >> \"$GITHUB_ENV\"\
\n"
- name: Set up Python 3.9
- name: Set up Python 3.7, 3.8, 3.9, 3.10, 3.12, 3.11
uses: actions/setup-python@v5
with:
python-version: '3.9'
python-version: '3.7
3.8
3.9
3.10
3.12
3.11'
- name: Download native binaries
uses: actions/download-artifact@v4
with:
Expand Down Expand Up @@ -850,12 +880,20 @@ jobs:
echo "${HOME}/.thrift" >> $GITHUB_PATH
'
- name: Set up Python 3.9
- name: Set up Python 3.7, 3.8, 3.9, 3.10, 3.12, 3.11
uses: actions/setup-python@v5
with:
python-version: '3.9'
- name: Expose Pythons
uses: pantsbuild/actions/expose-pythons@v9
python-version: '3.7
3.8
3.9
3.10
3.12
3.11'
- name: Download native binaries
uses: actions/download-artifact@v4
with:
Expand Down Expand Up @@ -942,12 +980,20 @@ jobs:
echo "${HOME}/.thrift" >> $GITHUB_PATH
'
- name: Set up Python 3.9
- name: Set up Python 3.7, 3.8, 3.9, 3.10, 3.12, 3.11
uses: actions/setup-python@v5
with:
python-version: '3.9'
- name: Expose Pythons
uses: pantsbuild/actions/expose-pythons@v9
python-version: '3.7
3.8
3.9
3.10
3.12
3.11'
- name: Download native binaries
uses: actions/download-artifact@v4
with:
Expand Down Expand Up @@ -1034,12 +1080,20 @@ jobs:
echo "${HOME}/.thrift" >> $GITHUB_PATH
'
- name: Set up Python 3.9
- name: Set up Python 3.7, 3.8, 3.9, 3.10, 3.12, 3.11
uses: actions/setup-python@v5
with:
python-version: '3.9'
- name: Expose Pythons
uses: pantsbuild/actions/expose-pythons@v9
python-version: '3.7
3.8
3.9
3.10
3.12
3.11'
- name: Download native binaries
uses: actions/download-artifact@v4
with:
Expand Down Expand Up @@ -1126,12 +1180,20 @@ jobs:
echo "${HOME}/.thrift" >> $GITHUB_PATH
'
- name: Set up Python 3.9
- name: Set up Python 3.7, 3.8, 3.9, 3.10, 3.12, 3.11
uses: actions/setup-python@v5
with:
python-version: '3.9'
- name: Expose Pythons
uses: pantsbuild/actions/expose-pythons@v9
python-version: '3.7
3.8
3.9
3.10
3.12
3.11'
- name: Download native binaries
uses: actions/download-artifact@v4
with:
Expand Down Expand Up @@ -1218,12 +1280,20 @@ jobs:
echo "${HOME}/.thrift" >> $GITHUB_PATH
'
- name: Set up Python 3.9
- name: Set up Python 3.7, 3.8, 3.9, 3.10, 3.12, 3.11
uses: actions/setup-python@v5
with:
python-version: '3.9'
- name: Expose Pythons
uses: pantsbuild/actions/expose-pythons@v9
python-version: '3.7
3.8
3.9
3.10
3.12
3.11'
- name: Download native binaries
uses: actions/download-artifact@v4
with:
Expand Down Expand Up @@ -1310,12 +1380,20 @@ jobs:
echo "${HOME}/.thrift" >> $GITHUB_PATH
'
- name: Set up Python 3.9
- name: Set up Python 3.7, 3.8, 3.9, 3.10, 3.12, 3.11
uses: actions/setup-python@v5
with:
python-version: '3.9'
- name: Expose Pythons
uses: pantsbuild/actions/expose-pythons@v9
python-version: '3.7
3.8
3.9
3.10
3.12
3.11'
- name: Download native binaries
uses: actions/download-artifact@v4
with:
Expand Down Expand Up @@ -1402,12 +1480,20 @@ jobs:
echo "${HOME}/.thrift" >> $GITHUB_PATH
'
- name: Set up Python 3.9
- name: Set up Python 3.7, 3.8, 3.9, 3.10, 3.12, 3.11
uses: actions/setup-python@v5
with:
python-version: '3.9'
- name: Expose Pythons
uses: pantsbuild/actions/expose-pythons@v9
python-version: '3.7
3.8
3.9
3.10
3.12
3.11'
- name: Download native binaries
uses: actions/download-artifact@v4
with:
Expand Down Expand Up @@ -1494,12 +1580,20 @@ jobs:
echo "${HOME}/.thrift" >> $GITHUB_PATH
'
- name: Set up Python 3.9
- name: Set up Python 3.7, 3.8, 3.9, 3.10, 3.12, 3.11
uses: actions/setup-python@v5
with:
python-version: '3.9'
- name: Expose Pythons
uses: pantsbuild/actions/expose-pythons@v9
python-version: '3.7
3.8
3.9
3.10
3.12
3.11'
- name: Download native binaries
uses: actions/download-artifact@v4
with:
Expand Down Expand Up @@ -1586,12 +1680,20 @@ jobs:
echo "${HOME}/.thrift" >> $GITHUB_PATH
'
- name: Set up Python 3.9
- name: Set up Python 3.7, 3.8, 3.9, 3.10, 3.12, 3.11
uses: actions/setup-python@v5
with:
python-version: '3.9'
- name: Expose Pythons
uses: pantsbuild/actions/expose-pythons@v9
python-version: '3.7
3.8
3.9
3.10
3.12
3.11'
- name: Download native binaries
uses: actions/download-artifact@v4
with:
Expand Down Expand Up @@ -1678,12 +1780,20 @@ jobs:
echo "${HOME}/.thrift" >> $GITHUB_PATH
'
- name: Set up Python 3.9
- name: Set up Python 3.7, 3.8, 3.9, 3.10, 3.12, 3.11
uses: actions/setup-python@v5
with:
python-version: '3.9'
- name: Expose Pythons
uses: pantsbuild/actions/expose-pythons@v9
python-version: '3.7
3.8
3.9
3.10
3.12
3.11'
- name: Download native binaries
uses: actions/download-artifact@v4
with:
Expand Down Expand Up @@ -1737,12 +1847,20 @@ jobs:
with:
distribution: adopt
java-version: '11'
- name: Set up Python 3.9
- name: Set up Python 3.7, 3.8, 3.9, 3.10, 3.12, 3.11
uses: actions/setup-python@v5
with:
python-version: '3.9'
- name: Expose Pythons
uses: pantsbuild/actions/expose-pythons@v9
python-version: '3.7
3.8
3.9
3.10
3.12
3.11'
- name: Download native binaries
uses: actions/download-artifact@v4
with:
Expand Down
Loading

0 comments on commit 3413de5

Please sign in to comment.