Skip to content
This repository was archived by the owner on Sep 8, 2025. It is now read-only.
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
25 changes: 25 additions & 0 deletions .github/workflows/_lint.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
name: Lint

on: [push]

jobs:
lint:
runs-on: ubuntu-22.04
timeout-minutes: 10

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Use Node.js
uses: actions/setup-node@v4
with:
node-version: '18.x'

- name: Clean install a project
run: npm ci

- name: Lint
run: |
npm run lint
npm run format:check
19 changes: 19 additions & 0 deletions .github/workflows/_test_e2e_install.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
name: Test e2e install

on: [push]

jobs:
test-e2e-install:
runs-on: ubuntu-22.04
timeout-minutes: 10

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Install trdl
uses: ./install

- name: Use trdl binary
run: |
trdl --help
26 changes: 26 additions & 0 deletions .github/workflows/_test_e2e_setup-app_manual.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: Test e2e setup-app manually

on: [push]

jobs:
test-e2e-setup-app-manually:
runs-on: ubuntu-22.04
timeout-minutes: 10

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Setup application
uses: ./setup-app
with:
repo: kubedog
url: https://tuf.kubedog.werf.io
root-version: 12
root-sha512: 6462a80292eb6d7712d8a18126366511f9c47a566f121a7745cfd68b624dc340b6591c2cadfe20690eb38296c399a3f4e6948aca90be60e446ed05c3c238294c
group: 0
# channel: stable # optional param

- name: Use kubedog binary
run: |
kubedog --help
21 changes: 21 additions & 0 deletions .github/workflows/_test_e2e_setup-app_preset.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
name: Test e2e setup-app preset

on: [push]

jobs:
test-e2e-setup-app-preset:
runs-on: ubuntu-22.04
timeout-minutes: 10

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Setup application
uses: ./setup-app
with:
preset: werf

- name: Use werf binary
run: |
werf --help
23 changes: 23 additions & 0 deletions .github/workflows/_test_unit.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
name: Test Unit

on: [push]

jobs:
test-unit:
runs-on: ubuntu-22.04
timeout-minutes: 10

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Use Node.js
uses: actions/setup-node@v4
with:
node-version: '18.x'

- name: Clean install a project
run: npm ci

- name: Test Unit
run: npm run test
95 changes: 52 additions & 43 deletions install/dist/index.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import require$$0$9 from 'diagnostics_channel';
import require$$2$2 from 'child_process';
import require$$6$1 from 'timers';
import { chmodSync } from 'node:fs';
import { join } from 'node:path';

var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};

Expand Down Expand Up @@ -29826,7 +29827,7 @@ async function execOutput(commandLine, args, options) {
const stderr = [];
const defaultOptions = {
// https://github.com/actions/toolkit/blob/%40actions/exec%401.0.1/packages/exec/src/interfaces.ts#L39
silent: true,
silent: false,
failOnStdErr: true,
listeners: {
stdline(data) {
Expand Down Expand Up @@ -29857,27 +29858,19 @@ class GpgCli {
}
}
async import(ascPath) {
await execOutput(this.name, ['--import', ascPath]);
await execOutput(this.name, ['--import', ascPath], { failOnStdErr: false });
}
async verify(sigPath, binPath) {
await execOutput(this.name, ['--verify', sigPath, binPath]);
await execOutput(this.name, ['--verify', sigPath, binPath], { failOnStdErr: false });
}
async help() {
const { stdout } = await execOutput(this.name, ['--help']);
return stdout.join('');
const { stdout } = await execOutput(this.name, ['--help'], { silent: true });
return stdout.join('\n');
}
}

var ioExports = requireIo();

// optional array element
function optionalToArray(arg) {
return arg ? [arg] : [];
}
function optionalToObject(key, value) {
return value ? { [key]: value } : {};
}

class TrdlCli {
name;
constructor() {
Expand Down Expand Up @@ -29905,43 +29898,52 @@ class TrdlCli {
async update(args, opts) {
const { repo, group, channel } = args;
const env = { ...process.env, ...(opts && toUpdateEnvs(opts)) };
await execOutput(this.name, ['update', repo, group, ...optionalToArray(channel)], { env });
const channelOpt = channel !== undefined ? [channel] : []; // optional field
await execOutput(this.name, ['update', repo, group, ...channelOpt], { env });
}
async binPath(args) {
const { repo, group, channel } = args;
const execOpts = {
failOnStdErr: false,
ignoreReturnCode: true
};
const { stdout } = await execOutput(this.name, ['bin-path', repo, group, ...optionalToArray(channel)], execOpts);
const channelOpt = channel !== undefined ? [channel] : []; // optional field
const { stdout } = await execOutput(this.name, ['bin-path', repo, group, ...channelOpt], execOpts);
return stdout.join('');
}
async list() {
const { stdout } = await execOutput(this.name, ['list']);
return stdout.slice(1).map(parseLineToItem);
}
async version() {
const { stdout } = await execOutput(this.name, ['version']);
return stdout.join('');
}
}
function parseLineToItem(line) {
const [name, url, default_, channel] = line.split(/ +/);
const [name, url, default_, channel] = line.trim().split(/ +/);
return {
name,
url,
default: default_,
channel
...(channel !== undefined ? { channel } : {}) // optional field
};
}
function toUpdateEnvs(opts) {
const env = {};
if (opts?.inBackground) {
// eslint-disable-next-line no-prototype-builtins
if (opts.hasOwnProperty('inBackground')) {
env['TRDL_IN_BACKGROUND'] = String(opts.inBackground);
}
return env;
}

function parseInputs() {
const channel = coreExports.getInput('channel');
const version = coreExports.getInput('version');
return {
...optionalToObject('channel', coreExports.getInput('channel')), // optional field
...optionalToObject('version', coreExports.getInput('version')) // optional field
...(channel !== '' ? { channel } : {}), // optional field
...(version !== '' ? { version } : {}) // optional field
};
}
async function fetchVersion(group, channel) {
Expand All @@ -29951,8 +29953,8 @@ async function fetchVersion(group, channel) {
return version.trim();
}
async function getOptions(inputs, defaults) {
const channel = inputs?.channel || defaults.channel;
const version = inputs?.version || await fetchVersion(defaults.group, defaults.channel); // prettier-ignore
const channel = inputs.channel ?? defaults.channel;
const version = inputs.version ?? await fetchVersion(defaults.group, defaults.channel); // prettier-ignore
return {
channel,
version
Expand Down Expand Up @@ -30001,48 +30003,55 @@ async function downloadParallel(binUrl, sigUrl, ascUrl) {
function findTrdlCache(toolName, toolVersion) {
return toolCacheExports.find(toolName, toolVersion);
}
async function installTrdl(toolName, toolVersion, binPath) {
async function installTrdl(binPath, toolName, toolVersion) {
// install tool
const installedPath = await toolCacheExports.cacheFile(binPath, toolName, toolName, toolVersion);
// set permissions
chmodSync(installedPath, 0o755);
const cachedPath = await toolCacheExports.cacheFile(binPath, toolName, toolName, toolVersion);
// add tool to $PATH
coreExports.addPath(installedPath);
coreExports.addPath(cachedPath);
const cachedFile = join(cachedPath, toolName);
// set permissions
chmodSync(cachedFile, 0o755);
}
async function Run() {
const trdlCli = new TrdlCli();
const gpgCli = new GpgCli();
const inputs = parseInputs();
await Do(trdlCli, inputs);
await Do(trdlCli, gpgCli, inputs);
}
async function Do(trdlCli, inputs) {
coreExports.startGroup('Install or self-update trdl.');
coreExports.debug(format(`parsed inputs=%o`, inputs));
async function Do(trdlCli, gpgCli, inputs) {
coreExports.startGroup(`Install or self-update ${trdlCli.name}.`);
coreExports.info(format(`Parsed inputs=%o`, inputs));
const defaults = trdlCli.defaults();
coreExports.debug(format(`trdl defaults=%o`, defaults));
coreExports.info(format(`${trdlCli.name} repository defaults=%o`, defaults));
const options = await getOptions(inputs, defaults);
coreExports.debug(format(`installation options=%o`, options));
const toolCache = findTrdlCache(defaults.repo, options.version);
coreExports.info(format(`${trdlCli.name} installation options=%o`, options));
const toolCache = findTrdlCache(trdlCli.name, options.version);
if (toolCache) {
coreExports.info(`Installation skipped. trdl@v${options.version} is found at path ${toolCache}.`);
coreExports.info(`Installation skipped. ${trdlCli.name}@v${options.version} is found in tool cache ${toolCache}.`);
await trdlCli.mustExist();
coreExports.info(`Updating trdl to group=${defaults.group} and channel=${defaults.channel}`);
coreExports.info(`Checking ${trdlCli.name} version before updating.`);
await trdlCli.version();
coreExports.info(`Updating ${trdlCli.name} to group=${defaults.group} and channel=${defaults.channel}.`);
await trdlCli.update(defaults);
coreExports.info(`Checking ${trdlCli.name} version after updating.`);
await trdlCli.version();
coreExports.endGroup();
return;
}
const gpgCli = new GpgCli();
await gpgCli.mustGnuGP();
const [binUrl, sigUrl, ascUrl] = formatDownloadUrls(options.version);
coreExports.debug(format('%s bin_url=%s', defaults.repo, binUrl));
coreExports.debug(format('%s sig_url=%s', defaults.repo, sigUrl));
coreExports.debug(format('%s asc_url=%s', defaults.repo, ascUrl));
coreExports.info('Downloading signatures.');
coreExports.info(`${trdlCli.name} binUrl=${binUrl}`);
coreExports.info(`${trdlCli.name} sigUrl=${sigUrl}`);
coreExports.info(`${trdlCli.name} ascUrl=${ascUrl}`);
coreExports.info('Downloading binary and signatures.');
const [binPath, sigPath, ascPath] = await downloadParallel(binUrl, sigUrl, ascUrl);
coreExports.info('Importing and verifying gpg keys.');
await gpgCli.import(ascPath);
await gpgCli.verify(sigPath, binPath);
coreExports.info('Installing trdl and adding it to the $PATH.');
await installTrdl(defaults.repo, options.version, binPath);
coreExports.info(`Installing ${trdlCli.name} and adding it to the $PATH.`);
await installTrdl(binPath, trdlCli.name, options.version);
coreExports.info(`Checking installed ${trdlCli.name} version.`);
await trdlCli.version();
coreExports.endGroup();
}

Expand Down
2 changes: 1 addition & 1 deletion install/dist/index.mjs.map

Large diffs are not rendered by default.

Loading