Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: DeterminateSystems/nix-installer-action
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: v6
Choose a base ref
...
head repository: DeterminateSystems/nix-installer-action
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: v7
Choose a head ref

Commits on Oct 18, 2023

  1. Copy the full SHA
    b124035 View commit details
  2. Copy the full SHA
    1cd89e7 View commit details
  3. Merge pull request #44 from colemickens/fixup-nix-url-check

    main.ts: fixup logic to ensure only one installer url override is set
    Hoverbear authored Oct 18, 2023
    Copy the full SHA
    df82330 View commit details

Commits on Oct 19, 2023

  1. Copy the full SHA
    e0fea1f View commit details
  2. Copy the full SHA
    58853de View commit details
  3. Copy the full SHA
    5c1457f View commit details
  4. Copy the full SHA
    c906fbe View commit details
  5. Merge pull request #46 from colemickens/retries

    Retry (w/ back-off) downloading the installer binary
    Hoverbear authored Oct 19, 2023
    Copy the full SHA
    ba1bee1 View commit details

Commits on Oct 23, 2023

  1. Add check for dist folder

    Hoverbear committed Oct 23, 2023
    Copy the full SHA
    bbcd1ef View commit details
  2. Copy the full SHA
    1ae92f0 View commit details
  3. Show more in report

    Hoverbear committed Oct 23, 2023
    Copy the full SHA
    4420be3 View commit details
  4. Nosave

    Hoverbear committed Oct 23, 2023
    Copy the full SHA
    0e429be View commit details
  5. npm options wrong post

    Hoverbear committed Oct 23, 2023
    Copy the full SHA
    3177c7d View commit details

Commits on Oct 24, 2023

  1. Merge pull request #48 from DeterminateSystems/add-dist-folder-checkl

    Add check for dist folder
    Hoverbear authored Oct 24, 2023
    Copy the full SHA
    a5a150b View commit details
  2. package-lock.json: include node-fetch removal

    I'm guessing this got dropped again as part of having multiple
    branches in flight and rebasing. It would be good if CI checked that
    `npm install` and `npm run build` resulted in *zero* diffs to validate
    that generated/lock files match their source at time of CI.
    colemickens committed Oct 24, 2023
    Copy the full SHA
    806550d View commit details
  3. Copy the full SHA
    4e0fccb View commit details
  4. Copy the full SHA
    663467b View commit details
  5. Copy the full SHA
    d46d5b1 View commit details
  6. Copy the full SHA
    bb22c86 View commit details
  7. Merge pull request #47 from DeterminateSystems/colemickens/fix-stream…

    …-close
    
    fix: end the FileStreamWriter for the installer file
    Hoverbear authored Oct 24, 2023
    Copy the full SHA
    721f94f View commit details

Commits on Nov 2, 2023

  1. Detected whether we're running in a Namespace runner, and if so, set …

    …`init: none`. (#52)
    
    Background: Namespace managed runners run each github job in a container, in a
    separate micro-vm managed by Namespace. These VMs and containers do not rely on
    systemd, and instead use Namespace's own init/process management.
    hugosantos authored Nov 2, 2023
    Copy the full SHA
    7fa8f59 View commit details
  2. Copy the full SHA
    8b5f066 View commit details

Commits on Nov 3, 2023

  1. Merge pull request #53 from DeterminateSystems/use-github-tool-cache-…

    …and-exec
    
    Use Github Actions provided tool cache and exec
    Hoverbear authored Nov 3, 2023
    Copy the full SHA
    5620eb4 View commit details
Showing with 15,551 additions and 14,784 deletions.
  1. +2 −1 .eslintrc.json
  2. +10 −0 .github/workflows/ci.yml
  3. +3 −0 CONTRIBUTING.md
  4. +14,558 −14,564 dist/index.js
  5. +1 −1 dist/index.js.map
  6. +752 −0 dist/licenses.txt
  7. +149 −125 package-lock.json
  8. +3 −1 package.json
  9. +69 −89 src/main.ts
  10. +4 −3 tsconfig.json
3 changes: 2 additions & 1 deletion .eslintrc.json
Original file line number Diff line number Diff line change
@@ -47,6 +47,7 @@
"@typescript-eslint/no-array-constructor": "error",
"@typescript-eslint/no-empty-interface": "error",
"@typescript-eslint/no-explicit-any": "error",
"@typescript-eslint/no-floating-promises": "error",
"@typescript-eslint/no-extraneous-class": "error",
"@typescript-eslint/no-for-in-array": "error",
"@typescript-eslint/no-inferrable-types": "error",
@@ -71,4 +72,4 @@
"node": true,
"es6": true
}
}
}
10 changes: 10 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -4,8 +4,18 @@ on:
pull_request:
push:
branches: [main]
workflow_dispatch:

jobs:
check-dist-up-to-date:
name: Check the dist/ folder is up to date
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v3
- run: npm install --no-save
- run: npm run all
- run: git status --porcelain=v1
- run: test $(git status --porcelain=v1 2>/dev/null | wc -l) -eq 0
run-x86_64-linux:
name: Run x86_64 Linux
runs-on: ubuntu-22.04
3 changes: 3 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Submitting Pull Requests

This action is based off https://github.com/actions/javascript-action. As part of your contributing flow you **must** run `npm run all` before we can merge.
29,122 changes: 14,558 additions & 14,564 deletions dist/index.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/index.js.map

Large diffs are not rendered by default.

752 changes: 752 additions & 0 deletions dist/licenses.txt

Large diffs are not rendered by default.

274 changes: 149 additions & 125 deletions package-lock.json

Large diffs are not rendered by default.

4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -23,8 +23,10 @@
"homepage": "https://github.com/DeterminateSystems/nix-installer-action#readme",
"dependencies": {
"@actions/core": "^1.10.0",
"@actions/exec": "^1.1.1",
"@actions/github": "^5.1.1",
"node-fetch": "^3.3.1",
"@actions/tool-cache": "^2.0.1",
"fetch-retry": "^5.0.6",
"string-argv": "^0.3.2"
},
"devDependencies": {
158 changes: 69 additions & 89 deletions src/main.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,10 @@
import * as actions_core from "@actions/core";
import * as github from "@actions/github";
import { mkdtemp, chmod, access, writeFile } from "node:fs/promises";
import { spawn } from "node:child_process";
import * as actions_tool_cache from "@actions/tool-cache";
import * as actions_exec from "@actions/exec";
import { chmod, access, writeFile } from "node:fs/promises";
import { randomUUID } from "node:crypto";
import { join } from "node:path";
import { tmpdir } from "node:os";
import { pipeline } from "node:stream";
import fetch from "node-fetch";
import { promisify } from "node:util";
import fs from "node:fs";
import stringArgv from "string-argv";

@@ -236,6 +233,13 @@ class NixInstallerAction {
execution_env.NIX_INSTALLER_INIT = "none";
}

if (process.env.NSC_VM_ID && !process.env.NOT_NAMESPACE) {
actions_core.info(
"Detected Namespace runner, assuming this is a https://namespace.so created container, set `NOT_NAMESPACE=true` to override this. This will change the setting of the `init` to be compatible with Namespace",
);
execution_env.NIX_INSTALLER_INIT = "none";
}

return execution_env;
}

@@ -257,33 +261,25 @@ class NixInstallerAction {
args.concat(extra_args);
}

const merged_env = {
...process.env, // To get $PATH, etc
...execution_env,
};

const spawned = spawn(`${binary_path}`, args, {
env: merged_env,
});

spawned.stdout.setEncoding("utf-8");
spawned.stdout.on("data", (data) => {
const trimmed = data.trimEnd();
if (trimmed.length >= 0) {
actions_core.info(trimmed);
}
});

spawned.stderr.setEncoding("utf-8");
spawned.stderr.on("data", (data) => {
const trimmed = data.trimEnd();
if (trimmed.length >= 0) {
actions_core.info(trimmed);
}
});

const exit_code: number = await new Promise((resolve, _reject) => {
spawned.on("close", resolve);
const exit_code = await actions_exec.exec(binary_path, args, {
env: {
...execution_env,
...process.env, // To get $PATH, etc
},
listeners: {
stdout: (data: Buffer) => {
const trimmed = data.toString("utf-8").trimEnd();
if (trimmed.length >= 0) {
actions_core.info(trimmed);
}
},
stderr: (data: Buffer) => {
const trimmed = data.toString("utf-8").trimEnd();
if (trimmed.length >= 0) {
actions_core.info(trimmed);
}
},
},
});

if (exit_code !== 0) {
@@ -359,32 +355,30 @@ class NixInstallerAction {
}

async execute_uninstall(): Promise<number> {
const spawned = spawn(`/nix/nix-installer`, ["uninstall"], {
env: {
NIX_INSTALLER_NO_CONFIRM: "true",
...process.env, // To get $PATH, etc
const exit_code = await actions_exec.exec(
`/nix/nix-installer`,
["uninstall"],
{
env: {
NIX_INSTALLER_NO_CONFIRM: "true",
...process.env, // To get $PATH, etc
},
listeners: {
stdout: (data: Buffer) => {
const trimmed = data.toString("utf-8").trimEnd();
if (trimmed.length >= 0) {
actions_core.info(trimmed);
}
},
stderr: (data: Buffer) => {
const trimmed = data.toString("utf-8").trimEnd();
if (trimmed.length >= 0) {
actions_core.info(trimmed);
}
},
},
},
});

spawned.stdout.setEncoding("utf-8");
spawned.stdout.on("data", (data) => {
const trimmed = data.trimEnd();
if (trimmed.length >= 0) {
actions_core.info(trimmed);
}
});

spawned.stderr.setEncoding("utf-8");
spawned.stderr.on("data", (data) => {
const trimmed = data.trimEnd();
if (trimmed.length >= 0) {
actions_core.info(trimmed);
}
});

const exit_code: number = await new Promise((resolve, _reject) => {
spawned.on("close", resolve);
});
);

if (exit_code !== 0) {
throw new Error(`Non-zero exit code of \`${exit_code}\` detected`);
@@ -408,32 +402,13 @@ class NixInstallerAction {
private async fetch_binary(): Promise<string> {
if (!this.local_root) {
actions_core.info(`Fetching binary from ${this.nix_installer_url}`);
const response = await fetch(this.nix_installer_url);
if (!response.ok) {
throw new Error(
`Got a status of ${response.status} from \`${this.nix_installer_url}\`, expected a 200`,
);
}

const tempdir = await mkdtemp(join(tmpdir(), "nix-installer-"));
const tempfile = join(tempdir, `nix-installer-${this.platform}`);

if (!response.ok) {
throw new Error(`unexpected response ${response.statusText}`);
}

if (response.body !== null) {
const streamPipeline = promisify(pipeline);
await streamPipeline(response.body, fs.createWriteStream(tempfile));
actions_core.info(`Downloaded \`nix-installer\` to \`${tempfile}\``);
} else {
throw new Error("No response body recieved");
}

const binaryPath = await actions_tool_cache.downloadTool(
String(this.nix_installer_url),
);
// Make executable
await chmod(tempfile, fs.constants.S_IXUSR | fs.constants.S_IXGRP);
await chmod(binaryPath, fs.constants.S_IXUSR | fs.constants.S_IXGRP);

return tempfile;
return binaryPath;
} else {
const local_path = join(
this.local_root,
@@ -597,25 +572,30 @@ function resolve_nix_installer_url(
resolved_nix_installer_url = new URL(
`https://install.determinate.systems/nix/branch/${nix_installer_branch}/nix-installer-${platform}?${url_suffix}`,
);
} else if (nix_installer_pr !== null) {
}
if (nix_installer_pr !== null) {
num_set += 1;
resolved_nix_installer_url = new URL(
`https://install.determinate.systems/nix/pr/${nix_installer_pr}/nix-installer-${platform}?${url_suffix}`,
);
} else if (nix_installer_revision !== null) {
}
if (nix_installer_revision !== null) {
num_set += 1;
resolved_nix_installer_url = new URL(
`https://install.determinate.systems/nix/rev/${nix_installer_revision}/nix-installer-${platform}?${url_suffix}`,
);
} else if (nix_installer_tag !== null) {
}
if (nix_installer_tag !== null) {
num_set += 1;
resolved_nix_installer_url = new URL(
`https://install.determinate.systems/nix/tag/${nix_installer_tag}/nix-installer-${platform}?${url_suffix}`,
);
} else if (nix_installer_url !== null) {
}
if (nix_installer_url !== null) {
num_set += 1;
resolved_nix_installer_url = new URL(nix_installer_url);
} else {
}
if (resolved_nix_installer_url == null) {
resolved_nix_installer_url = new URL(
`https://install.determinate.systems/nix/nix-installer-${platform}?${url_suffix}`,
);
@@ -674,11 +654,11 @@ async function main(): Promise<void> {
actions_core.saveState("isPost", "true");
await installer.install();
} else {
installer.report_overall();
await installer.report_overall();
}
} catch (error) {
if (error instanceof Error) actions_core.setFailed(error);
}
}

main();
await main();
7 changes: 4 additions & 3 deletions tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
{
"compilerOptions": {
"target": "es6", /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', 'ES2018', 'ES2019' or 'ESNEXT'. */
"module": "commonjs", /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', or 'ESNext'. */
"target": "es2017", /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', 'ES2018', 'ES2019' or 'ESNEXT'. */
"module": "esnext",
"moduleResolution": "node",
"outDir": "./lib", /* Redirect output structure to the directory. */
"rootDir": "./src", /* Specify the root directory of input files. Use to control the output directory structure with --outDir. */
"strict": true, /* Enable all strict type-checking options. */
@@ -12,4 +13,4 @@
"node_modules",
"**/*.test.ts"
]
}
}