Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Quick fix for failing windows runs #1150

Merged
merged 7 commits into from
Aug 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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