Skip to content
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
24 changes: 14 additions & 10 deletions actions/rsync-cache/dist/commit.js
Original file line number Diff line number Diff line change
Expand Up @@ -30796,11 +30796,6 @@ class Rsync {
this.ssh_user = this.core.getInput("ssh_user", { required: true });
this.ssh_dir = `${this.ssh_user}@${this.ssh_host}:${this.name}/${this.key}/`;

// Add a trailing slash to the path if necessary.
if (!this.path.match(/\/$/)) {
this.path += "/";
}

this._validate();
this._set_vars();
}
Expand All @@ -30811,6 +30806,9 @@ class Rsync {
this.ssh_port = "22";
}

// NOTE: We require absolute paths for security, but due to
// Windows paths having a colon we need to use relative paths in
// the command we run.
if (!path$1.isAbsolute(this.path)) {
throw new Error(`path to cache must be absolute: ${this.path}`);
}
Expand Down Expand Up @@ -30866,7 +30864,11 @@ class Rsync {
await this.fs.chmod(this.ssh_key_file, 0o600);

// Run rsync.
const options = { ignoreReturnCode: true };
const options = {
ignoreReturnCode: true,
cwd: path$1.dirname(this.path),
};

exit_code = await this.exec.exec(
this.command,
[...this.args, ...additional_arguments],
Expand All @@ -30886,16 +30888,18 @@ class Rsync {
async fetch_only() {
this.core.notice(`Falling back to HTTP fetch...`);

await this.io.mkdirP(this.path);

const exit_code = await this.exec.exec(
"rclone",
[
"copy",
"--http-url",
`https://archive.openms.de/openms/${this.name}/${this.key}`,
":http:",
this.path,
path$1.dirname(this.path),
],
{ ignoreReturnCode: true },
{ ignoreReturnCode: true, cwd: path$1.dirname(this.path) },
);

return exit_code;
Expand All @@ -30910,7 +30914,7 @@ class Rsync {
} else {
const rsync_args = [
this.ssh_dir, // FROM
this.path, // TO
path$1.basename(this.path) + "/", // TO
];

exit_code = await this.run(rsync_args);
Expand All @@ -30925,7 +30929,7 @@ class Rsync {
async push() {
const rsync_args = [
"--delete-before",
this.path, // FROM
path$1.basename(this.path) + "/", // FROM
this.ssh_dir, // TO
];

Expand Down
2 changes: 1 addition & 1 deletion actions/rsync-cache/dist/commit.js.map

Large diffs are not rendered by default.

24 changes: 14 additions & 10 deletions actions/rsync-cache/dist/restore.js
Original file line number Diff line number Diff line change
Expand Up @@ -30796,11 +30796,6 @@ class Rsync {
this.ssh_user = this.core.getInput("ssh_user", { required: true });
this.ssh_dir = `${this.ssh_user}@${this.ssh_host}:${this.name}/${this.key}/`;

// Add a trailing slash to the path if necessary.
if (!this.path.match(/\/$/)) {
this.path += "/";
}

this._validate();
this._set_vars();
}
Expand All @@ -30811,6 +30806,9 @@ class Rsync {
this.ssh_port = "22";
}

// NOTE: We require absolute paths for security, but due to
// Windows paths having a colon we need to use relative paths in
// the command we run.
if (!path$1.isAbsolute(this.path)) {
throw new Error(`path to cache must be absolute: ${this.path}`);
}
Expand Down Expand Up @@ -30866,7 +30864,11 @@ class Rsync {
await this.fs.chmod(this.ssh_key_file, 0o600);

// Run rsync.
const options = { ignoreReturnCode: true };
const options = {
ignoreReturnCode: true,
cwd: path$1.dirname(this.path),
};

exit_code = await this.exec.exec(
this.command,
[...this.args, ...additional_arguments],
Expand All @@ -30886,16 +30888,18 @@ class Rsync {
async fetch_only() {
this.core.notice(`Falling back to HTTP fetch...`);

await this.io.mkdirP(this.path);

const exit_code = await this.exec.exec(
"rclone",
[
"copy",
"--http-url",
`https://archive.openms.de/openms/${this.name}/${this.key}`,
":http:",
this.path,
path$1.dirname(this.path),
],
{ ignoreReturnCode: true },
{ ignoreReturnCode: true, cwd: path$1.dirname(this.path) },
);

return exit_code;
Expand All @@ -30910,7 +30914,7 @@ class Rsync {
} else {
const rsync_args = [
this.ssh_dir, // FROM
this.path, // TO
path$1.basename(this.path) + "/", // TO
];

exit_code = await this.run(rsync_args);
Expand All @@ -30925,7 +30929,7 @@ class Rsync {
async push() {
const rsync_args = [
"--delete-before",
this.path, // FROM
path$1.basename(this.path) + "/", // FROM
this.ssh_dir, // TO
];

Expand Down
2 changes: 1 addition & 1 deletion actions/rsync-cache/dist/restore.js.map

Large diffs are not rendered by default.

24 changes: 14 additions & 10 deletions actions/rsync-cache/src/rsync.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,6 @@ export default class Rsync {
this.ssh_user = this.core.getInput("ssh_user", { required: true });
this.ssh_dir = `${this.ssh_user}@${this.ssh_host}:${this.name}/${this.key}/`;

// Add a trailing slash to the path if necessary.
if (!this.path.match(/\/$/)) {
this.path += "/";
}

this._validate();
this._set_vars();
}
Expand All @@ -57,6 +52,9 @@ export default class Rsync {
this.ssh_port = "22";
}

// NOTE: We require absolute paths for security, but due to
// Windows paths having a colon we need to use relative paths in
// the command we run.
if (!path.isAbsolute(this.path)) {
throw new Error(`path to cache must be absolute: ${this.path}`);
}
Expand Down Expand Up @@ -112,7 +110,11 @@ export default class Rsync {
await this.fs.chmod(this.ssh_key_file, 0o600);

// Run rsync.
const options = { ignoreReturnCode: true };
const options = {
ignoreReturnCode: true,
cwd: path.dirname(this.path),
};

exit_code = await this.exec.exec(
this.command,
[...this.args, ...additional_arguments],
Expand All @@ -132,16 +134,18 @@ export default class Rsync {
async fetch_only() {
this.core.notice(`Falling back to HTTP fetch...`);

await this.io.mkdirP(this.path);

const exit_code = await this.exec.exec(
"rclone",
[
"copy",
"--http-url",
`https://archive.openms.de/openms/${this.name}/${this.key}`,
":http:",
this.path,
path.dirname(this.path),
],
{ ignoreReturnCode: true },
{ ignoreReturnCode: true, cwd: path.dirname(this.path) },
);

return exit_code;
Expand All @@ -156,7 +160,7 @@ export default class Rsync {
} else {
const rsync_args = [
this.ssh_dir, // FROM
this.path, // TO
path.basename(this.path) + "/", // TO
];

exit_code = await this.run(rsync_args);
Expand All @@ -171,7 +175,7 @@ export default class Rsync {
async push() {
const rsync_args = [
"--delete-before",
this.path, // FROM
path.basename(this.path) + "/", // FROM
this.ssh_dir, // TO
];

Expand Down
12 changes: 11 additions & 1 deletion actions/rsync-cache/test/rsync_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,13 @@ class Deps {
assert.equal(name, this.commands.at(-1).at(0));
}

// Assert that the last command ran in `dir`.
assert_last_cwd(dir) {
assert(this.commands.length > 0);
const options = this.commands.at(-1).at(2);
assert.equal(dir, options["cwd"]);
}

// Return the last two command line arguments for the last
// command that was executed.
get_final_args() {
Expand Down Expand Up @@ -108,7 +115,7 @@ class Deps {
function validate_rsync_paths(rsync, server, directory) {
assert(server && directory);
assert.equal(rsync.ssh_dir, server);
assert.equal(rsync.path, directory);
assert.equal(path.basename(rsync.path) + "/", directory);

// The server should start with a username and contain a colon.
assert.match(server, /^[\w]+@/);
Expand Down Expand Up @@ -169,6 +176,7 @@ test("can pull the cache", async () => {
// local directory.
await rsync.pull();
deps.exec.assert_last_command("rsync");
deps.exec.assert_last_cwd(path.dirname(rsync.path));

const [server, directory] = deps.exec.get_final_args();
validate_rsync_paths(rsync, server, directory);
Expand All @@ -183,6 +191,7 @@ test("can push the cache", async () => {
// first, then the ssh server.
await rsync.push();
deps.exec.assert_last_command("rsync");
deps.exec.assert_last_cwd(path.dirname(rsync.path));

const [directory, server] = deps.exec.get_final_args();
validate_rsync_paths(rsync, server, directory);
Expand All @@ -205,5 +214,6 @@ test("disabled on missing ssh key", async () => {
// But fetching should try to run rclone:
await rsync.pull();
deps.exec.assert_last_command("rclone");
deps.exec.assert_last_cwd(path.dirname(rsync.path));
}
});