Commit c730792a authored by DJOUNANG NANA Guy Rostan's avatar DJOUNANG NANA Guy Rostan
Browse files

ci: add cypress_run job

parent a33a9043
Loading
Loading
Loading
Loading
+28 −0
Original line number Diff line number Diff line
## Objective

A job to run end-to-end test

## How to use it

1. <Your steps>
1. Add this job URL inside the `include` list of your `.gitlab-ci.yml` file (see the [quick setup](/use-the-hub/#quick-setup)). You can specify [a fixed version](#changelog) instead of `latest`.
    ```yaml
      - remote: 'https://jobs.r2devops.io/latest/cypress_run.yml'
    ```
1. If you need to customize the job (stage, variables, ...) 👉 check the [jobs
   customization](/use-the-hub/#jobs-customization)
1. Well done, your job is ready to work ! 😀

## Job details

* Job name: `cypress_run`
* Docker image:
[`node:16-buster`](https://hub.docker.com/r/_/node)
* Default stage: `dynamic_tests`
* When: `always`

### Variables

| Name | Description | Default |
| ---- | ----------- | ------- |
| `VARIABLE` <img width=100/> | A general variable for this job <img width=175/>| `Hello R2` <img width=100/>|
+36 −0
Original line number Diff line number Diff line
stages:
  - dynamic_tests

cypress_run:
    image: cypress/browsers:node16.5.0-chrome94-ff93
    stage: dynamic_tests
    cache:
      key: ${CI_COMMIT_REF_SLUG}
      paths:
        - node_modules/
        - .npm/
    variables:
      CYPRESS_CONFIG_FILE : "cypress.json"
      CYPRESS_PROJECT_PATH : "."
      CYPRESS_RECORD_KEY : ""
      CYPRESS_RECORDER : "spec"
      ADDITIONAL_OPTIONS : ""

    script:
      # install dependencies
      - npm ci
      # start de server in the background
      - npm run start:ci &
      # run Cypress tests
      - >
        if [[${CYPRESS_RECORD_KEY} != ""]]; then
          export CYPRESS_RECORD_KEY=${CYPRESS_RECORD_KEY}
          npx cypress run -P ${CYPRESS_PROJECT_PATH} -C ${CYPRESS_CONFIG_FILE} -r ${CYPRESS_RECORDER} ${ADDITIONAL_OPTIONS} --record
        else
          npx cypress run -P ${CYPRESS_PROJECT_PATH} -C ${CYPRESS_CONFIG_FILE} -r ${CYPRESS_RECORDER} ${ADDITIONAL_OPTIONS}
        fi
      artifacts:
        when: always
        paths:
          - cypress/videos/**/*.mp4
          - cypress/screenshots/**/*.png
+9 −0
Original line number Diff line number Diff line
name: cypress_run
description: A job to run end-to-end test
default_stage: dynamic_tests
icon: 🧠
maintainer: DjNaGuRo
license: MIT
images:
  cypress/browsers:node16.5.0-chrome94-ff93
tools:
 No newline at end of file
+0 −0

Empty file added.

+1 −0
Original line number Diff line number Diff line
* Initial version
 No newline at end of file