Commit 6c8d20bb authored by Thomas Boni's avatar Thomas Boni
Browse files

Merge branch 'thibaud-vdb' into 'latest'

Adding the yarn_test job

See merge request r2devops/hub!237
parents 5f3d8470 aaa9ebd2
Loading
Loading
Loading
Loading
+43 −0
Original line number Diff line number Diff line
## Objective

This job will run a predefined `test` command that can be specified in the `package.json` configuration file


## How to use it

1. Make sure that your project has
   [`package.json`](https://yarnpkg.com/configuration/manifest){:target="_blank"}
   file which contains the required `test` command in the `scripts` object
2. 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/yarn_test.yml'
    ```
3. If you need to customize the job (stage, variables, ...) 👉 check the
   [jobs customization](/use-the-hub/#jobs-customization)
4. Well done, your job is ready to work ! 😀


## Job details

* Job name: `yarn_test`
* Default stage: `static_tests`
* Docker image: [`node:16.0-buster`](https://hub.docker.com/_/node){:target="_blank"}
* When: `always`


### Variables

!!! note
    All paths defined in variables are relative and start from the root of your
    repository.

| Name | Description | Default |
| ---- | ----------- | ------- |
| `PROJECT_ROOT` | Path to the directory containing `package.json`  | `.` |
| `YARN_INSTALL_OPTIONS` | Additional options for `yarn install` | ` ` |
| `YARN_TEST_OPTIONS` | Additional options for `yarn test` | ` ` |


### Cache

To cache `node_modules` folder for other `npm` jobs, take a look at [`npm_install`](/jobs/others/npm_install/#cache)

jobs/yarn_test/job.yml

0 → 100644
+15 −0
Original line number Diff line number Diff line
name: yarn_test
description: Ready to use yarn job that runs predefined command "test" specified in package.json
default_stage: static_tests
icon: 🧪
maintainer: Totara-thib
license: MIT
images:
    "node": "16.0-buster"
tools:
    "yarn": "1.22.5"
labels:
    - GitLab
    - Test
    - Yarn
    - Utilities
+0 −0

Empty file added.

+1 −0
Original line number Diff line number Diff line
* Initial version
+23 −0
Original line number Diff line number Diff line
# Job from R2Devops hub --> r2devops.io


stages:
  - static_tests


yarn_test:
  stage: static_tests
  image:
    name: node:16.0-buster
    entrypoint: [""]
  variables:
    PROJECT_ROOT: "."
    YARN_INSTALL_OPTIONS: ""
    YARN_TEST_OPTIONS: ""
  script:
    # Working directory
    - cd $PROJECT_ROOT
    # Run yarn install
    - yarn install $YARN_INSTALL_OPTIONS
    # Run yarn test
    - yarn test $YARN_TEST_OPTIONS
 No newline at end of file