From d5de2ed65a1a608430fbd8610e56b0b88e314748 Mon Sep 17 00:00:00 2001 From: Tsiry Sandratraina Date: Wed, 8 Nov 2023 10:06:31 +0000 Subject: [PATCH] feat: handle pipeline arguments --- .github/workflows/ci.yml | 16 ++++------------ README.md | 2 +- ci.ts | 2 +- deno.lock | 5 +++++ deps.ts | 2 ++ fixtures/workflow.yml | 14 +++----------- src/dagger/runner.ts | 16 +++++++++++++++- src/github/config.ts | 16 +++------------- 8 files changed, 34 insertions(+), 39 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index f8521e3..8db2804 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -10,19 +10,11 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 - - uses: denoland/setup-deno@v1 - with: - deno-version: v1.37 - - name: Setup Fluent CI CLI - run: deno install -A -r https://cli.fluentci.io -n fluentci - - name: Setup Dagger - run: | - curl -L https://dl.dagger.io/dagger/install.sh | DAGGER_VERSION=0.8.1 sh - sudo mv bin/dagger /usr/local/bin - dagger version + - name: Setup Fluent CI + uses: fluentci-io/setup-fluentci@v1 - name: Run Dagger Pipelines - run: dagger run fluentci . fmt lint test + run: fluentci run . fmt lint test - name: Upload to Codecov - run: dagger run fluentci codecov_pipeline + run: fluentci run codecov_pipeline env: CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} diff --git a/README.md b/README.md index f2cd5a4..88ff3dd 100644 --- a/README.md +++ b/README.md @@ -40,7 +40,7 @@ dagger run fluentci . You can also use this pipeline programmatically: ```ts -import { djangoTests } from "https://pkg.fluentci.io/django_pipeline@v0.6.1/mod.ts"; +import { djangoTests } from "https://pkg.fluentci.io/django_pipeline@v0.7.0/mod.ts"; await djangoTests(); diff --git a/ci.ts b/ci.ts index 9755b7c..2199daf 100644 --- a/ci.ts +++ b/ci.ts @@ -1,3 +1,3 @@ -import { djangoTests } from "https://pkg.fluentci.io/django_pipeline@v0.6.1/mod.ts"; +import { djangoTests } from "https://pkg.fluentci.io/django_pipeline@v0.7.0/mod.ts"; await djangoTests(); diff --git a/deno.lock b/deno.lock index 584cbf4..67c59e2 100644 --- a/deno.lock +++ b/deno.lock @@ -31,6 +31,8 @@ "https://cdn.jsdelivr.net/gh/tsirysndr/tar@v0.1.1/deps.ts": "096395daebc7ed8a18f0484e4ffcc3a7f70e50946735f7df9611a7fcfd8272cc", "https://cdn.jsdelivr.net/gh/tsirysndr/tar@v0.1.1/mod.ts": "e269d71c72ae68e82c1960e5db2a0c7419c97c9683ef717de0ab75d90f364713", "https://cdn.jsdelivr.net/gh/tsirysndr/tar@v0.1.1/src/tar.ts": "9b02eaaa784b225ad7a23d2769cd492adf113ea7c11c02e3646849e98f4ae43b", + "https://cdn.skypack.dev/-/lodash@v4.17.21-K6GEbP02mWFnLA45zAmi/dist=es2019,mode=imports/optimized/lodash.js": "10c4df47937ffc78548d136dd535a021df5f57182a653260d715c0690dd22978", + "https://cdn.skypack.dev/lodash": "8280de0b3efd87f06ea0eb330d15b8de32c059556023b8c6524e9eb9e4844dc0", "https://deno.land/std@0.129.0/_util/assert.ts": "e94f2eb37cebd7f199952e242c77654e43333c1ac4c5c700e929ea3aa5489f74", "https://deno.land/std@0.129.0/_util/os.ts": "49b92edea1e82ba295ec946de8ffd956ed123e2948d9bd1d3e901b04e4307617", "https://deno.land/std@0.129.0/archive/tar.ts": "35ea1baddec7988cc4034765a2cee7613bc8074bd40940d3f5e98f63070a716a", @@ -149,6 +151,9 @@ "https://deno.land/std@0.203.0/path/to_file_url.ts": "00e6322373dd51ad109956b775e4e72e5f9fa68ce2c6b04e4af2a6eed3825d31", "https://deno.land/std@0.203.0/path/to_namespaced_path.ts": "1b1db3055c343ab389901adfbda34e82b7386bcd1c744d54f9c1496ee0fd0c3d", "https://deno.land/std@0.203.0/path/win32.ts": "8b3f80ef7a462511d5e8020ff490edcaa0a0d118f1b1e9da50e2916bdd73f9dd", + "https://deno.land/std@0.205.0/assert/assert.ts": "9a97dad6d98c238938e7540736b826440ad8c1c1e54430ca4c4e623e585607ee", + "https://deno.land/std@0.205.0/assert/assertion_error.ts": "4d0bde9b374dfbcbe8ac23f54f567b77024fb67dbb1906a852d67fe050d42f56", + "https://deno.land/std@0.205.0/flags/mod.ts": "0948466fc437f017f00c0b972a422b3dc3317a790bcf326429d23182977eaf9f", "https://deno.land/std@0.52.0/fmt/colors.ts": "ec9d653672a9a3c7b6eafe53c5bc797364a2db2dcf766ab649c1155fea7a80b2", "https://deno.land/x/crc32@v0.2.0/mod.ts": "de7a3fa2d4ef24b96fc21e1cc4d2d65d1d2b1dcea92f63960e3e11bfa82df0fa", "https://deno.land/x/fluent_aws_codepipeline@v0.2.3/mod.ts": "79cc758901d20a3573d7e3cc2db9f0a5fe56833f4d9befcedc072b94d542eec7", diff --git a/deps.ts b/deps.ts index b6da9c3..e681ed0 100644 --- a/deps.ts +++ b/deps.ts @@ -26,6 +26,8 @@ export { join, resolve, } from "https://deno.land/std@0.203.0/path/mod.ts"; +export { parse } from "https://deno.land/std@0.205.0/flags/mod.ts"; +export { snakeCase, camelCase } from "https://cdn.skypack.dev/lodash"; export * as FluentGitlabCI from "https://deno.land/x/fluent_gitlab_ci@v0.4.2/mod.ts"; export * as FluentGithubActions from "https://deno.land/x/fluent_github_actions@v0.2.1/mod.ts"; diff --git a/fixtures/workflow.yml b/fixtures/workflow.yml index 4c663d3..2840435 100644 --- a/fixtures/workflow.yml +++ b/fixtures/workflow.yml @@ -10,15 +10,7 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 - - uses: denoland/setup-deno@v1 - with: - deno-version: v1.36 - - name: Setup Fluent CI CLI - run: deno install -A -r https://cli.fluentci.io -n fluentci - - name: Setup Dagger - run: | - curl -L https://dl.dagger.io/dagger/install.sh | DAGGER_VERSION=0.8.1 sh - sudo mv bin/dagger /usr/local/bin - dagger version + - name: Setup Fluent CI + uses: fluentci-io/setup-fluentci@v1 - name: Run Dagger Pipelines - run: dagger run fluentci django_pipeline + run: fluentci run django_pipeline diff --git a/src/dagger/runner.ts b/src/dagger/runner.ts index ce5e3a5..59f82f5 100644 --- a/src/dagger/runner.ts +++ b/src/dagger/runner.ts @@ -1,3 +1,17 @@ import pipeline from "./pipeline.ts"; +import { parse, camelCase, snakeCase } from "../../deps.ts"; -await pipeline(".", Deno.args); +const args = parse(Deno.args.map((x) => x.split(" ")).flat()); + +if (!Array.isArray(Deno.args)) { + for (const param of Object.keys(args) + .filter((x) => x !== "_") + .map((x) => snakeCase(x).toUpperCase())) { + Deno.env.set(param, args[camelCase(param)]); + } +} + +await pipeline( + ".", + Array.isArray(Deno.args) ? Deno.args : (args._ as string[]) +); diff --git a/src/github/config.ts b/src/github/config.ts index 94311d3..c89fb30 100644 --- a/src/github/config.ts +++ b/src/github/config.ts @@ -23,22 +23,12 @@ export function generateYaml(): Workflow { uses: "actions/checkout@v2", }, { - uses: "denoland/setup-deno@v1", - with: { - "deno-version": "v1.36", - }, - }, - { - name: "Setup Fluent CI CLI", - run: "deno install -A -r https://cli.fluentci.io -n fluentci", - }, - { - name: "Setup Dagger", - run: setupDagger, + name: "Setup Fluent CI", + uses: "fluentci-io/setup-fluentci@v1", }, { name: "Run Dagger Pipelines", - run: "dagger run fluentci django_pipeline", + run: "fluentci run django_pipeline", }, ], };