Skip to content

Commit 673ab9e

Browse files
authored
Upgrade to Pants 2.15 and to scie-pants (#11)
1 parent 86e6657 commit 673ab9e

File tree

6 files changed

+43
-560
lines changed

6 files changed

+43
-560
lines changed

.github/workflows/pants.yaml

+11-16
Original file line numberDiff line numberDiff line change
@@ -19,20 +19,15 @@ jobs:
1919
name: Perform CI Checks
2020
needs: org-check
2121
runs-on: ubuntu-20.04
22-
strategy:
23-
matrix:
24-
# The python version to run Pants itself on.
25-
python-version: [3.9]
2622
steps:
2723
- uses: actions/checkout@v3
28-
- uses: pantsbuild/actions/init-pants@v2
24+
- uses: pantsbuild/actions/init-pants@v4-scie-pants
2925
# This action bootstraps pants and manages 2-3 GHA caches.
3026
# See: github.com/pantsbuild/actions/tree/main/init-pants/
3127
with:
32-
pants-python-version: ${{ matrix.python-version }}
33-
# cache0 makes it easy to bust the cache if needed
28+
# v0 makes it easy to bust the cache if needed
3429
# just increase the integer to start with a fresh cache
35-
gha-cache-key: cache0-py${{ matrix.python-version }}
30+
gha-cache-key: v0
3631
# The go backend doesn't use named caches. See the example-python repo for an example
3732
# of how to set up this cache.
3833
named-caches-hash: ""
@@ -49,21 +44,21 @@ jobs:
4944
- name: Install Go
5045
uses: actions/setup-go@v2
5146
with:
52-
go-version: 1.17.1
47+
go-version: 1.19.5
5348
- name: Bootstrap Pants
54-
run: ./pants --version
49+
run: pants --version
5550
- name: Check Pants config files
56-
run: ./pants tailor --check update-build-files --check
51+
run: pants tailor --check update-build-files --check
5752
- name: Lint and compile
58-
run: ./pants lint check '::'
53+
run: pants lint check '::'
5954
- name: Test
60-
run: ./pants test '::'
55+
run: pants test '::'
6156
- name: Package / Run
6257
run: |
6358
# We also smoke test that our release process will work by running `package`.
64-
./pants package ::
65-
./pants run cmd/greeter_en
66-
./pants run cmd/greeter_es
59+
pants package ::
60+
pants run cmd/greeter_en:
61+
pants run cmd/greeter_es:
6762
- name: Upload Pants log
6863
uses: actions/upload-artifact@v3
6964
with:

README.md

+26-28
Original file line numberDiff line numberDiff line change
@@ -4,28 +4,26 @@ An example repository to demonstrate Pants's experimental Golang support.
44

55
See the [Golang blog post](https://blog.pantsbuild.org/golang-support-pants-28/) for some unique
66
benefits Pants brings to Golang repositories, and see
7-
[pantsbuild.org/docs/go-overview](https://www.pantsbuild.org/v2.8/docs/go-overview) for more detailed
7+
[pantsbuild.org/docs/go-overview](https://www.pantsbuild.org/docs/go-overview) for more detailed
88
documentation.
99

1010
This is only one possible way of laying out your project with Pants. See
1111
[pantsbuild.org/docs/source-roots#examples](https://www.pantsbuild.org/docs/source-roots#examples)
1212
for some other example layouts.
1313

14-
Note: for now, Pants only supports repositories using a single `go.mod`. Please comment on
15-
[#13114](https://github.com/pantsbuild/pants/issues/13114) if you need support for greater
16-
than one `go.mod` so that we can prioritize adding support.
17-
1814
# Running Pants
1915

20-
You run Pants goals using the `./pants` wrapper script, which will bootstrap the
21-
configured version of Pants if necessary.
16+
You run Pants goals using the `pants` launcher binary, which will bootstrap the
17+
version of Pants configured for this repo if necessary.
18+
19+
See [here](https://www.pantsbuild.org/docs/installation) for how to install the `pants` binary.
2220

2321
# Goals
2422

2523
Pants commands are called _goals_. You can get a list of goals with
2624

2725
```
28-
./pants help goals
26+
pants help goals
2927
```
3028

3129
Most goals take arguments to run on. To run on a single directory, use the directory name with
@@ -35,19 +33,19 @@ end.
3533
For example:
3634

3735
```
38-
./pants lint cmd: internal::
36+
pants lint cmd: internal::
3937
```
4038

4139
You can run on all changed files:
4240

4341
```
44-
./pants --changed-since=HEAD lint
42+
pants --changed-since=HEAD lint
4543
```
4644

4745
You can run on all changed files, and any of their "dependees":
4846

4947
```
50-
./pants --changed-since=HEAD --changed-dependees=transitive test
48+
pants --changed-since=HEAD --changed-dependees=transitive test
5149
```
5250

5351
# Example Goals
@@ -57,60 +55,60 @@ Try these out in this repo!
5755
## Run Gofmt
5856

5957
```
60-
./pants fmt :: # Format all packages.
61-
./pants fmt cmd/greeter_en # Format only this package.
62-
./pants lint pkg/:: # Check that all packages under `pkg` are formatted.
58+
pants fmt :: # Format all packages.
59+
pants fmt cmd/greeter_en: # Format only this package.
60+
pants lint pkg:: # Check that all packages under `pkg` are formatted.
6361
```
6462

6563
## Check compilation
6664

6765
```
68-
./pants check :: # Compile all packages.
69-
./pants check cmd/greeter_en # Compile only this package and its transitive dependencies.
66+
pants check :: # Compile all packages.
67+
pants check cmd/greeter_en: # Compile only this package and its transitive dependencies.
7068
```
7169

7270
## Run tests
7371

7472
```
75-
./pants test :: # Run all tests in the repository.
76-
./pants test pkg/uuid # Run all the tests in this package.
77-
./pants test pkg/uuid -- -run TestGenerateUuid # Run just this one test.
73+
pants test :: # Run all tests in the repository.
74+
pants test pkg/uuid: # Run all the tests in this package.
75+
pants test pkg/uuid: -- -run TestGenerateUuid # Run just this one test.
7876
```
7977

8078
## Create a binary file
8179

8280
Writes the result to the `dist/` folder.
8381

8482
```
85-
./pants package cmd/greeter_en
86-
./pants package cmd/:: # Create all binaries.
83+
pants package cmd/greeter_en:
84+
pants package cmd:: # Create all binaries.
8785
```
8886

8987
## Run a binary
9088

9189
```
92-
./pants run cmd/greeter_en
93-
./pants run cmd/greeter_es -- --help
90+
pants run cmd/greeter_en:
91+
pants run cmd/greeter_es: -- --help
9492
```
9593

9694
## Determine dependencies
9795

9896
```
99-
./pants dependencies cmd/greeter_en
100-
./pants dependencies --transitive cmd/greeter_en
97+
pants dependencies cmd/greeter_en:
98+
pants dependencies --transitive cmd/greeter_en:
10199
```
102100

103101
## Determine dependees
104102

105103
That is, find what code depends on a particular package(s).
106104

107105
```
108-
./pants dependees pkg/uuid
109-
./pants dependees --transitive pkg/uuid
106+
pants dependees pkg/uuid:
107+
pants dependees --transitive pkg/uuid:
110108
```
111109

112110
## Count lines of code
113111

114112
```
115-
./pants count-loc '**/*'
113+
pants count-loc '**/*'
116114
```

cmd/greeter_en/BUILD

+2-2
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@
33

44
go_package()
55

6-
# This target allows us to use `./pants run` and `./pants package` on this `main` Go package.
6+
# This target allows us to use `pants run` and `pants package` on this `main` Go package.
77
#
88
# You can optionally set the field `output_path="greeter_en"`, for example, for the binary's name
9-
# to be different when running `./pants package`.
9+
# to be different when running `pants package`.
1010
go_binary(
1111
name="bin",
1212
)

cmd/greeter_es/BUILD

+2-2
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@
33

44
go_package()
55

6-
# This target allows us to use `./pants run` and `./pants package` on this `main` Go package.
6+
# This target allows us to use `pants run` and `pants package` on this `main` Go package.
77
#
88
# You can optionally set the field `output_path="greeter_es"`, for example, for the binary's name
9-
# to be different when running `./pants package`.
9+
# to be different when running `pants package`.
1010
go_binary(
1111
name="bin",
1212
)

0 commit comments

Comments
 (0)