Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
93e79fb
chore: pre-commit and spelling fixes
dimaqq Nov 12, 2024
9d9c6a8
chore: ruff autofix
dimaqq Nov 12, 2024
fb8897e
chore: manual fixes
dimaqq Nov 12, 2024
7006d61
chore: docformatter over tests
dimaqq Nov 12, 2024
6422645
chore: docformatter + ruff
dimaqq Nov 12, 2024
61f346b
chore: manual ruff fixes
dimaqq Nov 12, 2024
e21d3c1
chore: manual ruff fixes
dimaqq Nov 12, 2024
70e3a74
chore: pre-commit and its settings
dimaqq Nov 12, 2024
ac99474
chore: verbatim copies of json files from juju
dimaqq Nov 13, 2024
83a3cd4
chore: exempt json files copied from juju from specific checks
dimaqq Nov 13, 2024
04e6446
chore: ruff format after codegen
dimaqq Nov 13, 2024
7ae3858
chore: fix up arg that's not optional
dimaqq Nov 13, 2024
05dfde5
chore: fix up utils, secrets, provisioner
dimaqq Nov 13, 2024
d79029d
chore: fix model; restore jasyncio re-export
dimaqq Nov 13, 2024
a864024
chore: fix k8s proxy; re-export in jasyncio
dimaqq Nov 13, 2024
f546538
chore: fix up the codegen
dimaqq Nov 13, 2024
9b45d8a
chore: fix up the codegen
dimaqq Nov 13, 2024
50199e2
chore: fix client and connection, disable warnings for the generated …
dimaqq Nov 13, 2024
5492c30
chore: clean pre-commit
dimaqq Nov 13, 2024
5f119ec
chore: remove old linter
dimaqq Nov 13, 2024
a8399b4
chore: don't let pre-commit autofix pull requests, it doesn't pass CLA
dimaqq Nov 14, 2024
1217ef1
chore: exclude known large file patterns
dimaqq Nov 14, 2024
a3b241d
chore: document pre-commit
dimaqq Nov 14, 2024
4ccd82d
chore: remove lint from GHA job deps
dimaqq Nov 14, 2024
6de9a5b
chore: fix package build
dimaqq Nov 14, 2024
cb4a962
chore: publish wheels in addition to sdist
dimaqq Nov 14, 2024
3ea32bf
chore: add tooling to the contributor guide
dimaqq Nov 14, 2024
7cd3743
chore: uvx in gha
dimaqq Nov 14, 2024
45c5b99
chore: weirdly my local build both sdist and wheel, while GHA build a…
dimaqq Nov 14, 2024
e3cecc3
chore: main is still on .0, not .1
dimaqq Nov 14, 2024
d8c4688
chore: sensible stacklevel on deprecation warnings
dimaqq Nov 14, 2024
3cba1b6
chore: sensible stacklevel on deprecation warnings
dimaqq Nov 14, 2024
62585d2
chore: pre-commit via github action
dimaqq Nov 15, 2024
f5b93e7
chore: simpler build
dimaqq Nov 15, 2024
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
2 changes: 1 addition & 1 deletion .github/ISSUE_TEMPLATE/BugReport.yml
Original file line number Diff line number Diff line change
Expand Up @@ -53,4 +53,4 @@ body:
Please provide a simplified reproducer, and if it's possible please refrain from providing a 'clone this repository and run the integration tests to see the problem' type of a reproducer. Thanks!"
render: python
validations:
required: true
required: true
2 changes: 1 addition & 1 deletion .github/ISSUE_TEMPLATE/FeatureRequest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,4 @@ body:
description: "Please provide valid Python code that you'd like to be able to run with this new feature: "
render: python
validations:
required: true
required: true
2 changes: 1 addition & 1 deletion .github/pull_request_template.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,4 @@ All CI tests need to pass.

#### Notes & Discussion

*\<Additional notes for the reviewers if needed. Please delete section if not applicable.\>*
*\<Additional notes for the reviewers if needed. Please delete section if not applicable.\>*
17 changes: 17 additions & 0 deletions .github/workflows/pre-commit.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
---
name: pre-commit

on:
pull_request:
push:
branches: [main]

jobs:
pre-commit:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: "3.13"
- uses: pre-commit/action@v3.0.1
1 change: 0 additions & 1 deletion .github/workflows/static-analysis.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,3 @@ jobs:
steps:
- uses: actions/checkout@v4
- uses: wagoid/commitlint-github-action@v6

37 changes: 6 additions & 31 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,28 +7,6 @@ concurrency:
cancel-in-progress: true

jobs:
lint:
name: Linter
runs-on: ubuntu-latest
strategy:
matrix:
python:
- "3.9"
- "3.10"
steps:
- name: Check out code
uses: actions/checkout@v4
- name: Setup Python
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python }}
- name: Install dependencies
run: pip install tox
- name: Run linter
run: |
tox -e lint
./scripts/copyright.sh

build-test:
name: Build test
runs-on: ubuntu-latest
Expand All @@ -37,14 +15,12 @@ jobs:
python:
- "3.10"
steps:
- name: Check out code
uses: actions/checkout@v4
- name: Setup Python
uses: actions/setup-python@v5
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python }}
- name: Run build test target
run: |
- uses: astral-sh/setup-uv@v3.2.2
- run: |
make build-test

validate:
Expand All @@ -67,7 +43,6 @@ jobs:
run: tox -e validate

unit-tests:
needs: lint
name: Unit tests
runs-on: ubuntu-latest
strategy:
Expand All @@ -93,7 +68,7 @@ jobs:

integration:
name: Integration
needs: [lint, unit-tests]
needs: [unit-tests]
timeout-minutes: 150
runs-on: ubuntu-latest
strategy:
Expand Down Expand Up @@ -161,7 +136,7 @@ jobs:

integration-quarantine:
name: Quarantined Integration Tests
needs: [lint, unit-tests]
needs: [unit-tests]
timeout-minutes: 150
runs-on: ubuntu-latest
strategy:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/test_candidate.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ jobs:
else
echo "Candidate $candidate has to be tested"
next_test="$candidate"
fi
fi
fi
echo "next-test=$next_test" >> $GITHUB_ENV
echo "$next_test" > ~/juju-last-candidate-version
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/test_edge.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ jobs:
else
echo "Edge $edge has to be tested"
next_test="$edge"
fi
fi
fi
echo "next-test=$next_test" >> $GITHUB_ENV
echo "$next_test" > ~/juju-last-edge-version
Expand Down
46 changes: 46 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.5.0
hooks:
- id: check-added-large-files
exclude: |
(?x) # Verbose mode
^juju/client/schemas-juju-.*[.]json$ |
^tests/.*[.]charm$ |
^examples/.*[.]charm$
- id: check-ast
- id: check-case-conflict
- id: check-executables-have-shebangs
- id: check-shebang-scripts-are-executable
- id: check-merge-conflict
- id: check-symlinks
- id: check-json
- id: check-yaml
# Overlays deliberately comprise multiple YAML documents per file
exclude: "^tests/integration/bundle/test-overlays/.*multi.*yaml$"
- id: check-toml
- id: mixed-line-ending
- id: end-of-file-fixer
exclude: "^juju/client/schemas-juju-.*[.]json$"
- id: trailing-whitespace
- id: detect-private-key
exclude: "^tests/.*$"

- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.7.3
hooks:
- id: ruff
args: [ --preview, --fix ]
- id: ruff-format
args: [ --preview ]

- repo: https://github.com/codespell-project/codespell
rev: v2.3.0
hooks:
- id: codespell
additional_dependencies:
- tomli
exclude: "^juju/client/schemas-juju-.*[.]json$"

ci:
autofix_prs: false
2 changes: 1 addition & 1 deletion .readthedocs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@ build:
python: "3.10"

sphinx:
configuration: docs/conf.py
configuration: docs/conf.py
27 changes: 11 additions & 16 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -16,47 +16,42 @@ clean:

.PHONY: client
client:
tox -r --notest -e lint,py3
tox -r --notest -e py3
$(PY) -m juju.client.facade -s "juju/client/schemas*" -o juju/client/
pre-commit run --files $(shell echo juju/client/_[cd]*.py)

.PHONY: run-unit-tests
run-unit-tests: .tox lint
run-unit-tests: .tox
tox -e py3

.PHONY: run-integration-tests
run-integration-tests: .tox lint
run-integration-tests: .tox
tox -e integration

.PHONY: run-all-tests
test: run-unit-tests run-integration-tests

.PHONY: lint
lint:
@./scripts/copyright.sh
@echo "==> Running flake8 linter"
tox -e lint

.PHONY: docs
docs:
tox -e docs

.PHONY: build-test
build-test:
rm -rf venv
uv build
python3 -m venv venv
. venv/bin/activate
python3 setup.py sdist
pip install ./dist/juju-${VERSION}.tar.gz
pip install dist/juju-${VERSION}-py3-none-any.whl
python3 -c "from juju.controller import Controller"
rm ./dist/juju-${VERSION}.tar.gz
rm dist/*.tar.gz dist/*.whl

.PHONY: release
release:
git fetch --tags
rm dist/*.tar.gz || true
$(PY) setup.py sdist
$(BIN)/twine check dist/*
$(BIN)/twine upload --repository juju dist/*
rm dist/*.tar.gz dist/*.whl || true
uv build
uvx twine check dist/*
uvx twine upload --repository juju dist/*
git tag ${VERSION}
git push --tags

Expand Down
2 changes: 1 addition & 1 deletion debian/changelog
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ Thursday January 9 2020
Tuesday January 7 2020

* Update facade methods for Juju 2.7.0
* Fix an issue when querying CMR relations (#366)
* Fix an issue when querying CMR relations (#366)
* Fix storage support in bundles (#361)
* Fix reporting of unit leaders (#374)
* AddCloud API support (#370)
Expand Down
1 change: 0 additions & 1 deletion debian/control
Original file line number Diff line number Diff line change
Expand Up @@ -130,4 +130,3 @@ Description:
.
Pylibjuju releases now track the Juju release cadence. New generated schemas
will be updated per Juju releases.

1 change: 0 additions & 1 deletion debian/copyright
Original file line number Diff line number Diff line change
Expand Up @@ -212,4 +212,3 @@ License: Apache-2
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

7 changes: 7 additions & 0 deletions docs/CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,12 @@ Check to see what [types of contributions](/contributing/types-of-contributions.
-->


## Tooling

- `uv`, https://docs.astral.sh/uv/
- `pre-commit`, https://pre-commit.com/
- Python 3.8 ~ 3.13, https://www.python.org/downloads/

## Pull Request

Thanks for considering to contribute code to our project! We accept and welcome all kinds of PRs! :tada:
Expand All @@ -40,6 +46,7 @@ The process is very simple.
- Check with `git remote -v`, origin should point to your fork, upstream should point to ours.
- If your changes are going to be on top of a specific branch (e.g., `2.9`), then fetch and switch to that.
- `git switch -c your-branch-name`
- Make sure that you have run `pre-commit install`
- Make your changes, create your commits.
- `git push -u origin your-branch-name`

Expand Down
53 changes: 27 additions & 26 deletions docs/_extensions/automembersummary.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,45 +33,46 @@ def run(self):
try:
module = importlib.import_module(module_name)
except ImportError:
raise SphinxError("Unable to generate reference docs for %s, "
"could not import" % (module_name))
raise SphinxError(
"Unable to generate reference docs for %s, "
"could not import" % (module_name)
)

divider = '+{:-<80}+'.format('')
row = '| {:<78} |'.format
divider = "+{:-<80}+".format("")
row = "| {:<78} |".format
lines = []
for member_name, member in inspect.getmembers(module):
if not self._filter(module_name, member_name, member):
continue
summary = textwrap.wrap(self._get_summary(member), 78) or ['']
link = '`{} <#{}>`_'.format(member_name,
'.'.join([module_name,
member_name]))
methods = ['* `{} <#{}>`_'.format(n,
'.'.join([module_name,
member_name,
n]))
for n, m in inspect.getmembers(member)
if not n.startswith('_') and inspect.isfunction(m)]
summary = textwrap.wrap(self._get_summary(member), 78) or [""]
link = "`{} <#{}>`_".format(
member_name, ".".join([module_name, member_name])
)
methods = [
"* `{} <#{}>`_".format(n, ".".join([module_name, member_name, n]))
for n, m in inspect.getmembers(member)
if not n.startswith("_") and inspect.isfunction(m)
]

lines.append(divider)
lines.append(row(link))
lines.append(divider)
for line in summary:
lines.append(row(line))
lines.append(row(line)) # noqa: PERF401
if methods:
lines.append(row(''))
lines.append(row('Methods:'))
lines.append(row(''))
for i, method in enumerate(methods):
lines.append(row(""))
lines.append(row("Methods:"))
lines.append(row(""))
for _, method in enumerate(methods):
lines.append(row(method))
lines.append(divider)
content = '\n'.join(lines)
content = "\n".join(lines)

result = self._parse(content, '<automembersummary>')
result = self._parse(content, "<automembersummary>")
return result

def _get_summary(self, member):
doc = (member.__doc__ or '').splitlines()
doc = (member.__doc__ or "").splitlines()

# strip any leading blank lines
while doc and not doc[0].strip():
Expand All @@ -86,12 +87,12 @@ def _get_summary(self, member):
return " ".join(doc).strip()

def _filter(self, module_name, member_name, member):
if member_name.startswith('_'):
if member_name.startswith("_"):
return False
if hasattr(member, '__module__'):
if hasattr(member, "__module__"):
# skip imported classes & functions
return member.__module__.startswith(module_name)
elif hasattr(member, '__name__'):
elif hasattr(member, "__name__"):
# skip imported modules
return member.__name__.startswith(module_name)
else:
Expand All @@ -109,4 +110,4 @@ def _parse(self, rst_text, annotation):


def setup(app):
app.add_directive('automembersummary', AutoMemberSummary)
app.add_directive("automembersummary", AutoMemberSummary)
Loading