Skip to content

Commit

Permalink
feat: improve (reduce) cache invalidation
Browse files Browse the repository at this point in the history
  • Loading branch information
turadg committed Feb 6, 2024
1 parent a3bf156 commit 18db885
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
9 changes: 8 additions & 1 deletion packages/synthetic-chain/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,11 +55,18 @@ doctor - diagnostics and quick fixes
*/
const prepareDockerBuild = () => {
const cliPath = new URL(import.meta.url).pathname;
execSync(`cp -r ${path.resolve(cliPath, '..', 'upgrade-test-scripts')} .`);
// copy and generate files of the build context that aren't in the build contents
execSync(`cp -r ${path.resolve(cliPath, '..', 'docker-bake.hcl')} .`);
writeDockerfile(allProposals, buildConfig.fromTag);
writeBakefileProposals(allProposals);
// copy and generate files to include in the build
execSync(`cp -r ${path.resolve(cliPath, '..', 'upgrade-test-scripts')} .`);
buildProposalSubmissions(proposals);
// set timestamp of build content to zero to avoid invalidating the build cache
// (change in contents will still invalidate)
execSync(
'find upgrade-test-scripts -type f -exec touch -t 197001010000 {} +',
);
};

switch (cmd) {
Expand Down
2 changes: 2 additions & 0 deletions packages/synthetic-chain/src/cli/build.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,8 @@ export const buildProposalSubmissions = (proposals: ProposalInfo[]) => {
for (const { fileName } of plan.bundles) {
// Copy the bundle into the submission path.
execSync(`cp ${fileName} ${submissionPath}`);
// Set timestamp to zero to avoid invalidating the build cache
execSync(`touch -t 197001010000 ${submissionPath}/${fileName}`);
}
}
};
Expand Down

0 comments on commit 18db885

Please sign in to comment.