Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
50 changes: 0 additions & 50 deletions .github/workflows/container-pr-cleanup.yml

This file was deleted.

11 changes: 5 additions & 6 deletions .github/workflows/container.yml
Original file line number Diff line number Diff line change
Expand Up @@ -108,22 +108,21 @@ jobs:
- name: Prepare PR image tags
id: preview
env:
IMAGE_REPOSITORY: ${{ github.repository }}
IMAGE: ${{ matrix.image }}
PR_NUMBER: ${{ github.event.pull_request.number }}
TRACK: ${{ matrix.track }}
COMMIT_SHA: ${{ github.sha }}
IMAGE_VERSION: ${{ matrix.image-version }}
PLATFORMS: ${{ matrix.platforms }}
run: |
image="ghcr.io/${IMAGE_REPOSITORY,,}-pr"
tag="pr-${PR_NUMBER}-${TRACK}"
{
echo "image=$image"
echo "image=$IMAGE"
echo "package-version=${IMAGE_VERSION}-${tag}-${COMMIT_SHA:0:7}"
echo "platform=${PLATFORMS%%,*}"
echo 'tags<<PR_IMAGE_TAGS'
echo "$image:$tag"
echo "$image:$tag-$COMMIT_SHA"
echo "$IMAGE:$tag"
echo "$IMAGE:$tag-$COMMIT_SHA"
echo 'PR_IMAGE_TAGS'
} >> "$GITHUB_OUTPUT"
- name: Check out shared test and validation tooling
Expand Down Expand Up @@ -154,7 +153,7 @@ jobs:
outputs: type=oci,dest=${{ runner.temp }}/container-${{ matrix.track }}.tar
secrets: |
github_token=${{ github.event.pull_request.head.repo.full_name == github.repository && secrets.GITHUB_TOKEN || '' }}
# Preserve ownership even when a rerun leaves an older index untagged.
# Identify preview artifacts independently of their mutable tags.
annotations: |
index:io.tuxcrate.repository=${{ github.repository }}
index:io.tuxcrate.pull-request=${{ github.event.pull_request.number }}
Expand Down
19 changes: 0 additions & 19 deletions cmd/container-pr-cleanup/main.go

This file was deleted.

45 changes: 23 additions & 22 deletions cmd/container-release/workflow_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -380,29 +380,30 @@ func TestWorkflowPRImages(t *testing.T) {
switch {
case s.ID == "preview":
prepared = true
if s.Env["IMAGE_REPOSITORY"] != "${{ github.repository }}" || s.Env["PR_NUMBER"] != "${{ github.event.pull_request.number }}" || s.Env["TRACK"] != "${{ matrix.track }}" || s.Env["COMMIT_SHA"] != "${{ github.sha }}" || s.Env["PLATFORMS"] != "${{ matrix.platforms }}" || s.Env["IMAGE_VERSION"] != "${{ matrix.image-version }}" {
t.Fatal("preview tags must use caller repository, PR number, track, and tested merge commit")
if s.Env["IMAGE"] != "${{ matrix.image }}" || s.Env["PR_NUMBER"] != "${{ github.event.pull_request.number }}" || s.Env["TRACK"] != "${{ matrix.track }}" || s.Env["COMMIT_SHA"] != "${{ github.sha }}" || s.Env["PLATFORMS"] != "${{ matrix.platforms }}" || s.Env["IMAGE_VERSION"] != "${{ matrix.image-version }}" {
t.Fatal("preview tags must use the production image, PR number, track, and tested merge commit")
}
for _, track := range []string{"stable", "preview"} {
t.Run(track, func(t *testing.T) {
output := filepath.Join(t.TempDir(), "output")
sha := strings.Repeat("a", 40)
cmd := exec.Command("bash", "-e", "-o", "pipefail", "-c", s.Run)
cmd.Env = append(os.Environ(), "IMAGE_REPOSITORY=Tuxcrate/Zrepl", "PR_NUMBER=12", "TRACK="+track, "COMMIT_SHA="+sha, "GITHUB_OUTPUT="+output, "PLATFORMS=linux/arm64,linux/amd64", "IMAGE_VERSION=1.2.3")
if out, err := cmd.CombinedOutput(); err != nil {
t.Fatalf("prepare tags: %v: %s", err, out)
}
got, err := os.ReadFile(output)
if err != nil {
t.Fatal(err)
}
image := "ghcr.io/tuxcrate/zrepl-pr"
tag := "pr-12-" + track
want := "image=" + image + "\npackage-version=1.2.3-" + tag + "-" + sha[:7] + "\nplatform=linux/arm64\ntags<<PR_IMAGE_TAGS\n" + image + ":" + tag + "\n" + image + ":" + tag + "-" + sha + "\nPR_IMAGE_TAGS\n"
if string(got) != want {
t.Fatalf("unexpected preview tags: %s", got)
}
})
for _, image := range []string{"ghcr.io/tuxcrate/zrepl", "ghcr.io/tuxcrate/custom-image"} {
t.Run(track+"/"+image, func(t *testing.T) {
output := filepath.Join(t.TempDir(), "output")
sha := strings.Repeat("a", 40)
cmd := exec.Command("bash", "-e", "-o", "pipefail", "-c", s.Run)
cmd.Env = append(os.Environ(), "IMAGE="+image, "PR_NUMBER=12", "TRACK="+track, "COMMIT_SHA="+sha, "GITHUB_OUTPUT="+output, "PLATFORMS=linux/arm64,linux/amd64", "IMAGE_VERSION=1.2.3")
if out, err := cmd.CombinedOutput(); err != nil {
t.Fatalf("prepare tags: %v: %s", err, out)
}
got, err := os.ReadFile(output)
if err != nil {
t.Fatal(err)
}
tag := "pr-12-" + track
want := "image=" + image + "\npackage-version=1.2.3-" + tag + "-" + sha[:7] + "\nplatform=linux/arm64\ntags<<PR_IMAGE_TAGS\n" + image + ":" + tag + "\n" + image + ":" + tag + "-" + sha + "\nPR_IMAGE_TAGS\n"
if string(got) != want {
t.Fatalf("unexpected preview tags: %s", got)
}
})
}
}
case strings.HasPrefix(s.Uses, "docker/login-action@"):
loggedIn = true
Expand Down Expand Up @@ -572,7 +573,7 @@ fi
lookup, write := filepath.Join(dir, "lookup"), filepath.Join(dir, "write")
sha := strings.Repeat("a", 40)
digest := "sha256:" + strings.Repeat("b", 64)
image := "ghcr.io/tuxcrate/zrepl-pr"
image := "ghcr.io/tuxcrate/zrepl"
runURL := "https://github.com/tuxcrate/zrepl/actions/runs/123"
manifest := fmt.Sprintf("{\n \"track\": %q,\n \"os_flavor\": \"debian\",\n \"os_version\": \"13.7\"\n}", track)
if scenario != "missing-manifest" {
Expand Down
Loading