-
Notifications
You must be signed in to change notification settings - Fork 13
/
config.yml
183 lines (183 loc) · 5.57 KB
/
config.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
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
version: 2.1
jobs:
check_whitespace:
docker:
- image: cimg/base:2021.04
resource_class: small
steps:
- checkout
- run:
name: Check for trailing whitespace
command: ./dev-scripts/check-trailing-whitespace
- run:
name: Check that all text files end in a trailing newline
command: ./dev-scripts/check-trailing-newline
test-backend:
docker:
- image: nixos/nix:2.15.0
environment:
CACHIX_NAME: mtlynch-whatgotdone
steps:
- run:
name: Set up Cachix
command: |
nix-env -iA cachix -f https://cachix.org/api/v1/install
cachix use "${CACHIX_NAME}"
- run:
name: Enable Nix flakes
command: echo 'experimental-features = nix-command flakes' >> /etc/nix/nix.conf
- checkout
- attach_workspace:
at: ./
- run:
name: Test go packages
command: cachix watch-exec "${CACHIX_NAME}" -- nix develop --command dev-scripts/run-go-tests --full
- store_artifacts:
path: backend/.coverage.html
- run:
name: Verify golang formatting
command: dev-scripts/check-go-formatting
build_staging_frontend:
docker:
- image: nixos/nix:2.15.0
environment:
NODE_ENV: production
CACHIX_NAME: mtlynch-whatgotdone
steps:
- run:
name: Set up Cachix
command: |
nix-env -iA cachix -f https://cachix.org/api/v1/install
cachix use "${CACHIX_NAME}"
- run:
name: Enable Nix flakes
command: echo 'experimental-features = nix-command flakes' >> /etc/nix/nix.conf
- checkout
- run:
name: Compile frontend
command: cachix watch-exec "${CACHIX_NAME}" -- nix develop --command ./dev-scripts/build-frontend staging
- persist_to_workspace:
root: ./
paths:
- ./frontend/dist
build_staging_backend:
docker:
- image: nixos/nix:2.15.0
environment:
CACHIX_NAME: mtlynch-whatgotdone
steps:
- run:
name: Set up Cachix
command: |
nix-env -iA cachix -f https://cachix.org/api/v1/install
cachix use "${CACHIX_NAME}"
- run:
name: Enable Nix flakes
command: echo 'experimental-features = nix-command flakes' >> /etc/nix/nix.conf
- checkout
- attach_workspace:
at: ./
- restore_cache:
keys:
- go-mod-v3-{{ checksum "backend/go.sum" }}
- run:
name: Compile backend (staging)
command: cachix watch-exec "${CACHIX_NAME}" -- nix develop --command dev-scripts/build-backend staging
- save_cache:
key: go-mod-v3-{{ checksum "backend/go.sum" }}
paths:
- /go/pkg/mod
- persist_to_workspace:
root: ./
paths:
- ./bin/whatgotdone
lint_sql:
docker:
- image: nixos/nix:2.15.0
environment:
CACHIX_NAME: mtlynch-whatgotdone
steps:
- run:
name: Enable Nix flakes
command: echo 'experimental-features = nix-command flakes' >> /etc/nix/nix.conf
- run:
name: Set up Cachix
command: |
set -eux
nix-env -iA cachix -f https://cachix.org/api/v1/install
cachix use "${CACHIX_NAME}"
- checkout
- run:
name: Lint SQL files
command: cachix watch-exec "${CACHIX_NAME}" -- nix develop --command ./dev-scripts/lint-sql
e2e:
docker:
- image: mcr.microsoft.com/playwright:v1.29.2-focal
steps:
- checkout
- run:
name: Retrieve staging service account credentials (JSON) from CircleCI
command: |
echo "${INTEGRATION_CLIENT_SECRET}" | \
base64 --decode > creds/gcp-service-account-staging.json
- attach_workspace:
at: ./
- run:
name: Install dependencies
command: npm install
- run:
name: Run playwright tests
command: ./dev-scripts/run-e2e-tests --skip-rebuild
- store_artifacts:
path: playwright-report
deploy:
machine:
image: ubuntu-2004:202104-01
docker_layer_caching: true
environment:
# The flyctl changes too much to use a specific version, so use the latest for the
# time being.
# https://github.com/superfly/flyctl/issues/394#issuecomment-815890166
FLYCTL_VERSION: "latest"
steps:
- checkout
- run:
name: Retrieve GCP service account client secret from CircleCI
command: |
echo "$GCP_SERVICE_ACCOUNT" | \
base64 --decode > creds/gcp-service-account-prod.json
- run:
name: Install flyctl
command: curl -L https://fly.io/install.sh | sh -s "${FLYCTL_VERSION}"
- run:
name: Print flyctl version
command: |
"${HOME}/.fly/bin/flyctl" version
- run:
name: Deploy to fly.io
command: |
"${HOME}/.fly/bin/flyctl" deploy \
--access-token "${FLY_ACCESS_TOKEN}" \
--local-only
workflows:
version: 2
test-deploy:
jobs:
- check_whitespace
- build_staging_frontend
- test-backend
- build_staging_backend
- lint_sql
- e2e:
requires:
- build_staging_backend
- build_staging_frontend
- deploy:
requires:
- check_whitespace
- build_staging_frontend
- test-backend
- e2e
filters:
branches:
only: master