Skip to content

Commit

Permalink
Add a get-pants-version config option to specify the get-pants.sh --v…
Browse files Browse the repository at this point in the history
…ersion to use. (#34)

When installing pants via actions/init-pants the latest version of the
scie-pants is used by default.

This broke for folks using linux aarch64 due to a problem with the
builds (see pantsbuild/scie-pants#430).

Add an input which allows you to specify a version to pass into
`get-pants.sh --version`, e.g. "0.12.0" calls it with `get-pants.sh
--version 0.12.0`. When no version is specified the flag is omitted and
the default of the latest version is used.

We've been using this with the following in our fork to pin our build
scie-pants version:

```yaml
- uses: Noryai/pants-actions/init-pants@main
  with:
    get-pants-version: 0.12.0
```
  • Loading branch information
micktwomey authored Nov 27, 2024
1 parent d767b35 commit 56efcdb
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
4 changes: 4 additions & 0 deletions init-pants/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,10 @@ and oauth token so that pants can use GHA as a fine-grained remote cache. You mu
configure the other remote caching options in `pants.ci.toml` or similar as described in
[remote caching](https://www.pantsbuild.org/2.20/docs/using-pants/remote-caching-and-execution/remote-caching#github-actions-cache).

`get-pants-version`: This is used to override the version of scie-pants
downloaded by `get-pants.sh`. The default is the latest version. To specify a
version set this to a release, e.g. `0.12.0`.

`gh-host`: This is used to add an enterprise GitHub host for API calls instead of `github.com`.

`gha-cache-key`: This is used to create the GHA cache keys for pants' `lmdb_store`
Expand Down
15 changes: 13 additions & 2 deletions init-pants/action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,11 @@ inputs:
required: false
# When we update get-pants.sh, we should update this commit.
default: 6f136713a46e555946a22ffb3ed49c372eea58df
get-pants-version:
description: |
Pass this version into `get-pants.sh --version`
required: false
default: ''
base-branch:
description: |
The fallback commit to restore the local process cache from, if no cache
Expand Down Expand Up @@ -94,14 +99,20 @@ runs:
- name: Ensure the Pants launcher binary
shell: bash
run: |
VERSION="${{ inputs.get-pants-version }}"
if [ -n "${VERSION}" ]; then
VERSION_FLAG="--version ${VERSION}"
else
VERSION_FLAG=""
fi
if ! command -v pants; then
if [[ -f ./get-pants.sh ]]; then
./get-pants.sh
./get-pants.sh $VERSION_FLAG
else
curl --proto '=https' --tlsv1.2 -fsSLo ${{ runner.temp }}/get-pants.sh \
https://raw.githubusercontent.com/pantsbuild/setup/${{ inputs.setup-commit }}/get-pants.sh
chmod +x ${{ runner.temp }}/get-pants.sh
${{ runner.temp }}/get-pants.sh
${{ runner.temp }}/get-pants.sh $VERSION_FLAG
fi
# add 'pants' is on the PATH for subsequent actions.
if [[ -f "$HOME/bin/pants" ]]; then
Expand Down

0 comments on commit 56efcdb

Please sign in to comment.