Commit 2e189d2e authored by DJOUNANG NANA Guy Rostan's avatar DJOUNANG NANA Guy Rostan Committed by Thomas Boni
Browse files

Resolve "[New job] Pnpm test"

parent 34cea735
Loading
Loading
Loading
Loading
+5 −0
Original line number Diff line number Diff line
# Changelog
All notable changes to this job will be documented in this file.

## [0.1.0] - 2022-07-20
* Initial version
 No newline at end of file
+28 −0
Original line number Diff line number Diff line
## Objective

This job will run a predifined `test` command specified in the scripts section of the `package.json` configuration file

## How to use it

1. Make sure that your project has `package.json` file which contains the required `test` command in the `scripts` object.
2. Copy the job URL located in the `Install` part of the right panel and add it 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`.
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 ! 😀

### 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`  | `.` |
| `PNPM_INSTALL_OPTIONS` | Additional options for `pnpm install` | ` ` |
| `PNPM_TEST_COMMAND` | The command to run test specified in your `package.json` | `test` |
| `PNPM_TEST_OPTIONS` | Additional options for `pnpm test` | ` ` |
| `IMAGE_TAG` | The default tag for the docker image | `18-buster`  |

### Author
This resource is an **[official job](https://docs.r2devops.io/faq-labels/)** added in [**R2Devops repository**](https://gitlab.com/r2devops/hub) by [@DjNaGuRo](https://gitlab.com/DjNaGuRo)
 No newline at end of file
+24 −0
Original line number Diff line number Diff line
# Job from R2Devops hub --> r2devops.io

stages:
  - tests

pnpm_test:
  stage: tests
  image: node:${IMAGE_TAG}
  variables:
    PROJECT_ROOT: "."
    PNPM_INSTALL_OPTIONS: ""
    PNPM_TEST_COMMAND: "test"
    PNPM_TEST_OPTIONS: ""
    IMAGE_TAG: "18-buster"
  before_script:
      - curl -f https://get.pnpm.io/v6.16.js | node - add --global pnpm@7
      - pnpm config set store-dir ${CI_PROJECT_DIR}/${PROJECT_ROOT}/.pnpm-store
  script:
    # Working directory
    - cd $PROJECT_ROOT
    # Run pnpm install
    - pnpm install ${PNPM_INSTALL_OPTIONS}
    # Run pnpm test
    - pnpm run ${PNPM_TEST_COMMAND} ${PNPM_TEST_OPTIONS}