Commit ab797c25 authored by Mathis Goichon's avatar Mathis Goichon
Browse files

fix: hardcode all variabilized report variables

parent 481783c2
Loading
Loading
Loading
Loading
+7 −4
Original line number Diff line number Diff line
@@ -41,7 +41,8 @@ It is bound to the `test` stage, and uses the following variable:
|--------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|-------------------------------|
| `NODE_LINT_ENABLED`      | Set to `true` to enable lint analysis                                                                                                                                                                                      | _none_ (disabled)             |
| `NODE_LINT_ARGS`         | npm [run script](https://docs.npmjs.com/cli/v8/commands/npm-run-script) arguments to execute the lint analysis <br/> yarn [run script](https://classic.yarnpkg.com/en/docs/cli/run) arguments to execute the lint analysis | `run lint`                    |
| `NODE_LINT_REPORT_PATH`  | Variable to define lint analysis report path                                                                                                                                                                               | `reports/eslint-report.json`  |

The job generates a lint report that you will find here: `NODE_PROJECT_DIR/reports/eslint-report.json`.

### `node-build` job

@@ -58,7 +59,8 @@ This job is bound to the `build` stage, and uses the following variables:
| `NODE_BUILD_DIR`              | Variable to define build directory                                                                                                                                | `dist`                          |
| `NODE_BUILD_ARGS`             | npm [run script](https://docs.npmjs.com/cli/v8/commands/npm-run-script) arguments <br/> yarn [run script](https://classic.yarnpkg.com/en/docs/cli/run) arguments  | `run build --prod`              |
| `NODE_TEST_ARGS`              | npm [test](https://docs.npmjs.com/cli/v8/commands/npm-test) arguments <br/> yarn [test](https://classic.yarnpkg.com/en/docs/cli/test) arguments                   | `test -- --coverage --bail`     |
| `NODE_UNIT_TEST_REPORT_PATH`  | The unit test report file path (JUnit format)                                                                                                                     | `reports/unit_test_report.xml`  |

The job generates a unit test report that you will find here: `NODE_PROJECT_DIR/reports/unit_test_report.xml`.

#### Unit testing with Jest

@@ -244,7 +246,8 @@ It is bound to the `test` stage.
|------------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------|----------------------------------|
| `NODE_AUDIT_DISABLED`  | Set to `true` to disable npm audit                                                                                                                    | _none_ (enabled)                 |
| `NODE_AUDIT_ARGS`      | npm [audit](https://docs.npmjs.com/cli/v8/commands/npm-audit) arguments <br/> yarn [audit](https://classic.yarnpkg.com/en/docs/cli/audit) arguments   | `--audit-level=low`              |
| `NODE_AUDIT_JSON_PATH` | JSON audit report path                                                                                                                                | `reports/npm-audit-report.json`  |

The job generates an audit report that you will find here: `NODE_PROJECT_DIR/reports/npm-audit-report.json`.

### `node-npm-outdated` job

@@ -256,5 +259,5 @@ It is bound to the `test` stage.
|---------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------|------------------------------------|
| `NODE_OUTDATED_DISABLED`  | Set to `true` to disable npm outdated                                                                                                                                 | _none_ (enabled)                   |
| `NODE_OUTDATED_ARGS`      | npm [outdated](https://docs.npmjs.com/cli/v8/commands/npm-outdated) arguments <br/> yarn [outdated](https://classic.yarnpkg.com/lang/en/docs/cli/outdated/) arguments | `--long`                           |
| `NODE_OUTDATED_JSON_PATH` | JSON outdated report path                                                                                                                                             | `reports/npm-outdated-report.json` |

The job generates an outdated report that you will find here: `NODE_PROJECT_DIR/reports/npm-outdated-report.json`.
+0 −24
Original line number Diff line number Diff line
@@ -50,12 +50,6 @@
      "description": "npm [test](https://docs.npmjs.com/cli/v8/commands/npm-test) arguments - yarn [test](https://classic.yarnpkg.com/en/docs/cli/test) arguments",
      "default": "test -- --coverage --bail",
      "advanced": true
    },
    {
      "name": "NODE_UNIT_TEST_REPORT_PATH",
      "description": "The unit test report file path (JUnit format)",
      "default": "reports/unit_test_report.xml",
      "advanced": true
    }
  ],
  "features": [
@@ -70,12 +64,6 @@
          "description": "npm [run script](https://docs.npmjs.com/cli/v8/commands/npm-run-script) arguments to execute the lint analysis - yarn [run script](https://classic.yarnpkg.com/en/docs/cli/run) arguments to execute the lint analysis",
          "default": "run lint",
          "advanced": true
        },
        {
          "name": "NODE_LINT_REPORT_PATH",
          "description": "Variable to define lint analysis report path",
          "default": "reports/eslint-report.json",
          "advanced": true
        }
      ]
    },
@@ -89,12 +77,6 @@
          "name": "NODE_AUDIT_ARGS",
          "description": "npm [audit](https://docs.npmjs.com/cli/v8/commands/npm-audit) arguments - yarn [audit](https://classic.yarnpkg.com/en/docs/cli/audit) arguments",
          "default": "--audit-level=low"
        },
        {
          "name": "NODE_AUDIT_JSON_PATH",
          "description": "JSON audit report path",
          "default": "reports/npm-audit-report.json",
          "advanced": true
        }
      ]
    },
@@ -108,12 +90,6 @@
          "name": "NODE_OUTDATED_ARGS",
          "description": "npm [outdated](https://docs.npmjs.com/cli/v8/commands/npm-outdated) arguments - yarn [outdated](https://classic.yarnpkg.com/lang/en/docs/cli/outdated/) arguments",
          "default": "--long"
        },
        {
          "name": "NODE_OUTDATED_JSON_PATH",
          "description": "JSON outdated report path",
          "default": "reports/npm-outdated-report.json",
          "advanced": true
        }
      ]
    }
+4 −11
Original line number Diff line number Diff line
@@ -35,24 +35,17 @@ variables:
  NODE_IMAGE : "node:lts-alpine"
  # Node lint
  NODE_LINT_ARGS: "run lint"
  # Node lint report
  NODE_LINT_REPORT_PATH: "reports/eslint-report.json"
  # Node build
  NODE_BUILD_ARGS: "run build --prod"
  # Node test
  NODE_TEST_ARGS: "test -- --coverage --bail"

  # Gitlab JUnit test report
  NODE_UNIT_TEST_REPORT_PATH: "reports/unit_test_report.xml"

  # Audit
  NODE_AUDIT_LEVEL: "low"
  NODE_AUDIT_ARGS: "--audit-level=$NODE_AUDIT_LEVEL"
  NODE_AUDIT_JSON_PATH: "reports/audit-report.json"

  # Outdated
  NODE_OUTDATED_ARGS: "--long"
  NODE_OUTDATED_JSON_PATH: "reports/outdated-report.json"

  # default production ref name (pattern)
  PROD_REF: '/^(master|main)$/'
@@ -96,7 +89,7 @@ stages:
      mkdir -p reports
      # generate eslint report in json for SonarQube
      # shellcheck disable=SC2086
      $NODE_MANAGER $NODE_LINT_ARGS -- --format=json --output-file=$NODE_LINT_REPORT_PATH
      $NODE_MANAGER $NODE_LINT_ARGS -- --format=json --output-file=reports/eslint-report.json
    fi
  }

@@ -303,7 +296,7 @@ node-build:
  coverage: '/^All files\s*\|\s*(\d+(?:\.\d+)?)/'
  artifacts:
    reports:
      junit: $NODE_PROJECT_DIR/$NODE_UNIT_TEST_REPORT_PATH
      junit: $NODE_PROJECT_DIR/reports/unit_test_report.xml
    when: always
    name: "$CI_JOB_NAME artifacts from $CI_PROJECT_NAME on $CI_COMMIT_REF_SLUG"
    paths:
@@ -348,7 +341,7 @@ node-audit:
      if ! $NODE_MANAGER audit $NODE_AUDIT_ARGS
      then
        # failed: also generate JSON report
        $NODE_MANAGER audit --json $NODE_AUDIT_ARGS > $NODE_AUDIT_JSON_PATH
        $NODE_MANAGER audit --json $NODE_AUDIT_ARGS > reports/audit-report.json
      fi
  artifacts:
    name: "$CI_JOB_NAME artifacts from $CI_PROJECT_NAME on $CI_COMMIT_REF_SLUG"
@@ -376,7 +369,7 @@ node-outdated:
      if ! $NODE_MANAGER outdated $NODE_OUTDATED_ARGS
      then
        # failed: also generate JSON report
        $NODE_MANAGER outdated --json $NODE_OUTDATED_ARGS > $NODE_OUTDATED_JSON_PATH
        $NODE_MANAGER outdated --json $NODE_OUTDATED_ARGS > reports/outdated-report.json
      fi
  artifacts:
    name: "$CI_JOB_NAME artifacts from $CI_PROJECT_NAME on $CI_COMMIT_REF_SLUG"