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

Prepare to release v0.12.0 #854

Merged
merged 4 commits into from
Sep 1, 2023
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
6 changes: 6 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,12 @@ jobs:
os: macos-12
- node: 19
os: windows-2022
- node: 20
os: ubuntu-22.04
- node: 20
os: macos-12
- node: 20
os: windows-2022

# Allow all matrix configurations to complete, instead of cancelling as
# soon as one fails. Useful because we often have different kinds of
Expand Down
4 changes: 3 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@ Versioning](https://semver.org/spec/v2.0.0.html).

<!-- ## [Unreleased] -->

## [Unreleased]
<!-- ## [Unreleased] -->

## [0.12.0] - 2023-09-01

## Added

Expand Down
14 changes: 7 additions & 7 deletions package-lock.json

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

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "wireit",
"version": "0.11.0",
"version": "0.12.0",
"description": "Upgrade your npm scripts to make them smarter and more efficient",
"author": "Google LLC",
"license": "Apache-2.0",
Expand Down Expand Up @@ -429,7 +429,7 @@
"vscode-languageclient": "^8.0.1",
"vscode-languageserver": "^8.0.1",
"vscode-languageserver-textdocument": "^1.0.4",
"wireit": "^0.11.0",
"wireit": "^0.10.0",
"yarn": "^1.22.18"
},
"prettier": {
Expand Down
31 changes: 22 additions & 9 deletions src/caching/github-actions-cache.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ import * as https from 'https';
import {createHash} from 'crypto';
import {scriptReferenceToString} from '../config.js';
import {getScriptDataDir} from '../util/script-data-dir.js';
import '../util/dispose.js';
import {fileBudget} from '../util/fs.js';
import {execFile} from 'child_process';

import type * as http from 'http';
Expand All @@ -20,7 +22,6 @@ import type {Fingerprint} from '../fingerprint.js';
import type {Logger} from '../logging/logger.js';
import type {AbsoluteEntry} from '../util/glob.js';
import type {Result} from '../error.js';
import {fileBudget} from '../util/fs.js';

/**
* Caches script output to the GitHub Actions caching service.
Expand Down Expand Up @@ -119,7 +120,8 @@ export class GitHubActionsCache implements Cache {
url.searchParams.set('keys', key);
url.searchParams.set('version', version);

const {req, resPromise} = this._request(url);
using requestResult = this._request(url);
const {req, resPromise} = requestResult;
req.end();
const result = await resPromise;
if (!this._maybeHandleServiceDown(result, script)) {
Expand Down Expand Up @@ -261,7 +263,8 @@ export class GitHubActionsCache implements Cache {
'content-range': `bytes ${start}-${end}/*`,
},
};
const {req, resPromise} = this._request(url, opts);
using requestResult = this._request(url, opts);
const {req, resPromise} = requestResult;
tarballChunkStream.pipe(req);
tarballChunkStream.on('close', () => {
req.end();
Expand Down Expand Up @@ -306,12 +309,13 @@ export class GitHubActionsCache implements Cache {
const reqBody = JSON.stringify({
size: tarballBytes,
});
const {req, resPromise} = this._request(url, {
using requestResult = this._request(url, {
method: 'POST',
headers: {
'content-type': 'application/json',
},
});
const {req, resPromise} = requestResult;
req.end(reqBody);

const result = await resPromise;
Expand All @@ -337,7 +341,7 @@ export class GitHubActionsCache implements Cache {
): {
req: http.ClientRequest;
resPromise: Promise<Result<http.IncomingMessage, Error>>;
} {
} & Disposable {
return request(url, {
...options,
headers: {
Expand Down Expand Up @@ -511,12 +515,13 @@ export class GitHubActionsCache implements Cache {
version,
cacheSize,
});
const {req, resPromise} = this._request(url, {
using requestResult = this._request(url, {
method: 'POST',
headers: {
'content-type': 'application/json',
},
});
const {req, resPromise} = requestResult;
req.end(reqBody);

const result = await resPromise;
Expand Down Expand Up @@ -571,7 +576,8 @@ class GitHubActionsCacheHit implements CacheHit {
}

private async _download(tarballPath: string): Promise<void> {
const {req, resPromise} = request(this._url);
using requestResult = request(this._url);
const {req, resPromise} = requestResult;
req.end();
const result = await resPromise;
if (!result.ok) {
Expand Down Expand Up @@ -617,7 +623,7 @@ function request(
): {
req: http.ClientRequest;
resPromise: Promise<Result<http.IncomingMessage, Error>>;
} {
} & Disposable {
const opts = {
...options,
headers: {
Expand Down Expand Up @@ -647,7 +653,14 @@ function request(
});
},
);
return {req, resPromise};
return {
req,
resPromise,
[Symbol.dispose]() {
req.destroy();
req.socket?.destroy();
},
};
}

function isOk(res: http.IncomingMessage): boolean {
Expand Down
9 changes: 1 addition & 8 deletions src/logging/quiet/writeover-line.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,7 @@
*/

import {DEBUG} from '../logger.js';

// Quick Symbol.dispose polyfill.
if (!Symbol.dispose) {
type Writeable<T> = {-readonly [P in keyof T]: T[P]};
(Symbol as Writeable<typeof Symbol>).dispose = Symbol(
'dispose',
) as typeof Symbol.dispose;
}
import '../../util/dispose.js';

export interface StatusLineWriter {
clearAndStopRendering(): void;
Expand Down
1 change: 0 additions & 1 deletion src/test/util/check-script-output.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ export function checkScriptOutput(
}
}
}
console.log(actual);
const assertOutputEqualish =
NODE_MAJOR_VERSION < 16 ? assert.match : assert.equal;
assertOutputEqualish(actual, expected, message);
Expand Down
15 changes: 15 additions & 0 deletions src/util/dispose.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
/**
* @license
* Copyright 2023 Google LLC
* SPDX-License-Identifier: Apache-2.0
*/

// Quick Symbol.dispose polyfill.
if (!Symbol.dispose) {
type Writeable<T> = {-readonly [P in keyof T]: T[P]};
(Symbol as Writeable<typeof Symbol>).dispose = Symbol(
'dispose',
) as typeof Symbol.dispose;
}

export {};
11 changes: 1 addition & 10 deletions src/util/fs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import {
createWriteStream as rawCreateWriteStream,
} from 'fs';
import {Deferred} from './deferred.js';
import './dispose.js';
export {constants} from 'fs';

declare global {
Expand All @@ -22,16 +23,6 @@ declare global {
}
}

// The interface for https://github.com/tc39/proposal-explicit-resource-management
// Once we're on TS 5.2 we can write a lot of this with `using` syntax.
interface Disposable {
[Symbol.dispose](): void;
}

// Polyfill Symbol.dispose.
// eslint-disable-next-line
(Symbol as any).dispose ??= Symbol('Symbol.dispose');

export class Semaphore {
#remaining: number;
readonly #waiting: Deferred<void>[] = [];
Expand Down