Skip to content

Commit

Permalink
Merge pull request #8 from fluent-ci-templates/feat/run-specific-jobs
Browse files Browse the repository at this point in the history
feat: allow running specific jobs from a pipeline
  • Loading branch information
tsirysndr authored Aug 3, 2023
2 parents 4ed8cc7 + 3038b67 commit 8b4daa9
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 8 deletions.
8 changes: 4 additions & 4 deletions main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import upgrade from "./upgrade.ts";
export async function main() {
await new Command()
.name("fluentci")
.version("0.3.1")
.version("0.3.2")
.description(
`
.
Expand All @@ -20,10 +20,10 @@ export async function main() {
`
)
.arguments("<pipeline:string>")
.arguments("<pipeline:string> [jobs...:string]")
.option("-r, --reload", "Reload pipeline source cache")
.action(function (options, pipeline) {
run(pipeline, options.reload);
.action(function (options, pipeline, ...jobs: [string, ...Array<string>]) {
run(pipeline, jobs, options.reload);
})
.command("init", "Initialize a new pipeline")
.arguments("[pipeline-name:string]")
Expand Down
17 changes: 13 additions & 4 deletions run.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,11 @@ import { green } from "https://deno.land/[email protected]/fmt/colors.ts";

const BASE_URL = "https://api.fluentci.io/v1";

async function run(pipeline: string, reload = false) {
async function run(
pipeline: string,
jobs: [string, ...Array<string>],
reload = false
) {
if (pipeline === ".") {
try {
// verify if .fluentci directory exists
Expand All @@ -18,12 +22,16 @@ async function run(pipeline: string, reload = false) {
args: [
"run",
"-A",
`--import-map=.fluentci/import_map.json`,
`.fluentci/src/dagger/runner.ts`,
"--import-map=.fluentci/import_map.json",
".fluentci/src/dagger/runner.ts",
...jobs,
],
});

await command.output();
const { stderr, success } = await command.output();
if (!success) {
console.log(new TextDecoder().decode(stderr));
}
return;
}

Expand All @@ -41,6 +49,7 @@ async function run(pipeline: string, reload = false) {
let denoModule = [
`--import-map=https://deno.land/x/${pipeline}/import_map.json`,
`https://deno.land/x/${pipeline}/src/dagger/runner.ts`,
...jobs,
];

if (reload) {
Expand Down

0 comments on commit 8b4daa9

Please sign in to comment.