diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 0599de4..05b0cf0 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -13,15 +13,16 @@ jobs: - name: Setup Fluent CI uses: fluentci-io/setup-fluentci@v5 with: - pipeline: deno_pipeline - args: fmt test + wasm: true + plugin: deno + args: fmt - name: Run Dagger Pipelines run: | dagger -m github.com/fluent-ci-templates/github-pipeline@main functions - - name: Upload to Codecov - run: fluentci run codecov_pipeline - env: - CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} + #- name: Upload to Codecov + # run: fluentci run codecov_pipeline + # env: + # CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} publish: needs: tests runs-on: ubuntu-latest diff --git a/deno.json b/deno.json index 2cb3f86..391d277 100644 --- a/deno.json +++ b/deno.json @@ -1,6 +1,6 @@ { "name": "@fluentci/github", - "version": "0.5.0", + "version": "0.7.0", "exports": "./mod.ts", "importMap": "import_map.json", "tasks": { diff --git a/fluentci.toml b/fluentci.toml index b615d73..1b2fa19 100644 --- a/fluentci.toml +++ b/fluentci.toml @@ -5,4 +5,4 @@ authors = [ description = "CI/CD Plugin for Github" license = "MIT" name = "github" -version = "0.6.1" +version = "0.7.0" diff --git a/mod.ts b/mod.ts index fbc1f17..a1ca67a 100644 --- a/mod.ts +++ b/mod.ts @@ -1 +1 @@ -export * from "./src/dagger/index.ts"; +export * from "./src/mod.ts"; diff --git a/plugin/Cargo.toml b/plugin/Cargo.toml index a3c0cc2..aee2ebd 100644 --- a/plugin/Cargo.toml +++ b/plugin/Cargo.toml @@ -1,7 +1,7 @@ [package] edition = "2021" name = "github" -version = "0.6.1" +version = "0.7.0" [lib] crate-type = ["cdylib"] diff --git a/src/aws/README.md b/src/aws/README.md deleted file mode 100644 index 73c519f..0000000 --- a/src/aws/README.md +++ /dev/null @@ -1,37 +0,0 @@ -# AWS CodePipeline - -[![fluentci pipeline](https://img.shields.io/badge/dynamic/json?label=pkg.fluentci.io&labelColor=%23000&color=%23460cf1&url=https%3A%2F%2Fapi.fluentci.io%2Fv1%2Fpipeline%2Fbase_pipeline&query=%24.version)](https://pkg.fluentci.io/base_pipeline) -![deno compatibility](https://shield.deno.dev/deno/^1.37) - -The following command will generate a `buildspec.yml` file in your project: - -```bash -fluentci ac init -``` - -Generated file: - -```yaml -# Do not edit this file directly. It is generated by https://deno.land/x/fluent_aws_codepipeline - -version: 0.2 -phases: - install: - commands: - - curl -fsSL https://deno.land/x/install/install.sh | sh - - export DENO_INSTALL="$HOME/.deno" - - export PATH="$DENO_INSTALL/bin:$PATH" - - deno install -A -r https://cli.fluentci.io -n fluentci - - curl -L https://dl.dagger.io/dagger/install.sh | DAGGER_VERSION=0.8.1 sh - - mv bin/dagger /usr/local/bin - - dagger version - build: - commands: - - fluentci run . - post_build: - commands: - - echo Build completed on `date` - -``` - -Feel free to edit the template generator at `.fluentci/src/aws/config.ts` to your needs. diff --git a/src/aws/config.ts b/src/aws/config.ts deleted file mode 100644 index 2089c59..0000000 --- a/src/aws/config.ts +++ /dev/null @@ -1,24 +0,0 @@ -import { BuildSpec } from "fluent_aws_codepipeline"; - -export function generateYaml(): BuildSpec { - const buildspec = new BuildSpec(); - buildspec - .phase("install", { - commands: [ - "curl -fsSL https://deno.land/x/install/install.sh | sh", - 'export DENO_INSTALL="$HOME/.deno"', - 'export PATH="$DENO_INSTALL/bin:$PATH"', - "deno install -A -r https://cli.fluentci.io -n fluentci", - "curl -L https://dl.dagger.io/dagger/install.sh | DAGGER_VERSION=0.8.1 sh", - "mv bin/dagger /usr/local/bin", - "dagger version", - ], - }) - .phase("build", { - commands: ["fluentci run ."], - }) - .phase("post_build", { - commands: ["echo Build completed on `date`"], - }); - return buildspec; -} diff --git a/src/aws/config_test.ts b/src/aws/config_test.ts deleted file mode 100644 index 97bed68..0000000 --- a/src/aws/config_test.ts +++ /dev/null @@ -1,9 +0,0 @@ -import { assertEquals } from "https://deno.land/std@0.191.0/testing/asserts.ts"; -import { generateYaml } from "./config.ts"; - -Deno.test(function generateAWSCodePipelineTest() { - const buildspec = generateYaml(); - const actual = buildspec.toString(); - const expected = Deno.readTextFileSync("./fixtures/buildspec.yml"); - assertEquals(actual, expected); -}); diff --git a/src/aws/init.ts b/src/aws/init.ts deleted file mode 100644 index 83944b7..0000000 --- a/src/aws/init.ts +++ /dev/null @@ -1,3 +0,0 @@ -import { generateYaml } from "./config.ts"; - -generateYaml().save("buildspec.yml"); diff --git a/src/azure/README.md b/src/azure/README.md deleted file mode 100644 index 7bef026..0000000 --- a/src/azure/README.md +++ /dev/null @@ -1,40 +0,0 @@ -# Azure Pipelines - -[![fluentci pipeline](https://img.shields.io/badge/dynamic/json?label=pkg.fluentci.io&labelColor=%23000&color=%23460cf1&url=https%3A%2F%2Fapi.fluentci.io%2Fv1%2Fpipeline%2Fgithub_pipeline&query=%24.version)](https://pkg.fluentci.io/github_pipeline) -![deno compatibility](https://shield.deno.dev/deno/^1.37) - -The following command will generate a `azure-pipelines.yml` file in your project: - -```bash -fluentci ap init -``` - -Generated file: - -```yaml -# Do not edit this file directly. It is generated by https://deno.land/x/fluent_azure_pipelines - -trigger: - - main -pool: - name: Default - vmImage: ubuntu-latest -steps: - - script: | - curl -fsSL https://deno.land/x/install/install.sh | sh - export DENO_INSTALL="$HOME/.deno" - export PATH="$DENO_INSTALL/bin:$PATH" - displayName: Install Deno - - script: deno install -A -r https://cli.fluentci.io -n fluentci - displayName: Setup Fluent CI CLI - - script: | - curl -L https://dl.dagger.io/dagger/install.sh | DAGGER_VERSION=0.8.1 sh - sudo mv bin/dagger /usr/local/bin - dagger version - displayName: Setup Dagger - - script: fluentci run . - displayName: Run Dagger Pipelines - -``` - -Feel free to edit the template generator at `.fluentci/src/azure/config.ts` to your needs. diff --git a/src/azure/config.ts b/src/azure/config.ts deleted file mode 100644 index 7ec2956..0000000 --- a/src/azure/config.ts +++ /dev/null @@ -1,41 +0,0 @@ -import { AzurePipeline } from "fluent_azure_pipelines"; - -export function generateYaml(): AzurePipeline { - const azurePipeline = new AzurePipeline(); - - const installDeno = `\ - curl -fsSL https://deno.land/x/install/install.sh | sh - export DENO_INSTALL="$HOME/.deno" - export PATH="$DENO_INSTALL/bin:$PATH" -`; - - const setupDagger = `\ - curl -L https://dl.dagger.io/dagger/install.sh | DAGGER_VERSION=0.8.1 sh - sudo mv bin/dagger /usr/local/bin - dagger version -`; - - azurePipeline - .trigger(["main"]) - .pool({ - name: "Default", - vmImage: "ubuntu-latest", - }) - .step({ - script: installDeno, - displayName: "Install Deno", - }) - .step({ - script: "deno install -A -r https://cli.fluentci.io -n fluentci", - displayName: "Setup Fluent CI CLI", - }) - .step({ - script: setupDagger, - displayName: "Setup Dagger", - }) - .step({ - script: "fluentci run .", - displayName: "Run Dagger Pipelines", - }); - return azurePipeline; -} diff --git a/src/azure/config_test.ts b/src/azure/config_test.ts deleted file mode 100644 index 0311f55..0000000 --- a/src/azure/config_test.ts +++ /dev/null @@ -1,9 +0,0 @@ -import { assertEquals } from "https://deno.land/std@0.191.0/testing/asserts.ts"; -import { generateYaml } from "./config.ts"; - -Deno.test(function generateAzurePipelinesTest() { - const azurepipelines = generateYaml(); - const actual = azurepipelines.toString(); - const expected = Deno.readTextFileSync("./fixtures/azure-pipelines.yml"); - assertEquals(actual, expected); -}); diff --git a/src/azure/init.ts b/src/azure/init.ts deleted file mode 100644 index 2e71b2e..0000000 --- a/src/azure/init.ts +++ /dev/null @@ -1,3 +0,0 @@ -import { generateYaml } from "./config.ts"; - -generateYaml().save("azure-pipeline.yml"); diff --git a/src/circleci/README.md b/src/circleci/README.md deleted file mode 100644 index bf5706a..0000000 --- a/src/circleci/README.md +++ /dev/null @@ -1,45 +0,0 @@ -# Circle CI - -[![fluentci pipeline](https://img.shields.io/badge/dynamic/json?label=pkg.fluentci.io&labelColor=%23000&color=%23460cf1&url=https%3A%2F%2Fapi.fluentci.io%2Fv1%2Fpipeline%2Fgithub_pipeline&query=%24.version)](https://pkg.fluentci.io/github_pipeline) -![deno compatibility](https://shield.deno.dev/deno/^1.37) - - -The following command will generate a `.circleci/config.yml` file in your project: - -```bash -fluentci cci init -``` - -Generated file: - -```yaml -# Do not edit this file directly. It is generated by https://deno.land/x/fluent_circleci - -version: 2.1 -jobs: - base: - steps: - - checkout - - run: sudo apt-get update && sudo apt-get install -y curl unzip - - run: | - curl -fsSL https://deno.land/x/install/install.sh | sh - export DENO_INSTALL="$HOME/.deno" - export PATH="$DENO_INSTALL/bin:$PATH" - - run: deno install -A -r https://cli.fluentci.io -n fluentci - - 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 - - run: - name: Run Dagger Pipelines - command: fluentci run . - machine: - image: ubuntu-2004:2023.07.1 -workflows: - dagger: - jobs: - - base - -``` - -Feel free to edit the template generator at `.fluentci/src/circleci/config.ts` to your needs. diff --git a/src/circleci/config.ts b/src/circleci/config.ts deleted file mode 100644 index b7d8a19..0000000 --- a/src/circleci/config.ts +++ /dev/null @@ -1,37 +0,0 @@ -import { CircleCI, Job } from "fluent_circleci"; - -export function generateYaml(): CircleCI { - const circleci = new CircleCI(); - - const base = new Job().machine({ image: "ubuntu-2004:2023.07.1" }).steps([ - "checkout", - { - run: "sudo apt-get update && sudo apt-get install -y curl unzip", - }, - { - run: `\ -curl -fsSL https://deno.land/x/install/install.sh | sh -export DENO_INSTALL="$HOME/.deno" -export PATH="$DENO_INSTALL/bin:$PATH"`, - }, - { - run: "deno install -A -r https://cli.fluentci.io -n fluentci", - }, - { - 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`, - }, - { - run: { - name: "Run Dagger Pipelines", - command: "fluentci run .", - }, - }, - ]); - - circleci.jobs({ base }).workflow("dagger", ["base"]); - - return circleci; -} diff --git a/src/circleci/config_test.ts b/src/circleci/config_test.ts deleted file mode 100644 index 283a9c3..0000000 --- a/src/circleci/config_test.ts +++ /dev/null @@ -1,9 +0,0 @@ -import { assertEquals } from "https://deno.land/std@0.191.0/testing/asserts.ts"; -import { generateYaml } from "./config.ts"; - -Deno.test(function generateCircleCITest() { - const circleci = generateYaml(); - const actual = circleci.toString(); - const expected = Deno.readTextFileSync("./fixtures/config.yml"); - assertEquals(actual, expected); -}); diff --git a/src/circleci/init.ts b/src/circleci/init.ts deleted file mode 100644 index 1f71248..0000000 --- a/src/circleci/init.ts +++ /dev/null @@ -1,3 +0,0 @@ -import { generateYaml } from "./config.ts"; - -generateYaml().save(".circleci/config.yml"); diff --git a/src/dagger/list_jobs.ts b/src/dagger/list_jobs.ts deleted file mode 100644 index 1911145..0000000 --- a/src/dagger/list_jobs.ts +++ /dev/null @@ -1,20 +0,0 @@ -import { brightGreen, stringifyTree } from "../../deps.ts"; -import { runnableJobs, jobDescriptions, Job } from "./jobs.ts"; - -const tree = { - name: brightGreen("github_pipeline"), - children: (Object.keys(runnableJobs) as Job[]).map((job) => ({ - name: jobDescriptions[job] - ? `${brightGreen(job)} - ${jobDescriptions[job]}` - : brightGreen(job), - children: [], - })), -}; - -console.log( - stringifyTree( - tree, - (t) => t.name, - (t) => t.children - ) -); diff --git a/src/github/README.md b/src/github/README.md deleted file mode 100644 index 4613b32..0000000 --- a/src/github/README.md +++ /dev/null @@ -1,42 +0,0 @@ -# Github Actions - -[![fluentci pipeline](https://img.shields.io/badge/dynamic/json?label=pkg.fluentci.io&labelColor=%23000&color=%23460cf1&url=https%3A%2F%2Fapi.fluentci.io%2Fv1%2Fpipeline%2Fgithub_pipeline&query=%24.version)](https://pkg.fluentci.io/github_pipeline) -![deno compatibility](https://shield.deno.dev/deno/^1.37) - -The following command will generate a `.github/workflows/base.yml` file in your project: - -```bash -fluentci gh init -``` - -Generated file: - -```yaml -# Do not edit this file directly. It is generated by https://deno.land/x/fluent_github_actions - -name: base -on: - push: - branches: - - main -jobs: - tests: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v3 - - 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: Run Dagger Pipelines - run: fluentci run . - -``` - -Feel free to edit the template generator at `.fluentci/src/github/config.ts` to your needs. diff --git a/src/github/config.ts b/src/github/config.ts deleted file mode 100644 index d7d9c41..0000000 --- a/src/github/config.ts +++ /dev/null @@ -1,30 +0,0 @@ -import { JobSpec, Workflow } from "fluent_github_actions"; - -export function generateYaml(): Workflow { - const workflow = new Workflow("release"); - - const push = { - branches: ["main"], - }; - - const tests: JobSpec = { - "runs-on": "ubuntu-latest", - steps: [ - { - uses: "actions/checkout@v3", - }, - { - name: "Setup Fluent CI", - uses: "fluentci-io/setup-fluentci@v1", - }, - { - name: "Run Dagger Pipelines", - run: "fluentci run .", - }, - ], - }; - - workflow.on({ push }).jobs({ tests }); - - return workflow; -} diff --git a/src/github/config_test.ts b/src/github/config_test.ts deleted file mode 100644 index 88bf54f..0000000 --- a/src/github/config_test.ts +++ /dev/null @@ -1,9 +0,0 @@ -import { assertEquals } from "https://deno.land/std@0.191.0/testing/asserts.ts"; -import { generateYaml } from "./config.ts"; - -Deno.test(function generateGithubActionsWorkflowTest() { - const workflow = generateYaml(); - const actual = workflow.toString(); - const expected = Deno.readTextFileSync("./fixtures/workflow.yml"); - assertEquals(actual, expected); -}); diff --git a/src/github/init.ts b/src/github/init.ts deleted file mode 100644 index d3c1b05..0000000 --- a/src/github/init.ts +++ /dev/null @@ -1,3 +0,0 @@ -import { generateYaml } from "./config.ts"; - -generateYaml().save(".github/workflows/release.yml"); diff --git a/src/gitlab/README.md b/src/gitlab/README.md deleted file mode 100644 index a226a5a..0000000 --- a/src/gitlab/README.md +++ /dev/null @@ -1,45 +0,0 @@ -# Gitlab CI - -[![fluentci pipeline](https://img.shields.io/badge/dynamic/json?label=pkg.fluentci.io&labelColor=%23000&color=%23460cf1&url=https%3A%2F%2Fapi.fluentci.io%2Fv1%2Fpipeline%2Fgithub_pipeline&query=%24.version)](https://pkg.fluentci.io/github_pipeline) -![deno compatibility](https://shield.deno.dev/deno/^1.37) - -The following command will generate a `.gitlab-ci.yml` file in your project: - -```bash -fluentci gl init -``` - -Generated file: - -```yaml -# Do not edit this file directly. It is generated by https://deno.land/x/fluent_gitlab_ci - -.docker: - image: denoland/deno:alpine - services: - - docker:${DOCKER_VERSION}-dind - variables: - DOCKER_HOST: tcp://docker:2376 - DOCKER_TLS_VERIFY: "1" - DOCKER_TLS_CERTDIR: /certs - DOCKER_CERT_PATH: /certs/client - DOCKER_DRIVER: overlay2 - DOCKER_VERSION: 20.10.16 - -.dagger: - extends: .docker - before_script: - - apk add docker-cli curl unzip - - deno install -A -r https://cli.fluentci.io -n fluentci - - curl -L https://dl.dagger.io/dagger/install.sh | DAGGER_VERSION=0.8.1 sh - - mv bin/dagger /usr/local/bin - - dagger version - -base: - extends: .dagger - script: - - fluentci run . - -``` - -Feel free to edit the template generator at `.fluentci/src/gitlab/config.ts` to your needs. diff --git a/src/gitlab/config.ts b/src/gitlab/config.ts deleted file mode 100644 index a63b9a2..0000000 --- a/src/gitlab/config.ts +++ /dev/null @@ -1,32 +0,0 @@ -import { GitlabCI, Job } from "fluent_gitlab_ci"; - -export function generateYaml(): GitlabCI { - const docker = new Job() - .image("denoland/deno:alpine") - .services(["docker:${DOCKER_VERSION}-dind"]) - .variables({ - DOCKER_HOST: "tcp://docker:2376", - DOCKER_TLS_VERIFY: "1", - DOCKER_TLS_CERTDIR: "/certs", - DOCKER_CERT_PATH: "/certs/client", - DOCKER_DRIVER: "overlay2", - DOCKER_VERSION: "20.10.16", - }); - - const dagger = new Job().extends(".docker").beforeScript( - ` - apk add docker-cli curl unzip - deno install -A -r https://cli.fluentci.io -n fluentci - curl -L https://dl.dagger.io/dagger/install.sh | DAGGER_VERSION=0.8.1 sh - mv bin/dagger /usr/local/bin - dagger version - ` - ); - - const base = new Job().extends(".dagger").script("fluentci run ."); - - return new GitlabCI() - .addJob(".docker", docker) - .addJob(".dagger", dagger) - .addJob("base", base); -} diff --git a/src/gitlab/config_test.ts b/src/gitlab/config_test.ts deleted file mode 100644 index bf5c856..0000000 --- a/src/gitlab/config_test.ts +++ /dev/null @@ -1,9 +0,0 @@ -import { assertEquals } from "https://deno.land/std@0.191.0/testing/asserts.ts"; -import { generateYaml } from "./config.ts"; - -Deno.test(function generateGitlabCITest() { - const gitlabci = generateYaml(); - const actual = gitlabci.toString(); - const expected = Deno.readTextFileSync("./fixtures/.gitlab-ci.yml"); - assertEquals(actual, expected); -}); diff --git a/src/gitlab/init.ts b/src/gitlab/init.ts deleted file mode 100644 index 6097dd5..0000000 --- a/src/gitlab/init.ts +++ /dev/null @@ -1,3 +0,0 @@ -import { generateYaml } from "./config.ts"; - -generateYaml(); diff --git a/src/dagger/lib.ts b/src/helpers.ts similarity index 94% rename from src/dagger/lib.ts rename to src/helpers.ts index 638f367..4d796cd 100644 --- a/src/dagger/lib.ts +++ b/src/helpers.ts @@ -2,10 +2,10 @@ import { dag, env, Directory, - DirectoryID, + type DirectoryID, Secret, - SecretID, -} from "../../deps.ts"; + type SecretID, +} from "../deps.ts"; export const getDirectory = async ( src: string | Directory | undefined = "." diff --git a/src/dagger/jobs.ts b/src/jobs.ts similarity index 92% rename from src/dagger/jobs.ts rename to src/jobs.ts index 0e5a361..03576c7 100644 --- a/src/dagger/jobs.ts +++ b/src/jobs.ts @@ -1,5 +1,5 @@ -import { dag, env, exit, Directory, Secret } from "../../deps.ts"; -import { getDirectory, getGithubToken } from "./lib.ts"; +import { dag, env, exit, type Directory, type Secret } from "../deps.ts"; +import { getDirectory, getGithubToken } from "./helpers.ts"; export enum Job { releaseUpload = "release_upload", diff --git a/src/dagger/index.ts b/src/mod.ts similarity index 100% rename from src/dagger/index.ts rename to src/mod.ts diff --git a/src/dagger/pipeline.ts b/src/pipeline.ts similarity index 95% rename from src/dagger/pipeline.ts rename to src/pipeline.ts index 489d4a3..dbe4e62 100644 --- a/src/dagger/pipeline.ts +++ b/src/pipeline.ts @@ -1,5 +1,5 @@ import * as jobs from "./jobs.ts"; -import { env } from "../../deps.ts"; +import { env } from "../deps.ts"; const { releaseUpload, runnableJobs } = jobs; diff --git a/src/dagger/runner.ts b/src/runner.ts similarity index 86% rename from src/dagger/runner.ts rename to src/runner.ts index 59f82f5..4b86a36 100644 --- a/src/dagger/runner.ts +++ b/src/runner.ts @@ -1,5 +1,5 @@ import pipeline from "./pipeline.ts"; -import { parse, camelCase, snakeCase } from "../../deps.ts"; +import { parse, camelCase, snakeCase } from "../deps.ts"; const args = parse(Deno.args.map((x) => x.split(" ")).flat());