Linting
The CI/CD job called Linting is performed on the latest version of Ubuntu and depends on the previously performed Setup work. It is intended to check the code against certain style and syntax guidelines, generate a report and upload the report as an artefact for later use.
Pipeline job snippet
Description
Checkout repository: uses the actions/checkout@v4 action to download the content of the repository to the working environment. This step ensures that the repository will be available for further steps in the workflow.
Setup node.js: uses the actions/setup-node@v4 action to set up the Node.js environment. The version of Node.js (node-version: 18.x) to be used in this work is specified.
Use cached node_modules: executes the command "npm ci --cache ~/.npm" to use cached npm modules. This step ensures faster dependency installation as it uses the caching that was set in the previous section called "Setup".
Run linting and generate report: executes the "npm run lint" command to run the code linting process, which checks the code against style and syntax guidelines. This step generates a code cleanup report that will be used in the following steps.
Annotate code linting results: uses the ataylorme/eslint-annotate-action@v3 action to annotate the code linting results for the purpose of displaying them directly in code merge requests, etc. The code linting report (report-json: 'lint_report.json') generated in the previous step is specified as input parameter.
Upload linting report: uses the actions/upload-artifact@v4 action to upload the linting report as an artifact. The report (lint_report.json) is uploaded with a retention time of 5 days (retention-days: 5), allowing later inspection and analysis of the code cleanup results.