-
Notifications
You must be signed in to change notification settings - Fork 0
/
.gitlab-ci.yml
89 lines (84 loc) · 2.77 KB
/
.gitlab-ci.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
stages:
- formatting
- build
- documentation
workflow:
rules:
- if: $CI_PIPELINE_SOURCE == 'merge_request_event'
- if: $CI_PIPELINE_SOURCE == 'push' && $CI_COMMIT_BRANCH == 'main'
default:
image: node:20
interruptible: true # All the jobs can be interrupted by newer pipelines
before_script:
# Check for updates and install build-essential
- apt-get update -y
- apt-get upgrade -y
- apt-get install -y build-essential
# Print the exact versions of node and npm
- node --version
- npm --version
formatting:
stage: formatting
rules:
# Run this stage only during pipelines associated to merge requests
- if: $CI_PIPELINE_SOURCE == 'merge_request_event'
script:
# Start the job
- echo "Running job \"${CI_JOB_NAME}\" with the image \"${CI_JOB_IMAGE}\"..."
# Install angular
- npm install -g @angular/cli@15.2.7
# Install the dependencies
- npm ci
# Run prettier
- npm run prettier
# Count how many files have been modified by prettier
# if any, report what to do and exit with status code 1
- |
TOUCHED_FILES=$(git diff --name-only | wc -l)
if [ "${TOUCHED_FILES}" -ne 0 ]; then
echo "The following files are not properly formatted:"
git diff --name-only
echo "Run locally \`npm run prettier\` and commit the formatted files."
exit 1
fi
# Job successfully completed
- echo "Successfully completed job \"${CI_JOB_NAME}\" with the image \"${CI_JOB_IMAGE}\""
build:
stage: build
# Run this job using multiple node images
image: $IMAGE
parallel:
matrix:
- IMAGE: ['node:16', 'node:18', 'node:20'] # All the images we want to use
script:
# Start the job
- echo "Running job \"${CI_JOB_NAME}\" with the image \"${CI_JOB_IMAGE}\"..."
# Install angular
- npm install -g @angular/cli@15.2.7
# Install the dependencies
- npm ci
# Build the application
- npm run build
# Job successfully completed
- echo "Successfully completed job \"${CI_JOB_NAME}\" with the image \"${CI_JOB_IMAGE}\""
documentation:
stage: documentation
artifacts:
paths:
- docs/build/
expire_in: 1 week
expose_as: 'sphinx documentation'
when: on_success
script:
# Start the job
- echo "Running job \"${CI_JOB_NAME}\" with the image \"${CI_JOB_IMAGE}\"..."
# Install python3-venv and create a virtual environment
- apt-get install -y python3-venv
- python3 -m venv display-env
- source display-env/bin/activate
# Install the requirements
- pip3 install -r requirements-docs.txt
# Build the documentation
- sphinx-build docs/source/ docs/build
# Job successfully completed
- echo "Successfully completed job \"${CI_JOB_NAME}\" with the image \"${CI_JOB_IMAGE}\""