-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathnotes.yml
147 lines (134 loc) · 3.49 KB
/
notes.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
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
# Step 1
# CircleCI uses a YAML file to identify how you want your testing environment setup and what tests you want to run. On CircleCI 2.0, this file must be called config.yml and must be in a hidden folder called .circleci (on Mac, Linux, and Windows systems, files and folders whose names start with a period are treated as system files that are hidden from users by default).
version: 2
jobs:
build:
docker:
- image: circleci/node:4.8.2
steps:
- checkout
- run: echo "A first hello"
# Step 2
# Using Workflows
version: 2
jobs:
build:
docker:
- image: circleci/node:4.8.2
steps:
- checkout
- run: echo "A first hello"
build:
docker:
- image: circleci/node:4.8.2
steps:
- checkout
- run: echo "A first hello"
# Step 2a
version: 2
jobs:
one:
docker:
- image: circleci/node:4.8.2
steps:
- checkout
- run: echo "A first hello"
- run: sleep 25
two:
docker:
- image: circleci/node:4.8.2
steps:
- checkout
- run: echo "A more familiar hi"
- run: sleep 15
workflows:
version: 2
one_and_two:
jobs:
- one
- two
# Step 3
# Adding some changes to use Workspaces
# Each Workflow has an associated Workspace which can be used to transfer files to downstream jobs as the workflow progresses. You can use workspaces to pass along data that is unique to this run and which is needed for downstream jobs.
version: 2
jobs:
one:
docker:
- image: circleci/node:4.8.2
steps:
- checkout
- run: echo "A first hello"
- run: mkdir -p my_workspace
- run: echo "Trying out workspaces" > my_workspace/echo-output
- persist_to_workspace:
# Must be an absolute path, or relative path from working_directory
root: my_workspace
# Must be relative path from root
paths:
- echo-output
two:
docker:
- image: circleci/node:4.8.2
steps:
- checkout
- run: echo "A more familiar hi"
- attach_workspace:
# Must be absolute path or relative path from working_directory
at: my_workspace
- run: |
if [[ $(cat my_workspace/echo-output) == "Trying out workspaces" ]]; then
echo "It worked!";
else
echo "Nope!"; exit 1
fi
workflows:
version: 2
one_and_two:
jobs:
- one
- two:
requires:
- one
# Step 4
# Caching
# npm init; npm i react
version: 2
jobs:
one:
docker:
- image: circleci/node:4.8.2
steps:
- checkout
- restore_cache:
key: npm-cache-{{ .Branch }}-{{ checksum "package.json" }}
- run: npm i
- save_cache:
key: npm-cache-{{ .Branch }}-{{ checksum "package.json" }}
paths:
- node_modules
# Step 5
# Multiple containers - Database
version: 2
jobs:
one:
docker:
- image: circleci/node:4.8.2
environment:
TEST_DATABASE_URL: postgresql://root@localhost/circle_test
- image: circleci/postgres:9.6.5-alpine-ram
steps:
- checkout
- run: sudo apt install postgresql-client-9.6
- run: whoami
- run: |
psql \
-d $TEST_DATABASE_URL \
-c "CREATE TABLE test (name char(25));"
- run: |
psql \
-d $TEST_DATABASE_URL \
-c "INSERT INTO test (name char(25));"
- run: |
psql \
-d $TEST_DATABASE_URL \
-c "SELECT * from test"