Commit 194d04ff authored by Cédric OLIVIER's avatar Cédric OLIVIER
Browse files

Merge branch 'feat/component' into 'master'

feat: migrate to GitLab CI/CD component

See merge request to-be-continuous/bruno!5
parents 0338776f 53972a23
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -10,7 +10,7 @@ include:
    file: '/templates/validation.yml'
  - project: 'to-be-continuous/bash'
    ref: '3.3'
    file: 'templates/gitlab-ci-bash.yml'
    file: '/templates/gitlab-ci-bash.yml'
  - project: 'to-be-continuous/semantic-release'
    ref: '3.7'
    file: '/templates/gitlab-ci-semrel.yml'    
+33 −10
Original line number Diff line number Diff line
@@ -4,13 +4,36 @@ This project implements a GitLab CI/CD template to run your automated API tests

## Usage

In order to include this template in your project, add the following to your `gitlab-ci.yml`:
This template can be used both as a [CI/CD component](https://docs.gitlab.com/ee/ci/components/#use-a-component-in-a-cicd-configuration) 
or using the legacy [`include:project`](https://docs.gitlab.com/ee/ci/yaml/index.html#includeproject) syntax.

### Use as a CI/CD component

Add the following to your `gitlab-ci.yml`:

```yaml
include:
  - project: "to-be-continuous/bruno"
    ref: "1.0.0"
    file: "/templates/gitlab-ci-bruno.yml"
  # 1: include the component
  - component: gitlab.com/to-be-continuous/bruno/gitlab-ci-bruno@1.0.0
    # 2: set/override component inputs
    inputs:
      review-enabled: true # ⚠ this is only an example
```

### Use as a CI/CD template (legacy)

Add the following to your `gitlab-ci.yml`:

```yaml
include:
  # 1: include the template
  - project: 'to-be-continuous/bruno'
    ref: '1.0.0'
    file: '/templates/gitlab-ci-bruno.yml'

variables:
  # 2: set/override template variables
  REVIEW_ENABLED: "true" # ⚠ this is only an example
```

## `bruno` job
@@ -19,13 +42,13 @@ This job starts [Bruno](https://www.usebruno.com/) (functional) tests.

It uses the following variable:

| Name              | Description                                                                                                            | Default value                                 |
| Input / Variable | Description                                                                                                            | Default value                                 |
| ----------------- | ---------------------------------------------------------------------------------------------------------------------- | --------------------------------------------- |
| `BRU_IMAGE`       | The Docker image used to run the [Bruno CLI](https://docs.usebruno.com/cli/overview.html).                             | `registry.hub.docker.com/library/node:latest` |
| `BRU_COLLECTIONS` | The matcher to select Bruno collection directory(ies) to run.                                                          | `bruno`                                       |
| `BRU_BASE_URL`    | Explicit base url environment to test.<br/>_Auto-evaluated by default ([see below chapter](#base-url-auto-evaluation))._ | _none_ (auto-evaluated)                             |
| `BRU_EXTRA_ARGS`  | Bruno extra [run options](https://docs.usebruno.com/cli/overview.html#options)                                         | _none_                                        |
| `REVIEW_ENABLED`  | Set to `true` to enable Bruno tests on review environments (dynamic environments instantiated on development branches) | _none_ (disabled)                             |
| `image` / `BRU_IMAGE` | The Docker image used to run the [Bruno CLI](https://docs.usebruno.com/cli/overview.html).                             | `registry.hub.docker.com/library/node:latest` |
| `collections` / `BRU_COLLECTIONS` | The matcher to select Bruno collection directory(ies) to run.                                                          | `bruno`                                       |
| `base-url` / `BRU_BASE_URL` | Explicit base url environment to test.<br/>_Auto-evaluated by default ([see below chapter](#base-url-auto-evaluation))._ | _none_ (auto-evaluated)                             |
| `extra-args` / `BRU_EXTRA_ARGS` | Bruno extra [run options](https://docs.usebruno.com/cli/overview.html#options)                                         | _none_                                        |
| `review-enabled` / `REVIEW_ENABLED` | Set to `true` to enable Bruno tests on review environments (dynamic environments instantiated on development branches) | _none_ (disabled)                             |

In addition to a textual report in the console, this job produces the following reports, kept for one day:

+2 −0
Original line number Diff line number Diff line
@@ -4,6 +4,8 @@
  "description": "Test your APIs with [Bruno](https://www.usebruno.com/)",
  "template_path": "templates/gitlab-ci-bruno.yml",
  "kind": "acceptance",
  "prefix": "bru",
  "is_component": true,
  "variables": [
    {
      "name": "BRU_IMAGE",
−1.5 KiB (23.2 KiB)
Loading image diff...
+31 −5
Original line number Diff line number Diff line
@@ -13,6 +13,28 @@
# program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth 
# Floor, Boston, MA  02110-1301, USA.
# =========================================================================================
spec:
  inputs:
    image:
      description: The Docker image used to run the [Bruno CLI](https://docs.usebruno.com/cli/overview.html)
      default: registry.hub.docker.com/library/node:latest
    collections:
      description: The matcher to select Bruno collection directory(ies) to run
      default: bruno
    base-url:
      description: |-
        Explicit base url environment to test.

        _Auto-evaluated by default._
      default: ''
    extra-args:
      description: Bruno extra [run options](https://docs.usebruno.com/cli/overview.html#options)
      default: ''
    review-enabled:
      description: Set to enable Bruno tests on review environments (dynamic environments instantiated on development branches)
      type: boolean
      default: false
---
# default workflow rules: Merge Request pipelines
workflow:
  rules:
@@ -59,14 +81,18 @@ workflow:

variables:
  # variabilized tracking image
  TBC_TRACKING_IMAGE: "registry.gitlab.com/to-be-continuous/tools/tracking:master"
  TBC_TRACKING_IMAGE: registry.gitlab.com/to-be-continuous/tools/tracking:master
  # Default Docker image (use a public image - can be overridden)
  BRU_IMAGE: "registry.hub.docker.com/library/node:latest"
  BRU_COLLECTIONS: bruno
  BRU_IMAGE: $[[ inputs.image ]]
  BRU_COLLECTIONS: $[[ inputs.collections ]]
  # default production ref name (pattern)
  PROD_REF: '/^(master|main)$/'
  PROD_REF: /^(master|main)$/
  # default integration ref name (pattern)
  INTEG_REF: '/^develop$/'
  INTEG_REF: /^develop$/
  BRU_BASE_URL: $[[ inputs.base-url ]]

  BRU_EXTRA_ARGS: $[[ inputs.extra-args ]]
  REVIEW_ENABLED: $[[ inputs.review-enabled ]]

stages:
  - build