Skip to content

Commit

Permalink
Merge pull request #137 from MatrixAI/feature-node-20
Browse files Browse the repository at this point in the history
Upgrade to Node 20
  • Loading branch information
amydevs authored Feb 26, 2024
2 parents 35d2cf1 + 654208d commit 5855f03
Show file tree
Hide file tree
Showing 14 changed files with 64 additions and 67 deletions.
1 change: 1 addition & 0 deletions .gitlab-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -248,6 +248,7 @@ integration:builds:
.#packages.x86_64-linux.executable \
.#packages.x86_64-windows.executable \
.#packages.x86_64-darwin.executable \
.#packages.aarch64-darwin.executable \
)";
cp -r $(echo $builds | tr '\n' ' ') ./builds/;
artifacts:
Expand Down
2 changes: 1 addition & 1 deletion flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@

shell = { ci ? false }: with pkgs; pkgs.mkShell {
nativeBuildInputs = [
nodejs
nodejs_20
prefetch-npm-deps
shellcheck
gitAndTools.gh
Expand Down
2 changes: 1 addition & 1 deletion npmDepsHash
Original file line number Diff line number Diff line change
@@ -1 +1 @@
sha256-zPxb3VUEeVjeWsIpBlszq3RWeZh3/0ICKRw/SyMCKsw=
sha256-buIzGNjR5CMM7BNlw5srJtVTSH/6Ru+UsMeXeNOjgZ4=
22 changes: 11 additions & 11 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
Expand Up @@ -116,7 +116,7 @@
"@types/node": "^20.5.7",
"@typescript-eslint/eslint-plugin": "^5.61.0",
"@typescript-eslint/parser": "^5.61.0",
"@yao-pkg/pkg": "^5.9.1",
"@yao-pkg/pkg": "^5.11.4",
"commander": "^8.3.0",
"cross-env": "^7.0.3",
"esbuild": "0.19.4",
Expand Down
4 changes: 2 additions & 2 deletions scripts/brew-install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,5 @@ export HOMEBREW_NO_INSTALLED_DEPENDENTS_CHECK=1
export HOMEBREW_NO_AUTO_UPDATE=1
export HOMEBREW_NO_ANALYTICS=1

brew reinstall node@18
brew link --overwrite node@18
brew reinstall node@20
brew link --overwrite node@20
6 changes: 3 additions & 3 deletions scripts/choco-install.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,10 @@ if ( $null -eq $env:ChocolateyInstall ) {
New-Item -Path "${PSScriptRoot}\..\tmp\chocolatey" -ItemType "directory" -ErrorAction:SilentlyContinue
choco source add --name="cache" --source="${PSScriptRoot}\..\tmp\chocolatey" --priority=1

# Install nodejs v18.15.0 (will use cache if exists)
# Install nodejs v20.5.1 (will use cache if exists)
$nodejs = "nodejs.install"
choco install "$nodejs" --version="18.15.0" --require-checksums -y
choco install "$nodejs" --version="20.5.1" --require-checksums -y
# Internalise nodejs to cache if doesn't exist
if ( -not (Test-Path -Path "${PSScriptRoot}\..\tmp\chocolatey\$nodejs\$nodejs.18.15.0.nupkg" -PathType Leaf) ) {
if ( -not (Test-Path -Path "${PSScriptRoot}\..\tmp\chocolatey\$nodejs\$nodejs.20.5.1.nupkg" -PathType Leaf) ) {
Save-ChocoPackage -PackageName $nodejs
}
17 changes: 7 additions & 10 deletions tests/identities/authenticateAuthenticated.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ describe('authenticate/authenticated', () => {
let exitCode: number;
// Authenticate
// Invalid provider
({ exitCode } = await testUtils.pkStdio(
({ exitCode } = await testUtils.pkExec(
['identities', 'authenticate', '', testToken.identityId],
{
env: {
Expand All @@ -133,16 +133,13 @@ describe('authenticate/authenticated', () => {
expect(exitCode).toBe(sysexits.USAGE);
// Authenticated
// Invalid provider
({ exitCode } = await testUtils.pkStdio(
['identities', 'authenticate', ''],
{
env: {
PK_NODE_PATH: nodePath,
PK_PASSWORD: password,
},
cwd: dataDir,
({ exitCode } = await testUtils.pkExec(['identities', 'authenticate', ''], {
env: {
PK_NODE_PATH: nodePath,
PK_PASSWORD: password,
},
));
cwd: dataDir,
}));
expect(exitCode).toBe(sysexits.USAGE);
});
});
6 changes: 3 additions & 3 deletions tests/identities/claim.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ describe('claim', () => {
// Expect(claim!.payload.data.type).toBe('identity');
});
test('cannot claim unauthenticated identities', async () => {
const { exitCode } = await testUtils.pkStdio(
const { exitCode } = await testUtils.pkExec(
[
'identities',
'claim',
Expand All @@ -122,7 +122,7 @@ describe('claim', () => {
test('should fail on invalid inputs', async () => {
let exitCode: number;
// Invalid provider
({ exitCode } = await testUtils.pkStdio(
({ exitCode } = await testUtils.pkExec(
['identities', 'claim', `:${testToken.identityId}`],
{
env: {
Expand All @@ -134,7 +134,7 @@ describe('claim', () => {
));
expect(exitCode).toBe(sysexits.USAGE);
// Invalid identity
({ exitCode } = await testUtils.pkStdio(
({ exitCode } = await testUtils.pkExec(
['identities', 'claim', `${testToken.providerId}:`],
{
env: {
Expand Down
4 changes: 2 additions & 2 deletions tests/identities/discoverGet.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,7 @@ describe('discover/get', () => {
});
test('should fail on invalid inputs', async () => {
// Discover
const { exitCode } = await testUtils.pkStdio(
const { exitCode } = await testUtils.pkExec(
['identities', 'discover', 'invalid'],
{
env: {
Expand All @@ -296,7 +296,7 @@ describe('discover/get', () => {
);
expect(exitCode).toBe(sysexits.USAGE);
// Get
await testUtils.pkStdio(['identities', 'get', 'invalid'], {
await testUtils.pkExec(['identities', 'get', 'invalid'], {
env: {
PK_NODE_PATH: nodePath,
PK_PASSWORD: password,
Expand Down
6 changes: 3 additions & 3 deletions tests/identities/search.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -361,7 +361,7 @@ describe('search', () => {
test('should fail on invalid inputs', async () => {
let exitCode: number;
// Invalid identity id
({ exitCode } = await testUtils.pkStdio(
({ exitCode } = await testUtils.pkExec(
['identities', 'search', '--identity-id', ''],
{
env: {
Expand All @@ -373,7 +373,7 @@ describe('search', () => {
));
expect(exitCode).toBe(sysexits.USAGE);
// Invalid auth identity id
({ exitCode } = await testUtils.pkStdio(
({ exitCode } = await testUtils.pkExec(
['identities', 'search', '--auth-identity-id', ''],
{
env: {
Expand All @@ -385,7 +385,7 @@ describe('search', () => {
));
expect(exitCode).toBe(sysexits.USAGE);
// Invalid value for limit
({ exitCode } = await testUtils.pkStdio(
({ exitCode } = await testUtils.pkExec(
['identities', 'search', '--limit', 'NaN'],
{
env: {
Expand Down
19 changes: 8 additions & 11 deletions tests/identities/trustUntrustList.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,7 @@ describe('trust/untrust/list', () => {
// belongs to and add it to our gestalt graph
// This command should fail first time as we need to allow time for the
// identity to be linked to a node in the node graph
({ exitCode } = await testUtils.pkStdio(
({ exitCode } = await testUtils.pkExec(
['identities', 'trust', providerString],
{
env: {
Expand Down Expand Up @@ -379,19 +379,16 @@ describe('trust/untrust/list', () => {
test('should fail on invalid inputs', async () => {
let exitCode: number;
// Trust
({ exitCode } = await testUtils.pkStdio(
['identities', 'trust', 'invalid'],
{
env: {
PK_NODE_PATH: nodePath,
PK_PASSWORD: password,
},
cwd: dataDir,
({ exitCode } = await testUtils.pkExec(['identities', 'trust', 'invalid'], {
env: {
PK_NODE_PATH: nodePath,
PK_PASSWORD: password,
},
));
cwd: dataDir,
}));
expect(exitCode).toBe(sysexits.USAGE);
// Untrust
({ exitCode } = await testUtils.pkStdio(
({ exitCode } = await testUtils.pkExec(
['identities', 'untrust', 'invalid'],
{
env: {
Expand Down
6 changes: 5 additions & 1 deletion tests/utils/exec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,9 @@ async function pk(args: Array<string>): Promise<any> {
* Runs pk command functionally with mocked STDIO
* Both stdout and stderr are the entire output including newlines
* This can only be used serially, because the mocks it relies on are global singletons
* If it is used concurrently, the mocking side effects can conflict
* If it is used concurrently, the mocking side effects can conflict.
* Note that because this does not launch Polykey in a subprocess, the `process.exitCode` of the main process is overriden.
* This should only be used for commands that are expected to exit with code 0.
*/
async function pkStdio(
args: Array<string> = [],
Expand All @@ -160,6 +162,7 @@ async function pkStdio(
stdout: string;
stderr: string;
}> {
const lastExitCode = process.exitCode;
const cwd =
opts.cwd ??
(await fs.promises.mkdtemp(path.join(globalThis.tmpDir, 'polykey-test-')));
Expand Down Expand Up @@ -221,6 +224,7 @@ async function pkStdio(
mockProcessAddListener.mockRestore();
mockProcessOnce.mockRestore();
mockProcessOn.mockRestore();
process.exitCode = lastExitCode;
return {
exitCode,
stdout,
Expand Down
34 changes: 16 additions & 18 deletions utils.nix
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
{ nix-gitignore
, linkFarm
, nodejs
, nodejs_20
, lib
, fetchurl
}:

rec {
nodeVersion = builtins.elemAt (lib.versions.splitVersion nodejs.version) 0;
nodeVersion = builtins.elemAt (lib.versions.splitVersion nodejs_20.version) 0;
# Filter source to only what's necessary for building
src = nix-gitignore.gitignoreSource [
# The `.git` itself should be ignored
Expand All @@ -33,22 +33,21 @@ rec {
pkgBuilds = {
"3.5" = {
"linux-x64" = fetchurl {
url = "https://github.com/yao-pkg/pkg-fetch/releases/download/v3.5/node-v18.15.0-linux-x64";
sha256 = "0pwbh2wxvkhl57s1fb2rivfjay963f00hz98kh5nvs4r2brl2a2p";
url = "https://github.com/yao-pkg/pkg-fetch/releases/download/v3.5/node-v20.11.1-linux-x64";
sha256 = "0f065bb2ccfdedaa7889e04604516604c2d0c0a0d9d13869578a6b3916b9a93e";
};
"win32-x64" = fetchurl {
url = "https://github.com/yao-pkg/pkg-fetch/releases/download/v3.5/node-v18.15.0-win-x64";
sha256 = "04brqm5avx8crfg28w706r0hkm8jx5gyadq9knq67s7jwd8x9j50";
url = "https://github.com/yao-pkg/pkg-fetch/releases/download/v3.5/node-v20.11.1-win-x64";
sha256 = "140c377c2c91751832e673cb488724cbd003f01aa237615142cd2907f34fa1a2";
};
"macos-x64" = fetchurl {
url = "https://github.com/yao-pkg/pkg-fetch/releases/download/v3.5/node-v18.15.0-macos-x64";
sha256 = "0xbqbd6bdfd7qbf94575103n2awndlnfv013mc92scvshl015ffx";
url = "https://github.com/yao-pkg/pkg-fetch/releases/download/v3.5/node-v20.11.1-macos-x64";
sha256 = "1558a49dfea01ae42702a71eaa1c7a6479abde8b2778bc7cb4f9a65d65a0afa6";
};
"macos-arm64" = fetchurl {
url = "https://github.com/yao-pkg/pkg-fetch/releases/download/v3.5/node-v20.11.1-macos-arm64";
sha256 = "1fa7f9e233820cfc5668ba21b70c463214f981fc69f1b8175b25dfa871451e26";
};
# No build for v18.15.0 macos-arm64 build
# "macos-arm64" = fetchurl {
# url = "";
# sha256 = "";
# };
};
};
pkgCachePath =
Expand All @@ -70,10 +69,9 @@ rec {
name = fetchedName pkgBuild.macos-x64.name;
path = pkgBuild.macos-x64;
}
# No build for v18.15 macos-arm64 build
# {
# name = fetchedName pkgBuild.macos-arm64.name;
# path = pkgBuild.macos-arm64;
# }
{
name = fetchedName pkgBuild.macos-arm64.name;
path = pkgBuild.macos-arm64;
}
];
}

0 comments on commit 5855f03

Please sign in to comment.