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

Merge branch 'feat/component' into 'master'

feat: migrate to CI/CD component

See merge request to-be-continuous/robotframework!44
parents 7d7cf316 7d08f911
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'
+54 −38
Original line number Diff line number Diff line
@@ -4,13 +4,40 @@ This project implements a GitLab CI/CD template to run your automated tests with

## 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:
  # 1: include the component
  - component: gitlab.com/to-be-continuous/robotframework/gitlab-ci-robotframework@4.1.0
    # 2: set/override component inputs
    inputs:
      # ⚠ this is only an example
      tests-dir: "e2e"
      review-enabled: "true"
```

### 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/robotframework'
    ref: '4.1.0'
    file: '/templates/gitlab-ci-robotframework.yml'

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

## Jobs
@@ -21,9 +48,9 @@ This job performs a **lint** analysis on Robot Framework files, using [robotfram

It is bound to the `test` stage, and uses the following variable:

| Name                  | Description                              | Default value     |
| Input / Variable | Description                              | Default value     |
| --------------------- | ---------------------------------------- | ----------------- |
| `ROBOT_LINT_DISABLED` | Set to `true` to disable linter                           | _none_ |
| `lint-disabled` / `ROBOT_LINT_DISABLED` | Set to `true` to disable linter                           | _none_ |

### `robotframework` job

@@ -31,19 +58,18 @@ This job performs [Robot Framework tests](https://robotframework.org/).

It is bound to the `acceptance` stage, and uses the following variable:

| Name                  | Description                                                 | Default value |
| Input / Variable | Description                                                 | Default value |
| --------------------- | ----------------------------------------------------------- | ------------- |
| `ROBOT_BASE_IMAGE`    | The Docker image used to run Robot Framework                | `registry.hub.docker.com/ppodgorsek/robot-framework:latest` |
| `ROBOT_TESTS_DIR`     | Robot Framework's tests directory                           | `robot` |
| `ROBOT_THREADS`       | Number of threads to execute Robot Framework's tests (uses [Pabot](https://pabot.org/) if > `1`)  | `1` |
| `ROBOT_SCREEN_COLOUR_DEPTH` | Screen colour depth for X Window Virtual Framebuffer  | `24`   |
| `ROBOT_SCREEN_HEIGHT` | Screen height for X Window Virtual Framebuffer              | `1080` |
| `ROBOT_SCREEN_WIDTH`  | Screen width for X Window Virtual Framebuffer               | `1920` |
| `ROBOT_BROWSER`       | Browser to use (one of `firefox` or `chrome`)               | `firefox` |
| `ROBOT_OPTIONS`       | Robot Framework [additional options](http://robotframework.org/robotframework/latest/RobotFrameworkUserGuide.html#all-command-line-options) | _none_ |
| `PABOT_OPTIONS`       | Pabot [additional options](https://github.com/mkorpela/pabot#command-line-options) (if `ROBOT_THREADS` > `1`)   | _none_ |
| `ACCEPTANCE_ALWAYS`   | Force to execute the test after each commit (even on development branches) | `false` |
| `REVIEW_ENABLED`      | Set to `true` to enable Robot Framework tests on review environments (_dynamic environments instantiated on development branches_) | _none_ (disabled) |
| `base-image` / `ROBOT_BASE_IMAGE` | The Docker image used to run Robot Framework                | `registry.hub.docker.com/ppodgorsek/robot-framework:latest` |
| `tests-dir` / `ROBOT_TESTS_DIR` | Robot Framework's tests directory                           | `robot` |
| `threads` / `ROBOT_THREADS` | Number of threads to execute Robot Framework's tests (uses [Pabot](https://pabot.org/) if > `1`)  | `1` |
| `screen-colour-depth` / `ROBOT_SCREEN_COLOUR_DEPTH` | Screen colour depth for X Window Virtual Framebuffer  | `24`   |
| `screen-height` / `ROBOT_SCREEN_HEIGHT` | Screen height for X Window Virtual Framebuffer              | `1080` |
| `screen-width` / `ROBOT_SCREEN_WIDTH` | Screen width for X Window Virtual Framebuffer               | `1920` |
| `browser` / `ROBOT_BROWSER` | Browser to use (one of `firefox` or `chrome`)               | `firefox` |
| `options` / `ROBOT_OPTIONS` | Robot Framework [additional options](http://robotframework.org/robotframework/latest/RobotFrameworkUserGuide.html#all-command-line-options) | _none_ |
| `pabot-options` / `PABOT_OPTIONS` | Pabot [additional options](https://github.com/mkorpela/pabot#command-line-options) (if `ROBOT_THREADS` > `1`)   | _none_ |
| `review-enabled` / `REVIEW_ENABLED` | Set to `true` to enable Robot Framework tests on review environments (_dynamic environments instantiated on development branches_) | _none_ (disabled) |

Notes:
* :warning: the Robot Framework project does not maintain an official Docker image. Use the default Docker image at your own risks. See the to-be-continuous [documentation](https://to-be-continuous.gitlab.io/doc/secu/#image-selection) for more details.
@@ -144,11 +170,11 @@ This variant allows delegating your secrets management to a [Vault](https://www.

In order to be able to communicate with the Vault server, the variant requires the additional configuration parameters:

| Name              | Description                            | Default value     |
| Input / Variable | Description                            | Default value     |
| ----------------- | -------------------------------------- | ----------------- |
| `TBC_VAULT_IMAGE` | The [Vault Secrets Provider](https://gitlab.com/to-be-continuous/tools/vault-secrets-provider) image to use (can be overridden) | `registry.gitlab.com/to-be-continuous/tools/vault-secrets-provider:master` |
| `VAULT_BASE_URL`  | The Vault server base API url          | _none_ |
| `VAULT_OIDC_AUD`  | The `aud` claim for the JWT | `$CI_SERVER_URL` |
| `vault-base-url` / `VAULT_BASE_URL` | The Vault server base API url          | _none_ |
| `vault-oidc-aud` / `VAULT_OIDC_AUD` | The `aud` claim for the JWT | `$CI_SERVER_URL` |
| :lock: `VAULT_ROLE_ID`   | The [AppRole](https://www.vaultproject.io/docs/auth/approle) RoleID | **must be defined** |
| :lock: `VAULT_SECRET_ID` | The [AppRole](https://www.vaultproject.io/docs/auth/approle) SecretID | **must be defined** |

@@ -166,7 +192,7 @@ Then you may retrieve any of your secret(s) from Vault using the following synta

With:

| Name                             | Description                            |
| Parameter                        | Description                            |
| -------------------------------- | -------------------------------------- |
| `secret_path` (_path parameter_) | this is your secret location in the Vault server |
| `field` (_query parameter_)      | parameter to access a single basic field from the secret JSON payload |
@@ -176,26 +202,16 @@ With:
```yaml
include:
  # main template
  - project: 'to-be-continuous/robotframework'
    ref: '4.1.0'
    file: '/templates/gitlab-ci-robotframework.yml'
  - component: gitlab.com/to-be-continuous/robotframework/gitlab-ci-robotframework@4.1.0
  # Vault variant
  - project: 'to-be-continuous/robotframework'
    ref: '4.1.0'
    file: '/templates/gitlab-ci-robotframework-vault.yml'

variables:
    ### variables have to be explicitly declared in the YAML to be exported to the service.
    VAULT_ROLE_ID: ${VAULT_ROLE_ID}
    VAULT_SECRET_ID: ${VAULT_SECRET_ID}
  - component: gitlab.com/to-be-continuous/robotframework/gitlab-ci-robotframework-vault@4.1.0
    inputs:
      # audience claim for JWT
      vault-oidc-aud: "https://vault.acme.host"
      vault-base-url: "https://vault.acme.host/v1"
      # $VAULT_ROLE_ID and $VAULT_SECRET_ID defined as a secret CI/CD variable

    ### /!\ don't define VAULT_ROLE_ID and VAULT_SECRET_ID if you want to use gitlab JWT
    # VAULT_JWT_TOKEN: "$CI_JOB_JWT"
    # VAULT_JWT_ROLE: "my_gitlab_role"

variables:
  ### Secrets managed by Vault
  MY_APPLICATION_PASS: "@url@http://vault-secrets-provider/api/secrets/b7ecb6ebabc231/my-app/robot/noprod?field=application_password"
    VAULT_BASE_URL: "https://vault.acme.host/v1"

```
+2 −2
Original line number Diff line number Diff line
@@ -27,13 +27,13 @@ if [[ "$curVer" ]]; then
  log_info "Bump version from \\e[33;1m${curVer}\\e[0m to \\e[33;1m${nextVer}\\e[0m (release type: $relType)..."

  # replace in README
  sed -e "s/ref: '$curVer'/ref: '$nextVer'/" README.md > README.md.next
  sed -e "s/ref: *'$curVer'/ref: '$nextVer'/" -e "s/ref: *\"$curVer\”/ref: \”$nextVer\”/" -e "s/component: *\(.*\)@$curVer/component: \1@$nextVer/" README.md > README.md.next
  mv -f README.md.next README.md

  # replace in template and variants
  for tmpl in templates/*.yml
  do
    sed -e "s/\"$curVer\"/\"$nextVer\"/" "$tmpl" > "$tmpl.next"
    sed -e "s/command: *\[\"--service\", \"\(.*\)\", \"$curVer\"\]/command: [\"--service\", \"\1\", \"$nextVer\"]/" "$tmpl" > "$tmpl.next"
    mv -f "$tmpl.next" "$tmpl"
  done
else
+27 −5
Original line number Diff line number Diff line
@@ -3,6 +3,8 @@
  "description": "Run your automated tests with [Robot Framework](https://robotframework.org/)",
  "template_path": "templates/gitlab-ci-robotframework.yml",
  "kind": "acceptance",
  "prefix": "robot",
  "is_component": true,
  "variables": [
    {
      "name": "ROBOT_BASE_IMAGE",
@@ -38,16 +40,36 @@
      "description": "Pabot [additional options](https://github.com/mkorpela/pabot#command-line-options) (if `ROBOT_THREADS` > `1`)",
      "advanced": true
    },
    {
      "name": "ROBOT_SCREEN_COLOUR_DEPTH",
      "description": "Screen colour depth for X Window Virtual Framebuffer",
      "type": "number",
      "default": "24"
    },
    {
      "name": "ROBOT_SCREEN_HEIGHT",
      "description": "Screen height for X Window Virtual Framebuffer",
      "type": "number",
      "default": "1080"
    },
    {
      "name": "ROBOT_SCREEN_WIDTH",
      "description": "Screen width for X Window Virtual Framebuffer",
      "type": "number",
      "default": "1920"
    },
    {
      "name": "REVIEW_ENABLED",
      "description": "Set to enable Robot Framework tests on review environments (dynamic environments instantiated on development branches)",
      "type": "boolean"
    },
    }
  ],
  "features": [
    {
      "name": "ACCEPTANCE_ALWAYS",
      "type": "boolean",
      "description": "Force to execute the test after each commit (even on development branches)",
      "advanced": true
      "id": "lint",
      "name": "robotframework-lint",
      "description": "This job performs a [Lint](https://github.com/boakley/robotframework-lint/) analysis on your `Robot Framework files`.",
      "disable_with": "ROBOT_LINT_DISABLED"
    }
  ],
  "variants": [
−2.09 KiB (8.53 KiB)
Loading image diff...
Loading