Fix GitHub action URL (#80)

Our docs and default value for the GitHub action cache URL were
referring to the
[wrong](https://github.com/tonistiigi/go-actions-cache/blob/master/api.md)
environment variable.

I was under the impression that the underlying library ends up checking
for the correct variable later so this would be only cosmetic, but a
user
[confirmed](https://github.com/pulumi/pulumi-docker-build/issues/77#issuecomment-2135621983)
this does appear to break things.

I brought over an old test I had written while this was still in the
pulumi-docker repo, but unfortunately it doesn't currently test GHA due
to ci-mgmt limitations
https://github.com/pulumi/pulumi-docker-build/issues/82.

Fixes https://github.com/pulumi/pulumi-docker-build/issues/77.
This commit is contained in:
Bryce Lampe
2024-05-29 05:29:58 -07:00
committed by GitHub
parent c9e5913af1
commit f0aaf7095d
22 changed files with 2228 additions and 64 deletions

View File

@@ -0,0 +1,7 @@
FROM --platform=$BUILDPLATFORM golang:1.21.6-alpine3.18 as initial
ARG SLEEP_SECONDS
RUN sleep ${SLEEP_SECONDS} && echo ${SLEEP_SECONDS} > output
FROM alpine:3.18 as final
COPY --from=initial /go/output output
RUN cat output

View File

@@ -0,0 +1,3 @@
name: test-buildx-caching
runtime: nodejs
description: A minimal TypeScript Pulumi program

View File

@@ -0,0 +1,40 @@
import * as buildx from "@pulumi/docker-build";
import * as pulumi from "@pulumi/pulumi";
const config = new pulumi.Config();
const start = new Date().getTime();
// docker buildx build \
// -f Dockerfile \
// --cache-to type=local,dest=tmp,mode=max,oci-mediatypes=true \
// --cache-from type=local,src=tmp \
// --build-arg SLEEP-MS=$SLEEP_MS \
// -t not-pushed \
// -f Dockerfile \
// .
const img = new buildx.Image(`buildx-${config.require("name")}`, {
tags: ["not-pushed"],
dockerfile: { location: "Dockerfile" },
push: false,
context: { location: "." },
buildArgs: {
SLEEP_SECONDS: config.require("SLEEP_SECONDS"),
},
cacheTo: [{ raw: config.require("cacheTo") }],
cacheFrom: [{ raw: config.require("cacheFrom") }],
// Set registry auth if it was provided.
registries: config.require("username")
? [
{
address: config.getSecret("address"),
username: config.getSecret("username"),
password: config.getSecret("password"),
},
]
: undefined,
});
export const durationSeconds = img.ref.apply(
(_) => (new Date().getTime() - start) / 1000.0
);

View File

@@ -0,0 +1,9 @@
{
"name": "test-buildx-caching",
"devDependencies": {
"@types/node": "^20.0.0"
},
"dependencies": {
"@pulumi/pulumi": "^3.0.0"
}
}

File diff suppressed because it is too large Load Diff