diff --git a/.github/workflows/python-package.yml b/.github/workflows/python-package.yml index a3308cf7..0861d8e7 100644 --- a/.github/workflows/python-package.yml +++ b/.github/workflows/python-package.yml @@ -22,6 +22,10 @@ jobs: cp docs/mkdocs.yml ./ - name: Render run: uv run mkdocs build + - uses: actions/upload-artifact@v4 + with: + name: Docs + path: site build-linux-lint: runs-on: ubuntu-24.04 diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 2acd001d..cae41892 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -40,6 +40,16 @@ of the file `docs/docs_utils.py` which is responsible for generating the part of http://localhost:8000 +### Use CI-generated docs + +The GitHub workflows automatically generate the docs and save them as artifacts. These can be accessed from the Artifacts section of the worfklow view (as [documented here](https://docs.github.com/en/actions/managing-workflow-runs-and-deployments/managing-workflow-runs/downloading-workflow-artifacts)). + +To view them: + +1. Download the artifact labeled `Docs`. +1. Extract the contents of the resulting `Docs.zip` file. +1. Open the `index.html` file in a browser. + ## Running the tests Same as before, using `uv` means that you don't need to install anything. Just run diff --git a/python_on_whales/components/buildx/cli_wrapper.py b/python_on_whales/components/buildx/cli_wrapper.py index 3877407c..ffd3e1de 100644 --- a/python_on_whales/components/buildx/cli_wrapper.py +++ b/python_on_whales/components/buildx/cli_wrapper.py @@ -126,6 +126,7 @@ def bake( set: Dict[str, str] = {}, variables: Dict[str, str] = {}, stream_logs: bool = False, + remote_definition: Union[str, None] = None, ) -> Union[Dict[str, Dict[str, Dict[str, Any]]], Iterator[str]]: """Bake is similar to make, it allows you to build things declared in a file. @@ -148,6 +149,7 @@ def bake( set: A list of overrides in the form `"targetpattern.key=value"`. variables: A dict containing the values of the variables defined in the hcl file. See + remote_definition: Remote context in which to find bake files # Returns The configuration used for the bake (files merged + override with @@ -197,6 +199,8 @@ def bake( for file in to_list(files): full_cmd.add_simple_arg("--file", file) full_cmd.add_args_iterable_or_single("--set", format_mapping_for_cli(set)) + if remote_definition is not None: + full_cmd.append(remote_definition) targets = to_list(targets) env = dict(variables) if print: diff --git a/tests/python_on_whales/components/buildx/test_buildx_cli_wrapper.py b/tests/python_on_whales/components/buildx/test_buildx_cli_wrapper.py index 3b945135..a752fca3 100644 --- a/tests/python_on_whales/components/buildx/test_buildx_cli_wrapper.py +++ b/tests/python_on_whales/components/buildx/test_buildx_cli_wrapper.py @@ -654,6 +654,55 @@ def test_bake_with_variables_2(only_print, monkeypatch): } +@pytest.mark.usefixtures("with_docker_driver") +@pytest.mark.usefixtures("change_cwd") +@pytest.mark.parametrize("only_print", [True, False]) +def test_bake_with_remote_definition(only_print): + config = docker.buildx.bake( + print=only_print, + remote_definition="https://github.com/gabrieldemarmiesse/python-on-whales.git#v0.74.0:tests/python_on_whales/components/bake_tests", + ) + assert config == { + "group": {"default": {"targets": ["my_out1", "my_out2"]}}, + "target": { + "my_out1": { + "context": "https://github.com/gabrieldemarmiesse/python-on-whales.git#v0.74.0:tests/python_on_whales/components/bake_tests", + "dockerfile": "Dockerfile", + "tags": ["pretty_image1:1.0.0"], + "target": "out1", + }, + "my_out2": { + "context": "https://github.com/gabrieldemarmiesse/python-on-whales.git#v0.74.0:tests/python_on_whales/components/bake_tests", + "dockerfile": "Dockerfile", + "tags": ["pretty_image2:1.0.0"], + "target": "out2", + }, + }, + } + + +@pytest.mark.usefixtures("with_docker_driver") +@pytest.mark.usefixtures("change_cwd") +@pytest.mark.parametrize("only_print", [True, False]) +def test_bake_with_remote_definition_and_target(only_print): + config = docker.buildx.bake( + print=only_print, + targets=["my_out2"], + remote_definition="https://github.com/gabrieldemarmiesse/python-on-whales.git#v0.74.0:tests/python_on_whales/components/bake_tests", + ) + assert config == { + "group": {"default": {"targets": ["my_out2"]}}, + "target": { + "my_out2": { + "context": "https://github.com/gabrieldemarmiesse/python-on-whales.git#v0.74.0:tests/python_on_whales/components/bake_tests", + "dockerfile": "Dockerfile", + "tags": ["pretty_image2:1.0.0"], + "target": "out2", + }, + }, + } + + @pytest.mark.usefixtures("with_docker_driver") @pytest.mark.usefixtures("change_cwd") def test_bake_stream_logs(monkeypatch):