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 5, 2024
1 parent 6656ea0 commit 34ae743
Show file tree
Hide file tree
Showing 4 changed files with 155 additions and 15 deletions.
20 changes: 9 additions & 11 deletions .github/workflows/docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -194,21 +194,18 @@ 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:"
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
Expand Down Expand Up @@ -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
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
diff --git a/dist/upgrade-test-scripts/env_setup.sh b/dist/upgrade-test-scripts/env_setup.sh
index 617a0fbe7efdfa457e28fc52806dba1b323930d8..25f52a6cf133dca830bd0dcd47c91700e6a8effe 100755
index 53bad1db0fcafa8a64727fe635ba6fdfac63a464..7eea07fc5fa5f4b4221d04fafa28ea3aaacce858 100755
--- a/dist/upgrade-test-scripts/env_setup.sh
+++ b/dist/upgrade-test-scripts/env_setup.sh
@@ -100,7 +100,7 @@ killAgd() {
Expand All @@ -11,3 +11,145 @@ index 617a0fbe7efdfa457e28fc52806dba1b323930d8..25f52a6cf133dca830bd0dcd47c91700
}

provisionSmartWallet() {
diff --git a/dist/cli/cli.js b/dist/cli/cli.js
index 53bad1db0fcafa8a64727fe635ba6fdfac63a464..7eea07fc5fa5f4b4221d04fafa28ea3aaacce858 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");
@@ -64,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(),
@@ -106,7 +107,7 @@ function readProposals(proposalsParent) {
function imageNameForProposal(proposal, stage2) {
const target = `${stage2}-${proposal.proposalName}`;
return {
- name: `${repository}:${target}`,
+ name: `${repositoryColon}${target}`,
target
};
}
@@ -141,10 +142,10 @@ RUN /usr/src/upgrade-test-scripts/run_prepare_zero.sh
* Resume from state of an existing image.
* Creates a "use" stage upon which a PREPARE or EVAL can stack.
*/
- RESUME(fromTag) {
+ RESUME(fromTag, repositoryColon) {
return `
## RESUME
-FROM ghcr.io/agoric/agoric-3-proposals:${fromTag} as use-${fromTag}
+FROM ${repositoryColon}${fromTag} as use-${fromTag}
`;
},
/**
@@ -184,10 +185,10 @@ RUN ./run_prepare.sh ${path5}
planName,
proposalName,
sdkImageTag
- }) {
+ }, sdkRepositoryColon) {
return `
# EXECUTE ${proposalName}
-FROM ghcr.io/agoric/agoric-sdk:${sdkImageTag} as execute-${proposalName}
+FROM ${sdkRepositoryColon}${sdkImageTag} as execute-${proposalName}

WORKDIR /usr/src/upgrade-test-scripts

@@ -274,7 +275,7 @@ FROM ${useImage} as latest
`;
}
};
-function writeBakefileProposals(allProposals2, platforms) {
+function writeBakefileProposals(allProposals2, platforms, repositoryColon) {
const json = {
variable: {
PLATFORMS: {
@@ -282,16 +283,19 @@ function writeBakefileProposals(allProposals2, platforms) {
},
PROPOSALS: {
default: allProposals2.map((p) => p.proposalName)
- }
+ },
+ REPOSITORY_COLON: {
+ default: repositoryColon
+ },
}
};
fs3.writeFileSync("docker-bake.json", JSON.stringify(json, null, 2));
}
-function writeDockerfile(allProposals2, fromTag) {
+function writeDockerfile(allProposals2, fromTag, repositoryColon, sdkRepositoryColon) {
- const blocks = ["# syntax=docker/dockerfile:1.4"];
+ const blocks = ["# syntax=docker/dockerfile:1.4\nARG SDK_TAG"];
let previousProposal = null;
if (fromTag) {
- blocks.push(stage.RESUME(fromTag));
+ blocks.push(stage.RESUME(fromTag, repositoryColon));
previousProposal = {
proposalName: fromTag,
proposalIdentifier: fromTag,
@@ -320,7 +324,7 @@ function writeDockerfile(allProposals2, fromTag) {
stage.PREPARE_ZERO(proposal.proposalName, proposal.planName)
);
}
- blocks.push(stage.EXECUTE(proposal));
+ blocks.push(stage.EXECUTE(proposal, sdkRepositoryColon));
break;
default:
throw new Error(`unsupported proposal type ${proposal.type}`);
@@ -476,8 +480,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 75d25cb8e071473b18cc9ea9517b6f4e59f17518..7f54a014b517f82b224e4ec9af68ca55e392b90b 100644
--- a/dist/docker-bake.hcl
+++ b/dist/docker-bake.hcl
@@ -23,7 +23,7 @@ target "use" {
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 @@ target "test" {
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 "test" {
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/proposals/e:upgrade-next/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"agoricProposal": {
"releaseNotes": false,
"sdkImageTag": "unreleased",
"sdkImageTag": "${SDK_TAG:-unreleased}",
"planName": "UNRELEASED_A3P_INTEGRATION",
"upgradeInfo": {
"coreProposals": []
Expand Down
4 changes: 2 additions & 2 deletions a3p-integration/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,15 @@ __metadata:

"@agoric/synthetic-chain@patch:@agoric/synthetic-chain@npm%3A0.1.0#~/.yarn/patches/@agoric-synthetic-chain-npm-0.1.0-148de716a6.patch":
version: 0.1.0
resolution: "@agoric/synthetic-chain@patch:@agoric/synthetic-chain@npm%3A0.1.0#~/.yarn/patches/@agoric-synthetic-chain-npm-0.1.0-148de716a6.patch::version=0.1.0&hash=4a65eb"
resolution: "@agoric/synthetic-chain@patch:@agoric/synthetic-chain@npm%3A0.1.0#~/.yarn/patches/@agoric-synthetic-chain-npm-0.1.0-148de716a6.patch::version=0.1.0&hash=4dc383"
dependencies:
"@endo/zip": "npm:^1.0.1"
better-sqlite3: "npm:^9.4.0"
chalk: "npm:^5.3.0"
execa: "npm:^8.0.1"
bin:
synthetic-chain: dist/cli/cli.js
checksum: 10c0/e974038161b1a9570912a02d9366c6680bc13ee3dfd0e49d06e5ce5e93dbcddf04d1d4cd453af0969bf29ccfe96ce3e141a214539722449add90b13f0785f1f7
checksum: 10c0/125ef8963e1a0b1c60d1ebc12b005f122e48a073f43d6a664ab4bc547700022007c60fb47a65b7f6ebf75bc1ccf99fc55d78abb2a643068ccee7556f9806ce4b
languageName: node
linkType: hard

Expand Down

0 comments on commit 34ae743

Please sign in to comment.