Skip to content

Commit

Permalink
Fixed macro comments
Browse files Browse the repository at this point in the history
  • Loading branch information
sureshjoshi committed Jun 18, 2024
1 parent 36e9d5b commit 93a2ef8
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 12 deletions.
2 changes: 0 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
# Dockerfiles

## Cache Strategy

## Deprecations/Removals

### TI-specific toolchains
Expand Down
28 changes: 18 additions & 10 deletions pants-plugins/macros.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
def default_ghcr_cache(target_name: str) -> tuple[str, Optional[str]]: # noqa: F821
"""
From Github Actions default env vars, try to constitute
Using Github Actions default env vars - create a cache_from, and cache_to taking
into account branches and PRs for better cache locality.
https://docs.github.com/en/actions/learn-github-actions/variables#default-environment-variables
"""
# Need to specify this, because Pants doesn't reconcile `@ghcr` in the cache details
Expand Down Expand Up @@ -36,17 +38,23 @@ def default_ghcr_cache(target_name: str) -> tuple[str, Optional[str]]: # noqa:

def docker_image_gha(name: str, **kwargs) -> None:
"""
A macro to create a Docker image that caches to Github Actions, by default.
A macro to create a Docker image that caches to Github Actions cache, by default.
"""
# cache_from = kwargs.pop("cache_from", {"type": "gha", "scope": name})
# cache_to = kwargs.pop("cache_to", {"type": "gha", "mode": "max", "scope": name})
cache_from = kwargs.pop("cache_from", {"type": "gha", "scope": name})
cache_to = kwargs.pop("cache_to", {"type": "gha", "mode": "max", "scope": name})

docker_image( # noqa: F821
name=name,
cache_from=cache_from,
cache_to=cache_to,
**kwargs,
)


# docker_image( # noqa: F821
# name=name,
# cache_from=cache_from,
# cache_to=cache_to,
# **kwargs,
# )
def docker_image_ghcr(name: str, **kwargs) -> None:
"""
A macro to create a Docker image that caches to Github Container Registry, by default.
"""

cache_from, cache_to = default_ghcr_cache(name)
cache_from = kwargs.pop(
Expand Down

0 comments on commit 93a2ef8

Please sign in to comment.