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/.github/workflows/python-publish.yml b/.github/workflows/python-publish.yml index dcb41eb7..85d9bf7b 100644 --- a/.github/workflows/python-publish.yml +++ b/.github/workflows/python-publish.yml @@ -16,13 +16,18 @@ jobs: - uses: actions/checkout@v2 - name: Setup uv run: ./scripts/install-uv.sh - - name: Build and publish - env: - UV_PUBLISH_USERNAME: ${{ secrets.PYPI_USERNAME }} - UV_PUBLISH_PASSWORD: ${{ secrets.PYPI_PASSWORD }} + - name: Build run: | uv build - uv publish + - name: Add release assets + uses: actions/upload-release-asset@v1.0.1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + upload_url: ${{ github.event.release.upload_url }} + asset_path: ./dist/*.whl + asset_name: python-on-whales.whl + asset_content_type: application/zip - name: Testing the uploaded wheel run: | uv run --with python-on-whales --no-project -- python -c "import python_on_whales" diff --git a/python_on_whales/components/buildx/cli_wrapper.py b/python_on_whales/components/buildx/cli_wrapper.py index 3877407c..0e32b774 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, + context: 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 + context: Context (optionally remote) in which to find definition 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 context is not None: + full_cmd.append(context) 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..8325c0e8 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,33 @@ 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_context(only_print): + config = docker.buildx.bake( + print=only_print, + context="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") def test_bake_stream_logs(monkeypatch):