Skip to content

Commit

Permalink
Quick fix for failing windows runs (#1150)
Browse files Browse the repository at this point in the history
The new GitHub caching setup system (see #1146) is not working on Windows. The Wireit processes are unable to fetch from the local custodian server.

I'm not sure why yet, but in the meantime this release will make it non-fatal when GitHub caching fails to set up.

Also shows more info when a fetch error occurs, and fixes an issue with environment variable inheritance in our integration tests.
  • Loading branch information
aomarks authored Aug 5, 2024
1 parent d7d6267 commit 742c56b
Show file tree
Hide file tree
Showing 7 changed files with 51 additions and 29 deletions.
8 changes: 6 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,10 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic
Versioning](https://semver.org/spec/v2.0.0.html).

<!-- ## Unreleased -->
## [0.14.7] - 2024-08-05

- When GitHub caching fails to initialize, more information is now shown about
the error, and it is no longer fatal.

## [0.14.6] - 2024-08-05

Expand Down Expand Up @@ -614,7 +617,8 @@ Versioning](https://semver.org/spec/v2.0.0.html).
- Initial release.
[unreleased]: https://github.com/google/wireit/compare/v0.14.6...HEAD
[unreleased]: https://github.com/google/wireit/compare/v0.14.7...HEAD
[0.14.7]: https://github.com/google/wireit/compare/v0.14.6...v0.14.7
[0.14.6]: https://github.com/google/wireit/compare/v0.14.5...v0.14.6
[0.14.5]: https://github.com/google/wireit/compare/v0.14.4...v0.14.5
[0.14.4]: https://github.com/google/wireit/compare/v0.14.3...v0.14.4
Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "wireit",
"version": "0.14.6",
"version": "0.14.7",
"description": "Upgrade your npm scripts to make them smarter and more efficient",
"author": "Google LLC",
"license": "Apache-2.0",
Expand Down
3 changes: 2 additions & 1 deletion src/caching/github-actions-cache.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import '../util/dispose.js';
import {fileBudget} from '../util/fs.js';
import {execFile} from 'child_process';
import '../util/dispose.js';
import {inspect} from 'util';

import type * as http from 'http';
import type {Cache, CacheHit} from './cache.js';
Expand Down Expand Up @@ -105,7 +106,7 @@ export class GitHubActionsCache implements Cache {
reason: 'unknown-error-thrown',
error: new Error(
`Error communicating with cache token mediator service: ` +
String(error),
inspect(error),
),
},
};
Expand Down
22 changes: 11 additions & 11 deletions src/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,18 +31,18 @@ const run = async (options: Options): Promise<Result<void, Failure[]>> => {
'./caching/github-actions-cache.js'
);
const cacheResult = await GitHubActionsCache.create(logger);
if (!cacheResult.ok) {
return {
ok: false,
error: [
{
script: options.script,
...cacheResult.error,
},
],
};
if (cacheResult.ok) {
cache = cacheResult.value;
} else {
cache = undefined;
console.warn(
'⚠️ Error initializing GitHub cache. Caching is disabled for this run',
);
logger.log({
script: options.script,
...cacheResult.error,
});
}
cache = cacheResult.value;
break;
}
case 'none': {
Expand Down
24 changes: 18 additions & 6 deletions src/test/errors-usage.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -180,13 +180,16 @@ test(
test(
'github caching without ACTIONS_CACHE_URL',
rigTest(async ({rig}) => {
const cmd = await rig.newCommand();
await rig.write({
'package.json': {
scripts: {
main: 'wireit',
},
wireit: {
main: {command: (await rig.newCommand()).command},
main: {
command: cmd.command,
},
},
},
});
Expand All @@ -197,8 +200,9 @@ test(
ACTIONS_RUNTIME_TOKEN: 'token',
},
});
(await cmd.nextInvocation()).exit(0);
const done = await result.exit;
assert.equal(done.code, 1);
assert.equal(done.code, 0);
assert.match(
done.stderr,
`
Expand All @@ -210,13 +214,16 @@ test(
test(
'github caching but ACTIONS_CACHE_URL does not end in slash',
rigTest(async ({rig}) => {
const cmd = await rig.newCommand();
await rig.write({
'package.json': {
scripts: {
main: 'wireit',
},
wireit: {
main: {command: (await rig.newCommand()).command},
main: {
command: cmd.command,
},
},
},
});
Expand All @@ -227,8 +234,9 @@ test(
ACTIONS_RUNTIME_TOKEN: 'token',
},
});
(await cmd.nextInvocation()).exit(0);
const done = await result.exit;
assert.equal(done.code, 1);
assert.equal(done.code, 0);
assert.match(
done.stderr,
`
Expand All @@ -240,13 +248,16 @@ test(
test(
'github caching without ACTIONS_RUNTIME_TOKEN',
rigTest(async ({rig}) => {
const cmd = await rig.newCommand();
await rig.write({
'package.json': {
scripts: {
main: 'wireit',
},
wireit: {
main: {command: (await rig.newCommand()).command},
main: {
command: cmd.command,
},
},
},
});
Expand All @@ -257,8 +268,9 @@ test(
ACTIONS_RUNTIME_TOKEN: undefined,
},
});
(await cmd.nextInvocation()).exit(0);
const done = await result.exit;
assert.equal(done.code, 1);
assert.equal(done.code, 0);
assert.match(
done.stderr,
`
Expand Down
17 changes: 11 additions & 6 deletions src/test/util/test-rig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -168,17 +168,22 @@ export class WireitTestRig
this._assertState('running');
const cwd = this.#resolve(opts?.cwd ?? '.');
const result = new ExecResult(command, cwd, {
// GitHub Actions sets CI=true, but we want our tests to act like they are
// running locally by default, even when they are actually running on CI.
CI: undefined,
// Remove all WIREIT_ prefixed variables because we don't want our tests
// to inherit any configuration that is for our CI environment.
...Object.fromEntries(
Object.keys(process.env)
.filter((name) => name.startsWith('WIREIT_'))
.map((name) => [name, undefined]),
),
// We hard code the parallelism here because by default we infer a value
// based on the number of cores we find on the machine, but we want tests
// to behave as consistently as possible across machines.
WIREIT_PARALLEL: '10',
// GitHub Actions sets CI=true, but we want our tests to act like they are
// running locally by default, even when they are actually running on CI.
CI: undefined,
// Unset GitHub Actions caching environment variables that are set when we
// are running these tests in CI.
WIREIT_CACHE: undefined,
WIREIT_FAILURES: undefined,
// are running these tests in CI using the v1 version of the action.
ACTIONS_CACHE_URL: undefined,
ACTIONS_RUNTIME_TOKEN: undefined,
// In npm 6 (which ships with Node 14), "npm run" only includes the
Expand Down

0 comments on commit 742c56b

Please sign in to comment.