Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/fluent-ci-templates/microcks-pipeline
Import API specifications into Microcks and run Microcks tests
https://github.com/fluent-ci-templates/microcks-pipeline
api api-testing continuous-integration contract-testing deno docker microcks mocking testing typescript
Last synced: about 6 hours ago
JSON representation
Import API specifications into Microcks and run Microcks tests
- Host: GitHub
- URL: https://github.com/fluent-ci-templates/microcks-pipeline
- Owner: fluent-ci-templates
- License: mit
- Created: 2024-02-25T06:29:18.000Z (9 months ago)
- Default Branch: main
- Last Pushed: 2024-06-18T16:09:28.000Z (5 months ago)
- Last Synced: 2024-07-24T01:02:30.554Z (4 months ago)
- Topics: api, api-testing, continuous-integration, contract-testing, deno, docker, microcks, mocking, testing, typescript
- Language: TypeScript
- Homepage:
- Size: 165 KB
- Stars: 4
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Contributing: CONTRIBUTING.md
- License: LICENSE
- Code of conduct: CODE_OF_CONDUCT.md
Awesome Lists containing this project
README
# Microcks Pipeline
[![fluentci pipeline](https://shield.fluentci.io/x/microcks_pipeline)](https://pkg.fluentci.io/microcks_pipeline)
![deno compatibility](https://shield.deno.dev/deno/^1.41)
[![dagger-min-version](https://shield.fluentci.io/dagger/v0.11.7)](https://dagger.io)
[![](https://jsr.io/badges/@fluentci/microcks)](https://jsr.io/@fluentci/microcks)
[![ci](https://github.com/fluent-ci-templates/microcks-pipeline/actions/workflows/ci.yml/badge.svg)](https://github.com/fluent-ci-templates/microcks-pipeline/actions/workflows/ci.yml)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 run .
```## 🧩 Dagger Module
Use as a [Dagger](https://dagger.io) module:
```bash
dagger install github.com/fluent-ci-templates/microcks-pipeline@main
```Call a function from the module:
```bash
# Import API specifications into Microcks
dagger call import-api-specs --src . \
--specification-files $SPECIFICATION_FILES \
--microcks-url $MICROCKS_URL \
--keycloak-client-id $KEYCLOAK_CLIENT_ID \
--keycloak-client-secret KEYCLOAK_CLIENT_SECRET# Run Microcks tests
dagger call run-tests --api-name-and-version "$API_NAME_AND_VERSION" \
--test-endpoint $TEST_ENDPOINT \
--runner $RUNNER \
--microcks-url $MICROCKS_URL \
--keycloak-client-id $KEYCLOAK_CLIENT_ID \
--keycloak-client-secret KEYCLOAK_CLIENT_SECRET
```## 🛠️ Environment variables
| Variable | Description | Default |
| ----------------- | ------------------------- | ---------- |
| SPECIFICATION_FILES | The path to the API specifications | |
| MICROCKS_URL | Microcks instance API endpoint | |
| KEYCLOAK_CLIENT_ID | Keycloak Realm Service Account ClientId | |
| KEYCLOAK_CLIENT_SECRET | Keycloak Realm Service Account ClientSecret | |
| API_NAME_AND_VERSION | The name and version of the API to test | |
| TEST_ENDPOINT | The endpoint to test | |
| RUNNER | Test strategy (one of: HTTP, SOAP, SOAP_UI, POSTMAN, OPEN_API_SCHEMA, ASYNC_API_SCHEMA, GRPC_PROTOBUF, GRAPHQL_SCHEMA) | `HTTP` |
| WAIT_FOR | Time to wait for test to finish (int + one of: milli, sec, min) | `5sec` |
| SECRET_NAME | The name of a Secret to use for connecting test endpoint | |
| FILTERED_OPERATIONS | JSON that allows to filter a list of operations to launch a test for | |## ✨ 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;runTests(
apiNameAndVersion: string,
testEndpoint: string,
microcksURL: string,
keycloakClientId: string,
keycloakClientSecret: string | Secret,
runner = "HTTP",
waitFor = "5sec",
secretName?: string,
filteredOperations?: string,
operationsHeaders?: string
): Promise;
```## 👨💻 Programmatic usage
You can also use this pipeline programmatically:
```ts
import { importApiSpecs, runTests } from "jsr:@fluentci/microcks";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("FILTERED_OPERATIONS")
);
```