1
+ # Use the latest stable version of Semaphore 2.0 YML syntax:
1
2
version : v1.0
3
+
4
+ # Name your pipeline. In case you connect multiple pipelines with promotions,
5
+ # the name will help you differentiate between, for example, a CI build phase
6
+ # and delivery phases.
2
7
name : Semaphore JavaScript Example Pipeline
8
+
9
+ # An agent defines the environment in which your code runs.
10
+ # It is a combination of one of available machine types and operating
11
+ # system images.
12
+ # See https://docs.semaphoreci.com/article/20-machine-types
13
+ # and https://docs.semaphoreci.com/article/32-ubuntu-1804-image
3
14
agent :
4
15
machine :
5
16
type : e1-standard-2
6
17
os_image : ubuntu1804
7
18
19
+ # Blocks are the heart of a pipeline and are executed sequentially.
20
+ # Each block has a task that defines one or more jobs. Jobs define the
21
+ # commands to execute.
22
+ # See https://docs.semaphoreci.com/article/62-concepts
8
23
blocks :
9
24
- name : Install dependencies
10
25
task :
26
+ # Set environment variables that your project requires.
27
+ # See https://docs.semaphoreci.com/article/66-environment-variables-and-secrets
11
28
env_vars :
12
29
- name : NODE_ENV
13
30
value : test
14
31
- name : CI
15
32
value : ' true'
33
+
34
+ # This block runs two jobs in parallel and they both share common
35
+ # setup steps. We can group them in a prologue.
36
+ # See https://docs.semaphoreci.com/article/50-pipeline-yaml#prologue
16
37
prologue :
17
38
commands :
39
+ # Get the latest version of our source code from GitHub:
18
40
- checkout
41
+
42
+ # Use the version of Node.js specified in .nvmrc.
43
+ # Semaphore provides nvm preinstalled.
19
44
- nvm use
20
45
- node --version
21
46
- npm --version
22
47
jobs :
48
+ # First parallel job:
23
49
- name : client npm install and cache
24
50
commands :
25
51
- cd src/client
52
+
53
+ # Restore dependencies from cache. This command will not fail in
54
+ # case of a cache miss. In case of a cache hit, npm install will
55
+ # run very fast.
56
+ # For more info on caching, see https://docs.semaphoreci.com/article/68-caching-dependencies
26
57
- cache restore client-node-modules-$SEMAPHORE_GIT_BRANCH-$(checksum package-lock.json),client-node-modules-$SEMAPHORE_GIT_BRANCH,client-node-modules-master
27
58
- npm install
59
+
60
+ # Store the latest version of node modules in cache to reuse in
61
+ # further blocks:
28
62
- cache store client-node-modules-$SEMAPHORE_GIT_BRANCH-$(checksum package-lock.json) node_modules
63
+
64
+ # Second parallel job:
29
65
- name : server npm install and cache
30
66
commands :
31
67
- cd src/server
@@ -50,7 +86,10 @@ blocks:
50
86
- name : Client Lint
51
87
commands :
52
88
- cd src/client
89
+ # At this point we can assume 100% cache hit rate of node modules:
53
90
- cache restore client-node-modules-$SEMAPHORE_GIT_BRANCH-$(checksum package-lock.json),client-node-modules-$SEMAPHORE_GIT_BRANCH,client-node-modules-master
91
+
92
+ # Run task as defined in package.json:
54
93
- npm run lint
55
94
- name : Server Lint
56
95
commands :
@@ -96,10 +135,14 @@ blocks:
96
135
- nvm use
97
136
- node --version
98
137
- npm --version
138
+ # Start a Postgres database. On Semaphore, databases run in the same
139
+ # environment as your code.
140
+ # See https://docs.semaphoreci.com/article/32-ubuntu-1804-image#databases-and-services
99
141
- sem-service start postgres
142
+ # With unrestricted sudo access, you can install any additional
143
+ # system package:
100
144
- sudo apt-get install -y libgtk2.0-0
101
145
jobs :
102
- # TODO cypress require additional package to be installed on ci server
103
146
- name : Client Tests
104
147
commands :
105
148
- cd src/client
0 commit comments