Skip to content

Commit

Permalink
Merge pull request #56 from ZettaScaleLabs/feat-publish-crates-debian…
Browse files Browse the repository at this point in the history
…-skip-in-test

feat: Support skipping instllation test in publish-crates-debian
  • Loading branch information
gabrik authored Mar 21, 2024
2 parents 8ef859d + ec3e8bb commit c1b8f13
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 28 deletions.
32 changes: 18 additions & 14 deletions dist/publish-crates-debian-main.js
Original file line number Diff line number Diff line change
Expand Up @@ -128538,19 +128538,21 @@ const publish_crates_debian_artifact = new artifact.DefaultArtifactClient();
const sourcesListName = "publish-crates-debian.list";
const sourcesListDir = "/etc/apt/sources.list.d";
function publish_crates_debian_setup() {
const liveRun = lib_core.getInput("live-run");
const liveRun = lib_core.getBooleanInput("live-run", { required: true });
const version = lib_core.getInput("version", { required: true });
const sshHost = lib_core.getInput("ssh-host", { required: true });
const sshHostPath = lib_core.getInput("ssh-host-path", { required: true });
const sshPrivateKey = lib_core.getInput("ssh-private-key", { required: true });
const sshPassphrase = lib_core.getInput("ssh-passphrase", { required: true });
const installationTest = lib_core.getBooleanInput("installation-test", { required: true });
return {
liveRun: liveRun == "" ? false : lib_core.getBooleanInput("live-run"),
liveRun,
version,
sshHost,
sshHostPath,
sshPrivateKey,
sshPassphrase,
installationTest
};
}
function gzip(input) {
Expand Down Expand Up @@ -128598,18 +128600,20 @@ async function publish_crates_debian_main(input) {
command_sh(`sudo cp ${sourcesListName} ${sourcesListDir}`);
command_sh(`cat ${sourcesListDir}/${sourcesListName}`);
command_sh("sudo apt-get update");
const debs = new Set();
for await (const dirent of await promises_.opendir(input.version)) {
const debPath = external_path_default().join(dirent.path, dirent.name);
const package_ = command_sh(`dpkg-deb --field ${debPath} Package`).trim();
debs.add(package_);
}
debs.forEach(deb => {
command_sh(`sudo apt-get install -y ${deb}`);
});
debs.forEach(deb => {
command_sh(`sudo dpkg --purge --force-all ${deb}`);
});
if (input.installationTest) {
const debs = new Set();
for await (const dirent of await promises_.opendir(input.version)) {
const debPath = external_path_default().join(dirent.path, dirent.name);
const package_ = command_sh(`dpkg-deb --field ${debPath} Package`).trim();
debs.add(package_);
}
debs.forEach(deb => {
command_sh(`sudo apt-get install -y ${deb}`);
});
debs.forEach(deb => {
command_sh(`sudo dpkg --purge --force-all ${deb}`);
});
}
if (input.liveRun) {
await withIdentity(input.sshPrivateKey, input.sshPassphrase, env => {
const files = [allPackagesGzippedPath, packagesPath, input.version].join(" ");
Expand Down
4 changes: 3 additions & 1 deletion publish-crates-debian/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: Publish crates (Debian)

inputs:
live-run:
required: false
required: true
version:
required: true
ssh-host:
Expand All @@ -13,6 +13,8 @@ inputs:
required: true
ssh-passphrase:
required: true
installation-test:
required: true

runs:
using: node20
Expand Down
33 changes: 20 additions & 13 deletions src/publish-crates-debian.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,23 +22,26 @@ export type Input = {
sshHostPath: string;
sshPrivateKey: string;
sshPassphrase: string;
installationTest: boolean;
};

export function setup(): Input {
const liveRun = core.getInput("live-run");
const liveRun = core.getBooleanInput("live-run", { required: true });
const version = core.getInput("version", { required: true });
const sshHost = core.getInput("ssh-host", { required: true });
const sshHostPath = core.getInput("ssh-host-path", { required: true });
const sshPrivateKey = core.getInput("ssh-private-key", { required: true });
const sshPassphrase = core.getInput("ssh-passphrase", { required: true });
const installationTest = core.getBooleanInput("installation-test", { required: true });

return {
liveRun: liveRun == "" ? false : core.getBooleanInput("live-run"),
liveRun,
version,
sshHost,
sshHostPath,
sshPrivateKey,
sshPassphrase,
installationTest
};
}

Expand Down Expand Up @@ -93,18 +96,22 @@ export async function main(input: Input) {
sh(`cat ${sourcesListDir}/${sourcesListName}`);
sh("sudo apt-get update");

const debs: Set<string> = new Set();
for await (const dirent of await fs.opendir(input.version)) {
const debPath = path.join(dirent.path, dirent.name);
const package_ = sh(`dpkg-deb --field ${debPath} Package`).trim();
debs.add(package_);
if (input.installationTest) {
const debs: Set<string> = new Set();
for await (const dirent of await fs.opendir(input.version)) {
const debPath = path.join(dirent.path, dirent.name);
const package_ = sh(`dpkg-deb --field ${debPath} Package`).trim();
debs.add(package_);
}

debs.forEach(deb => {
sh(`sudo apt-get install -y ${deb}`);
});

debs.forEach(deb => {
sh(`sudo dpkg --purge --force-all ${deb}`);
});
}
debs.forEach(deb => {
sh(`sudo apt-get install -y ${deb}`);
});
debs.forEach(deb => {
sh(`sudo dpkg --purge --force-all ${deb}`);
});

if (input.liveRun) {
await ssh.withIdentity(input.sshPrivateKey, input.sshPassphrase, env => {
Expand Down

0 comments on commit c1b8f13

Please sign in to comment.