Skip to content

Commit

Permalink
fix(ci): Fix issue in CI running sample tests if latest release tag d…
Browse files Browse the repository at this point in the history
…oesnt belong to the main branch (#1596)
  • Loading branch information
mjameswh authored Jan 10, 2025
1 parent 2eb587b commit 8c68e0c
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 5 deletions.
10 changes: 7 additions & 3 deletions packages/create-project/src/helpers/install.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,9 +75,13 @@ export async function replaceSdkVersion({ root, sdkVersion }: InstallArgs): Prom
const fileName = `${root}/package.json`;

const packageJson = JSON.parse(await readFile(fileName, 'utf8'));
for (const packageName in packageJson.dependencies) {
if (packageName.startsWith('@temporalio/')) {
packageJson.dependencies[packageName] = sdkVersion;
for (const depType of ['dependencies', 'devDependencies', 'peerDependencies']) {
if (packageJson[depType]) {
for (const packageName in packageJson[depType]) {
if (packageName.startsWith('@temporalio/')) {
packageJson[depType][packageName] = sdkVersion;
}
}
}
}
await writeFile(fileName, JSON.stringify(packageJson, null, 2));
Expand Down
11 changes: 10 additions & 1 deletion scripts/init-from-verdaccio.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,16 @@ async function main() {
console.log('spawning npx @temporalio/create with args:', initArgs);
try {
const npmConfigFile = resolve(registryDir, 'npmrc-custom');
const npmConfig = `@temporalio:registry=http://127.0.0.1:4873`;
let npmConfig = `@temporalio:registry=http://127.0.0.1:4873`;

if (!process.env?.['CI']) {
// When testing on dev's local machine, uses an isolated NPM cache directory to avoid mixing
// existing @temporalio/* cached packages with the ones from the local registry. We don't do
// that in CI though, as it is not needed (i.e. there should be no such cached packages yet)
// and would slow down the tests (i.e. it requires redownloading ALL packages).
npmConfig += `\ncache=${resolve(registryDir, 'npm-cache')}`;
}

writeFileSync(npmConfigFile, npmConfig, { encoding: 'utf-8' });

await spawnNpx(
Expand Down
2 changes: 1 addition & 1 deletion scripts/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,4 +50,4 @@ async function spawnNpx(args, opts) {
await waitOnChild(spawn(npx, npxArgs, { ...opts, shell }));
}

module.exports = { kill, spawnNpx, ChildProcessError, shell, sleep };
module.exports = { kill, spawnNpx, waitOnChild, ChildProcessError, shell, sleep };

0 comments on commit 8c68e0c

Please sign in to comment.