Skip to content

Commit

Permalink
ci(docker): patch @agoric/synthetic-chain to enable other repos
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelfig committed Sep 6, 2024
1 parent 0883548 commit a083021
Show file tree
Hide file tree
Showing 5 changed files with 300 additions and 165 deletions.
24 changes: 11 additions & 13 deletions .github/workflows/docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -194,29 +194,26 @@ jobs:
yarn synthetic-chain prepare-build
working-directory: a3p-integration

- name: Override the platforms in docker-bake.json
run: |
jq -n --arg PLATFORMS "$DOCKER_PLATFORMS" \
'{"variable": {"PLATFORMS": { "default": ($PLATFORMS | split(",")) }}}' \
> ./docker-bake.override.json
working-directory: a3p-integration

- name: Save SDK_TAG
run: echo "SDK_TAG=${{ needs.snapshot.outputs.tag }}" >> $GITHUB_ENV

- name: Override some Docker tags we don't want
- name: Override the docker-bake.json variables
run: |
IMAGE="$REGISTRY/agoric/agoric-sdk"
sed -i.bak -e "s%$IMAGE:unreleased%$IMAGE:$SDK_TAG%g" Dockerfile
sed -i.bak -e "s%$REGISTRY/agoric/agoric-3-proposals:%$IMAGE:%g" docker-bake.hcl
REPOSITORY_COLON="$REGISTRY/agoric/agoric-sdk:a3p-"
jq -n --arg REPOSITORY_COLON "$REPOSITORY_COLON" \
--arg PLATFORMS "$DOCKER_PLATFORMS" \
'{"variable": {
"PLATFORMS": { "default": ($PLATFORMS | split(",")) },
"REPOSITORY_COLON": { "default": $REPOSITORY_COLON },
}}' > ./docker-bake.override.json
working-directory: a3p-integration

- name: Prefix tags
id: prefix-tags
run: |
IMAGE="$REGISTRY/agoric/agoric-sdk"
for TAG in ${{ needs.docker-sdk.outputs.tags }}; do
PREFIXED="$PREFIXED$sep$IMAGE:use-upgrade-next-$TAG"
PREFIXED="$PREFIXED$sep$IMAGE:a3p-use-upgrade-next-$TAG"
sep=,
done
echo "tags=$PREFIXED" >> $GITHUB_OUTPUT
Expand All @@ -237,7 +234,7 @@ jobs:
images: ${{ env.REGISTRY }}/agoric/agoric-sdk
tags: ${{ steps.prefix-tags.outputs.tags }}

- name: Save proposal "use-upgrade-next" image
- name: Publish "use-upgrade-next" image
uses: depot/bake-action@v1
id: bake-upgrade-next
with:
Expand All @@ -246,6 +243,7 @@ jobs:
docker-bake.override.json
docker-bake.hcl
${{ steps.meta.outputs.bake-file }}
set: '*.args.SDK_TAG=${{ env.SDK_TAG }}'
targets: use-upgrade-next
push: true
workdir: ./a3p-integration
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,126 @@
diff --git a/dist/cli/cli.js b/dist/cli/cli.js
index c59a54224c101648c5507f451bfe0b2cb7f420a5..24ef27a882805df4a969a96ab28dad15b8ee5479 100755
--- a/dist/cli/cli.js
+++ b/dist/cli/cli.js
@@ -14,7 +14,9 @@ import path from "node:path";
var defaultConfig = {
// Tag of the agoric-3 image containing all passed proposals
// Must match the Bake file and CI config
- fromTag: "latest"
+ fromTag: "latest",
+ repositoryColon: "ghcr.io/agoric/agoric-3-proposals:",
+ sdkRepositoryColon: "ghcr.io/agoric/agoric-sdk:",
};
function readBuildConfig(root2) {
const packageJsonPath = path.join(root2, "package.json");
@@ -25,7 +27,8 @@ function readBuildConfig(root2) {
}
var buildProposalSubmissions = (proposals2) => {
for (const proposal of proposals2) {
- if (!("source" in proposal && proposal.source === "build")) continue;
+ if (!("source" in proposal && proposal.source === "build"))
+ continue;
console.log(
"Refreshing submission for",
proposal.proposalIdentifier,
@@ -63,7 +66,6 @@ import fs3 from "node:fs";
import assert from "node:assert";
import fs2 from "node:fs";
import * as path2 from "node:path";
-var repository = "ghcr.io/agoric/agoric-3-proposals";
function readInfo(proposalPath) {
assert(
proposalPath === proposalPath.toLowerCase(),
@@ -105,7 +107,7 @@ function readProposals(proposalsParent) {
function imageNameForProposal(proposal, stage2) {
const target = `${stage2}-${proposal.proposalName}`;
return {
- name: `${repository}:${target}`,
+ name: `${buildConfig.repositoryColon}${target}`,
target
};
}
@@ -143,7 +145,7 @@ RUN /usr/src/upgrade-test-scripts/run_prepare_zero.sh
RESUME(fromTag) {
return `
## RESUME
-FROM ghcr.io/agoric/agoric-3-proposals:${fromTag} as use-${fromTag}
+FROM \${REPOSITORY_COLON:-${buildConfig.repositoryColon}\}\${FROM_TAG:-${fromTag}\} as use-${fromTag}
`;
},
/**
@@ -186,7 +188,7 @@ RUN ./run_prepare.sh ${path5}
}) {
return `
# EXECUTE ${proposalName}
-FROM ghcr.io/agoric/agoric-sdk:${sdkImageTag} as execute-${proposalName}
+FROM \${SDK_REPOSITORY_COLON:-${buildConfig.sdkRepositoryColon}\}\${SDK_TAG:-${sdkImageTag}\} as execute-${proposalName}

WORKDIR /usr/src/upgrade-test-scripts

@@ -281,13 +283,22 @@ function writeBakefileProposals(allProposals2, platforms) {
},
PROPOSALS: {
default: allProposals2.map((p) => p.proposalName)
+ },
+ REPOSITORY_COLON: {
+ default: buildConfig.repositoryColon
+ },
+ SDK_REPOSITORY_COLON: {
+ default: buildConfig.sdkRepositoryColon
+ },
+ FROM_TAG: {
+ default: buildConfig.fromTag
}
}
};
fs3.writeFileSync("docker-bake.json", JSON.stringify(json, null, 2));
}
function writeDockerfile(allProposals2, fromTag) {
- const blocks = ["# syntax=docker/dockerfile:1.4"];
+ const blocks = ["# syntax=docker/dockerfile:1.4\nARG FROM_TAG\nARG REPOSITORY_COLON\nARG SDK_TAG\nARG SDK_REPOSITORY_COLON"];
let previousProposal = null;
if (fromTag) {
blocks.push(stage.RESUME(fromTag));
@@ -493,8 +517,8 @@ var prepareDockerBuild = () => {
const cliPath = new URL(import.meta.url).pathname;
const publicDir = path4.resolve(cliPath, "..", "..");
execSync4(`cp -r ${path4.resolve(publicDir, "docker-bake.hcl")} .`);
- writeDockerfile(allProposals, buildConfig.fromTag);
- writeBakefileProposals(allProposals, buildConfig.platforms);
+ writeDockerfile(allProposals, buildConfig.fromTag, buildConfig.repositoryColon, buildConfig.sdkRepositoryColon);
+ writeBakefileProposals(allProposals, buildConfig.platforms, buildConfig.repositoryColon);
execSync4(`cp -r ${path4.resolve(publicDir, "upgrade-test-scripts")} .`);
buildProposalSubmissions(proposals);
execSync4(
diff --git a/dist/docker-bake.hcl b/dist/docker-bake.hcl
index c59a54224c101648c5507f451bfe0b2cb7f420a5..24ef27a882805df4a969a96ab28dad15b8ee5479 100755
--- a/dist/docker-bake.hcl
+++ b/dist/docker-bake.hcl
@@ -23,7 +23,7 @@
proposal = PROPOSALS
}
// TODO proposal *number* would be immutable
- tags = ["ghcr.io/agoric/agoric-3-proposals:use-${proposal}"]
+ tags = ["${REPOSITORY_COLON}use-${proposal}"]
labels = {
"org.opencontainers.image.title": "Use ${proposal}",
"org.opencontainers.image.description": "Use agoric-3 synthetic chain after ${proposal} proposal",
@@ -37,7 +37,7 @@
matrix = {
proposal = PROPOSALS
}
- tags = ["ghcr.io/agoric/agoric-3-proposals:test-${proposal}"]
+ tags = ["${REPOSITORY_COLON}test-${proposal}"]
labels = {
"org.opencontainers.image.title": "Test ${proposal}",
}
@@ -49,7 +49,7 @@
target "latest" {
inherits = ["docker-metadata-action"]
platforms = PLATFORMS
- tags = ["ghcr.io/agoric/agoric-3-proposals:latest"]
+ tags = ["${REPOSITORY_COLON}latest"]
labels = {
"org.opencontainers.image.title": "All passed proposals",
"org.opencontainers.image.description": "Use agoric-3 synthetic chain including all passed proposals",
2 changes: 1 addition & 1 deletion a3p-integration/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"doctor": "yarn synthetic-chain doctor"
},
"dependencies": {
"@agoric/synthetic-chain": "patch:@agoric/synthetic-chain@npm%3A0.1.0#~/.yarn/patches/@agoric-synthetic-chain-npm-0.1.0-148de716a6.patch",
"@agoric/synthetic-chain": "patch:@agoric/synthetic-chain@npm%3A0.1.1#~/.yarn/patches/@agoric-synthetic-chain-npm-0.1.1-d26a740f05.patch",
"@types/better-sqlite3": "^7.6.9"
},
"packageManager": "[email protected]",
Expand Down
Loading

0 comments on commit a083021

Please sign in to comment.