Skip to content

Commit 81b6c01

Browse files
committed
chore: merge 3.6 into main
Conflicts: - api/agent/meterstatus/client.go - api/agent/meterstatus/client_test.go - api/agent/uniter/unit.go - api/agent/uniter/unit_test.go - api/agent/uniter/uniter.go - api/agent/uniter/uniter_test.go - api/apiclient.go - api/apiclient_test.go - api/userpass_login_provider.go - apiserver/admin_test.go - cmd/internal/loginprovider/sessiontokenloginprovider_test.go - cmd/juju/controller/register.go - cmd/juju/storage/add.go - core/status/caas.go - internal/storage/directive.go - internal/storage/directive_test.go - internal/worker/auditconfigupdater/manifold.go - internal/worker/certupdater/manifold.go - internal/worker/httpserver/manifold.go - internal/worker/peergrouper/manifold.go - internal/worker/uniter/runner/context/contextfactory.go - tests/suites/deploy/bundles/basic-openstack.yaml - worker/controlsocket/manifold.go - worker/meterstatus/manifold.go - worker/meterstatus/manifold_test.go - worker/metrics/sender/manifold.go - worker/metrics/sender/manifold_test.go
2 parents 1df3ba1 + d2d3eac commit 81b6c01

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

49 files changed

+958
-370
lines changed

.github/workflows/docs.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,12 @@ jobs:
4646
run: |
4747
go run ./scripts/md-gen/controller-config
4848
49+
- name: Add version notice to generated docs
50+
env:
51+
DOCS_DIR: ${{ steps.gen.outputs.dir }}
52+
run: |
53+
go run ./scripts/md-gen/version-notice
54+
4955
- name: pip install requirements
5056
run: |
5157
python3 -m venv .venv

.github/workflows/static-analysis.yml

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -168,3 +168,41 @@ jobs:
168168
steps:
169169
- uses: actions/checkout@v4
170170
- uses: wagoid/commitlint-github-action@v6
171+
172+
go-version:
173+
name: Go Version
174+
runs-on: [self-hosted, linux, arm64, aws, large]
175+
if: github.event.pull_request.draft == false
176+
strategy:
177+
fail-fast: false
178+
matrix:
179+
binary: ["jujud", "juju"]
180+
steps:
181+
- name: Checkout
182+
uses: actions/checkout@v3
183+
184+
- name: Set up Go
185+
uses: actions/setup-go@v4
186+
with:
187+
go-version-file: 'go.mod'
188+
cache: true
189+
190+
- name: Get go.mod version
191+
id: go_mod_version
192+
shell: bash
193+
run: echo "GO_MOD_VERSION=$(go mod edit -json | jq -r .Go | awk 'BEGIN{FS="."} {print $1"."$2}')" >> $GITHUB_ENV
194+
195+
- name: Get binary snapcraft.yaml
196+
id: get_binary_snapcraft
197+
uses: mikefarah/yq@master
198+
with:
199+
cmd: yq -r '.parts | .["${{ matrix.binary }}"] | .["go-channel"]' snap/snapcraft.yaml
200+
201+
- name: Ensure go version
202+
shell: bash
203+
run: |
204+
echo ${{ steps.get_binary_snapcraft.outputs.result }} | grep -q "$GO_MOD_VERSION"
205+
if [ $? -ne 0 ]; then
206+
echo "Go version in go.mod ($mod_version) does not match snapcraft.yaml ($snap_version)"
207+
exit 1
208+
fi

CONTRIBUTING.md

Lines changed: 31 additions & 70 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ great.
55
- Bug reports should be filed on [Launchpad](https://bugs.launchpad.net/juju/+bugs),
66
not GitHub. Please check that your bug has not already been reported.
77
- When opening a pull request:
8+
- Check that all your [commits are signed](https://docs.github.com/en/authentication/managing-commit-signature-verification/signing-commits).
9+
- Use [Conventional Commits](https://www.conventionalcommits.org/en/v1.0.0/) for commit messages.
810
- Check that your patch is [targeting the correct branch](#branches) -
911
if not, please rebase it.
1012
- Please [sign the CLA](#contributor-licence-agreement) if you haven't already.
@@ -44,29 +46,23 @@ Building Juju
4446
`juju` is written in [Go](https://go.dev/), a modern, compiled, statically typed,
4547
concurrent language.
4648

47-
Generally, Juju is built against the most recent version of Go, with the caveat
48-
that Go versions are not incremented during a release cycle. This means that
49-
`main` will typically be using the latest version of Go, but any given release
50-
branch may lag by one version or so. Check the `go.mod` file at the root of
51-
the project for the targeted version of Go, as this is authoritative.
49+
Generally, Juju is built against a recent version of Go, with the caveat
50+
that Go versions are not incremented during a release cycle. Check the `go.mod`
51+
file at the root of the project for the targeted version of Go, as this is
52+
authoritative.
5253

5354
For example, the following indicates that Go 1.21 is targeted:
5455

5556
```
5657
module github.com/juju/juju
5758
58-
go 1.21
59+
go 1.21.3
5960
```
6061

6162
### Official distribution
6263

63-
Go can be [installed](https://golang.org/doc/install#install) from the official distribution.
64-
65-
### via snap
66-
67-
[Snap](https://snapcraft.io/go) may also be used to install Go on Linux.
68-
69-
snap install go --channel=1.21/stable --classic
64+
Go can be [installed](https://golang.org/doc/install#install) from the official
65+
distribution.
7066

7167
## Build Juju and its dependencies
7268

@@ -76,14 +72,11 @@ The easiest way to get the Juju source code is to clone the GitHub repository:
7672

7773
To build/install from source, `cd` into the root directory of the cloned repo,
7874
and use `make`.
79-
- `make go-build` will build the Juju binaries and put them in a
75+
- `make build` will build the Juju binaries and put them in a
8076
`_build` subdirectory.
81-
- `make go-install` will build the Juju binaries and install them in your
77+
- `make install` will build the Juju binaries and install them in your
8278
[$GOBIN directory](https://pkg.go.dev/cmd/go#hdr-Compile_and_install_packages_and_dependencies)
8379
(which defaults to `$GOPATH/bin` or `~/go/bin`).
84-
- `make build` and `make install` are as above, but they will also regenerate
85-
the facade schema. An up-to-date schema is always checked into the Juju repo,
86-
so you shouldn't need to do this unless you make facade changes.
8780

8881
Getting started
8982
===============
@@ -125,37 +118,6 @@ that your fork is not automatically kept in sync with the official Juju repo
125118
Note that Juju has dependencies hosted elsewhere with other version control
126119
tools.
127120

128-
Local clone
129-
-----------
130-
131-
To contribute to Juju you will also need a local clone of your GitHub fork.
132-
The earlier `go get` command will have already cloned the Juju repo for you.
133-
However, that local copy is still set to pull from and push to the upstream
134-
Juju github account. Here is how to fix that (replace <USERNAME> with your
135-
github account name):
136-
137-
```bash
138-
cd juju
139-
git remote set-url origin [email protected]:<USERNAME>/juju.git
140-
```
141-
142-
To simplify staying in sync with upstream, give it a "remote" name:
143-
144-
```bash
145-
git remote add upstream https://github.com/juju/juju.git
146-
```
147-
148-
Add the check script as a git hook:
149-
150-
```bash
151-
cd juju
152-
ln -s scripts/pre-push.bash .git/hooks/pre-push
153-
```
154-
155-
This will ensure that any changes you commit locally pass a basic sanity
156-
check. Using pre-push requires git 1.8.2 or later, though alternatively
157-
running the check as a pre-commit hook also works.
158-
159121
Staying in sync
160122
---------------
161123

@@ -169,30 +131,28 @@ git pull upstream
169131
Dependency management
170132
=====================
171133

172-
In the top-level directory of the Juju repo, there is a file,
173-
[go.mod](go.mod), that holds the versions of all the external
174-
Go modules that Juju depends on. That file is used to freeze the code in
175-
external repositories so that Juju is insulated from changes to those repos.
176-
177134
go mod
178135
------
179136

180-
Juju uses Go modules to manage dependencies. Your Go installation will ensure
181-
you are building with the correct version - you don't need to do anything.
137+
Juju uses Go modules to manage dependencies.
182138

183139
Updating dependencies
184140
---------------------
185141

186-
To update a dependency, use
142+
To update a dependency, use the following, ensuring that the dependency is
143+
using a version where possible, or a commit hash if not available:
144+
145+
187146
```
188-
go get -u github.com/the/dependency
147+
go get -u github.com/the/dependency@v1.2.3
189148
go mod tidy
190149
```
191150

192151
Code formatting
193152
===============
194153

195-
Go provides a tool, `go fmt`, which facilitates a standardized format to go source code. The Juju project has one additional policy:
154+
Go provides a tool, `go fmt`, which facilitates a standardized format to go
155+
source code. The Juju project has one additional policy:
196156

197157
Imports
198158
-------
@@ -215,9 +175,6 @@ group is alphabetically sorted. eg:
215175
)
216176
```
217177

218-
Because "gopkg.in/check.v1" will be referenced frequently in test suites, its
219-
name gets a default short name of just "gc".
220-
221178
Workflow
222179
========
223180

@@ -242,7 +199,7 @@ and so we keep a separate Git branch for each version. When submitting a
242199
patch, please make sure your changes are targeted to the correct branch.
243200

244201
We keep a branch for each minor version of Juju in active development (e.g.
245-
`2.9`, `3.1`) - bug fixes should go into the relevant branch. We also keep a
202+
`3.4`, `3.5`) - bug fixes should go into the relevant branch. We also keep a
246203
`main` branch, which will become the next minor version of Juju. All new
247204
features should go into `main`.
248205

@@ -256,6 +213,7 @@ Creating a new branch
256213
All development should be done on a new branch, based on the correct branch
257214
determined above. Pull the latest version of this branch, then create and
258215
checkout a new branch for your changes - e.g. for a patch targeting `main`:
216+
259217
```
260218
git pull upstream main
261219
git checkout -b new_feature main
@@ -318,10 +276,18 @@ Testing and MongoDB
318276
-------------------
319277

320278
Many tests use a standalone instance of `mongod` as part of their setup. The
321-
`mongod` binary found in `$PATH` is executed by these suites. If you don't already have MongoDB installed, or have difficulty using your installed version to run Juju tests, you may want to install the [`juju-db` snap](https://snapcraft.io/juju-db), which is guaranteed to work with Juju.
279+
`mongod` binary found in `$PATH` is executed by these suites. If you don't
280+
already have MongoDB installed, or have difficulty using your installed version
281+
to run Juju tests, you may want to install the [`juju-db` snap](https://snapcraft.io/juju-db), which is guaranteed to work with Juju.
322282

323283
```bash
324284
sudo snap install juju-db --channel 4.4/stable
285+
```
286+
287+
Optionally, you can create aliases for `mongod` and `mongo` to make it easier to
288+
use the snap version:
289+
290+
```bash
325291
sudo snap alias juju-db.mongod mongod
326292
sudo snap alias juju-db.mongo mongo
327293
```
@@ -442,12 +408,7 @@ Required dependencies for full static analysis are:
442408
- shellcheck
443409
- python3
444410
- go
445-
- golint
446-
- goimports
447-
- deadcode
448-
- misspell
449-
- unconvert
450-
- ineffassign
411+
- golangci-lint
451412

452413
Community
453414
=========

0 commit comments

Comments
 (0)