Skip to content

Commit

Permalink
add example
Browse files Browse the repository at this point in the history
  • Loading branch information
tsirysndr committed Feb 25, 2024
1 parent 36601f2 commit 318f856
Show file tree
Hide file tree
Showing 24 changed files with 688 additions and 123 deletions.
16 changes: 0 additions & 16 deletions example/.fluentci/.github/workflows/ci.yml

This file was deleted.

22 changes: 0 additions & 22 deletions example/.fluentci/.github/workflows/zenith.yml

This file was deleted.

141 changes: 102 additions & 39 deletions example/.fluentci/README.md
Original file line number Diff line number Diff line change
@@ -1,48 +1,111 @@
# Base Pipeline
# Microcks Pipeline

[![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.34)
[![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%2Fmicrocks_pipeline&query=%24.version)](https://pkg.fluentci.io/microcks_pipeline)
![deno compatibility](https://shield.deno.dev/deno/^1.37)

This repository contains a minimal pipeline for a [Fluent CI](https://fluentci.io) project. It is intended to be used as a template for new projects.
Reusing this template will allow you to get started with Fluent CI in a matter of minutes, just run the following command:
A ready-to-use CI/CD Pipeline for importing API specifications into [Microcks](https://microcks.io/) and running [Microcks](https://microcks.io/) tests.

## 🚀 Usage

Run the following command:

```bash
fluentci run microcks_pipeline
```

Or, if you want to use it as a template:

```bash
fluentci init -t microcks
```

This will create a `.fluentci` folder in your project.

Now you can run the pipeline with:

```bash
fluentci init
fluentci run .
```

## Files Tree Layout
## Dagger Module

Use as a [Dagger](https://dagger.io) module:

```bash
dagger install github.com/fluent-ci-templates/microcks-pipeline@mod
```
src
├── aws
│ ├── config_test.ts : AWS CodePipeline Config Test
│ ├── config.ts : AWS CodePipeline Config
│ ├── init.ts : Used by `fluentci ac init` command
│ └── README.md : AWS CodePipeline README
├── azure : Azure Pipelines YAML Generator
│ ├── config_test.ts : Azure Pipelines Config Test
│ ├── config.ts : Azure Pipelines Config
│ ├── init.ts : Used by `fluentci ap init` command
│ └── README.md : Azure Pipelines README
├── circleci : Circle CI YAML Generator
│ ├── config_test.ts : Circle CI Config Test
│ ├── config.ts : Circle CI Config
│ ├── init.ts : Used by `fluentci cci init` command
│ └── README.md : Circle CI README
├── dagger : Dagger pipeline files
│ ├── index.ts : Dagger pipeline entrypoint
│ ├── jobs.ts : Dagger pipeline jobs
│ ├── list_jobs.ts : Used by `fluentci ls` command
│ ├── pipeline.ts : Dagger pipeline definition
│ └── runner.ts : Used by `dagger run fluentci .` command
├── github : Github Actions YAML Generator
│ ├── config_test.ts : Github Actions Config Test
│ ├── config.ts : Github Actions Config
│ ├── init.ts : Used by `fluentci gh init` command
│ └── README.md : Github Actions README
└── gitlab : Gitlab CI YAML Generator
├── config_test.ts : Gitlab CI Config Test
├── config.ts : Gitlab CI Config
├── init.ts : Used by `fluentci gl init` command
└── README.md : Gitlab CI README

## Environment variables

| Variable | Description | Default |
| ----------------- | ------------------------- | ---------- |
| SPECIFICATION_FILES | The path to the API specifications | |
| MICROCKS_URL | The URL of the Microcks instance | |
| KEYCLOAK_CLIENT_ID | The Keycloak client ID | |
| KEYCLOAK_CLIENT_SECRET | The Keycloak client secret | |
| API_NAME_AND_VERSION | The name and version of the API to test | |
| TEST_ENDPOINT | The endpoint to test | |
| RUNNER | The runner to use | `HTTP` |
| WAIT_FOR | The time to wait for the test to finish | `5sec` |
| SECRET_NAME | The name of the secret to use | |
| FILTER_OPERATIONS | The operations to filter | |



## Jobs

| Job | Description |
| ---------------- | ----------------------------------------- |
| import-api-specs | Import API specifications into Microcks |
| run-tests | Launch a Microcks test on an API endpoint |

```typescript
importApiSpecs(
src: string | Directory,
specificationFiles: string,
microcksURL: string,
keycloakClientId: string,
keycloakClientSecret: string | Secret
): Promise<string>;

runTests(
apiNameAndVersion: string,
testEndpoint: string,
microcksURL: string,
keycloakClientId: string,
keycloakClientSecret: string | Secret,
runner = "HTTP",
waitFor = "5sec",
secretName?: string,
filterOperations?: string,
operationsHeaders?: string
): Promise<string>;
```

## Programmatic usage

You can also use this pipeline programmatically:

```ts
import { importApiSpecs, runTests } from "https://pkg.fluentci.io/microcks_pipeline@v0.1.0/mod.ts";

await importApiSpecs(
".",
Deno.env.get("SPECIFICATION_FILES")!,
Deno.env.get("MICROCKS_URL")!,
Deno.env.get("KEYCLOAK_CLIENT_ID")!,
Deno.env.get("KEYCLOAK_CLIENT_SECRET")!
);

await runTests(
Deno.env.get("API_NAME_AND_VERSION")!,
Deno.env.get("TEST_ENDPOINT")!,
Deno.env.get("MICROCKS_URL")!,
Deno.env.get("KEYCLOAK_CLIENT_ID")!,
Deno.env.get("KEYCLOAK_CLIENT_SECRET")!,
Deno.env.get("RUNNER")!,
Deno.env.get("WAIT_FOR"),
Deno.env.get("SECRET_NAME"),
Deno.env.get("FILTER_OPERATIONS")
);
```
25 changes: 23 additions & 2 deletions example/.fluentci/ci.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,24 @@
import { hello } from "https://pkg.fluentci.io/base_pipeline@v0.5.3/mod.ts";
import {
importApiSpecs,
runTests,
} from "https://pkg.fluentci.io/microcks_pipeline@v0.1.0/mod.ts";

await hello();
await importApiSpecs(
".",
Deno.env.get("SPECIFICATION_FILES")!,
Deno.env.get("MICROCKS_URL")!,
Deno.env.get("KEYCLOAK_CLIENT_ID")!,
Deno.env.get("KEYCLOAK_CLIENT_SECRET")!
);

await runTests(
Deno.env.get("API_NAME_AND_VERSION")!,
Deno.env.get("TEST_ENDPOINT")!,
Deno.env.get("MICROCKS_URL")!,
Deno.env.get("KEYCLOAK_CLIENT_ID")!,
Deno.env.get("KEYCLOAK_CLIENT_SECRET")!,
Deno.env.get("RUNNER")!,
Deno.env.get("WAIT_FOR"),
Deno.env.get("SECRET_NAME"),
Deno.env.get("FILTER_OPERATIONS")
);
7 changes: 5 additions & 2 deletions example/.fluentci/dagger.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
{
"name": "base",
"sdk": "github.com/fluentci-io/daggerverse/deno-sdk@main"
"name": "microcks-pipeline",
"sdk": "github.com/fluentci-io/daggerverse/deno-sdk@main",
"version": "v0.1.0",
"description": "Import API specs or run Microcks tests",
"license": "MIT"
}
Loading

0 comments on commit 318f856

Please sign in to comment.