-
Notifications
You must be signed in to change notification settings - Fork 5
219 lines (193 loc) · 6.35 KB
/
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
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
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
name: CI/CD
on: [push]
jobs:
test:
name: "Test"
runs-on: "ubuntu-latest"
services:
postgres:
image: postgres:12.3
env:
POSTGRES_USER: congame
POSTGRES_PASSWORD: congame
POSTGRES_DB: congame
ports:
# will assign a random free host port
- 5432/tcp
# needed because the postgres container does not provide a healthcheck
options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5
steps:
- name: Checkout (+ fetch lfs)
uses: actions/checkout@master
with:
lfs: true # Does not checkout the files, only fetches them
- name: Checkout lfs objects
run: git lfs checkout
- name: Cache Racket dependencies
uses: actions/cache@v2
with:
path: |
~/.cache/racket
~/.local/share/racket
key: ${{ runner.os }}-${{ hashFiles('**/info.rkt') }}-${{ hashFiles('ci/setup-catalogs.sh') }}
- name: Install Racket
uses: Bogdanp/[email protected]
with:
architecture: 'x64'
distribution: 'full'
variant: 'CS'
version: '8.11'
- name: Install Racket deps
run: |
./ci/setup-catalogs.sh
raco pkg install -D --auto --skip-installed \
congame-core/ \
conscript/ \
congame-example-study/ \
congame-identity/ \
studies/ \
congame-pjb-studies/ \
congame-price-lists/ \
congame-smtp-proxy/ \
congame-tests/ \
congame-web/
raco setup --pkgs \
congame-core \
conscript \
congame-example-study \
congame-identity \
studies \
congame-pjb-studies \
congame-price-lists \
congame-smtp-proxy \
congame-tests \
congame-web
- name: Run tests
run: ./bin/run-tests.sh
env:
CONGAME_WEB_TEST_DB_HOST: 127.0.0.1
CONGAME_WEB_TEST_DB_PORT: ${{ job.services.postgres.ports[5432] }} # get randomly assigned published port
CONGAME_WEB_TEST_DB_NAME: congame
CONGAME_WEB_TEST_DB_USERNAME: congame
CONGAME_WEB_TEST_DB_PASSWORD: congame
if: ${{ !contains(github.event.head_commit.message, '[skip tests]') }}
build:
name: "Build"
runs-on: "ubuntu-latest"
steps:
- name: Checkout (+ fetch lfs)
uses: actions/checkout@master
with:
lfs: true # Does not checkout the files, only fetches them
- name: Checkout lfs objects
run: git lfs checkout
- name: Cache npm
uses: actions/cache@v2
with:
path: |
~/.npm
node_modules
key: ${{ runner.os }}-${{ hashFiles('package-lock.json') }}
- name: Cache Racket dependencies
uses: actions/cache@v2
with:
path: |
~/.cache/racket
~/.local/share/racket
key: ${{ runner.os }}-${{ hashFiles('**/info.rkt') }}-${{ hashFiles('ci/setup-catalogs.sh') }}
- name: Install Racket
uses: Bogdanp/[email protected]
with:
architecture: 'x64'
distribution: 'full'
variant: 'CS'
version: '8.11'
- name: Install Racket deps
run: |
./ci/setup-catalogs.sh
raco pkg install -D --auto --skip-installed \
congame-core/ \
conscript/ \
congame-example-study/ \
congame-identity/ \
studies/ \
congame-pjb-studies/ \
congame-price-lists/ \
congame-smtp-proxy/ \
congame-tests/ \
congame-web/
raco setup --pkgs \
congame-core \
conscript \
congame-example-study \
congame-identity \
studies \
congame-pjb-studies \
congame-price-lists \
congame-smtp-proxy \
congame-tests \
congame-web
- name: Install Node
uses: actions/setup-node@v1
with:
node-version: '12.x'
- name: Install Node packages
run: npm install
- name: Build Node assets
run: npm run build
- name: Build executables
run: |
raco scribble +m --htmls --dest doc --redirect 'https://docs.racket-lang.org/local-redirect/index.html' congame-doc/congame.scrbl
mkdir build
raco koyo dist -t build/identity ++lang north congame-identity/dynamic.rkt
raco koyo dist -t build/smtp-proxy congame-smtp-proxy/main.rkt
raco koyo dist \
-t build/web \
++lang conscript \
++lib conscript/survey-tools \
++lang north \
congame-web/dynamic.rkt
- name: Log into GHCR
run: |
echo "$PAT" | docker login ghcr.io -u MarcKaufmann --password-stdin
env:
PAT: ${{ secrets.PAT }}
- name: Build docker images
run: |
docker build -t "ghcr.io/marckaufmann/congame-docs:$GITHUB_SHA" -f Dockerfile.docs .
docker build -t "ghcr.io/marckaufmann/congame-identity:$GITHUB_SHA" -f Dockerfile.identity .
docker build -t "ghcr.io/marckaufmann/congame-smtp-proxy:$GITHUB_SHA" -f Dockerfile.smtp-proxy .
docker build -t "ghcr.io/marckaufmann/congame-web:$GITHUB_SHA" -f Dockerfile.web .
- name: Push docker images
run: |
docker push "ghcr.io/marckaufmann/congame-docs:$GITHUB_SHA"
docker push "ghcr.io/marckaufmann/congame-identity:$GITHUB_SHA"
docker push "ghcr.io/marckaufmann/congame-smtp-proxy:$GITHUB_SHA"
docker push "ghcr.io/marckaufmann/congame-web:$GITHUB_SHA"
deploy:
name: "Deploy"
needs: [test, build]
runs-on: "ubuntu-latest"
steps:
- name: Checkout
uses: actions/checkout@master
- name: Deploy staging
run: ./ci/deploy.sh STAGING
env:
PAT: ${{ secrets.PAT }}
DEPLOY_KEY: ${{ secrets.DEPLOY_KEY }}
DEPLOY_HOST: ${{ secrets.DEPLOY_HOST }}
POSTMARK_TOKEN: ${{ secrets.POSTMARK_TOKEN }}
SENTRY_DSN : ${{ secrets.SENTRY_DSN }}
if: >-
startsWith(github.ref, 'refs/heads/master')
- name: Deploy production
run: ./ci/deploy.sh PRODUCTION
env:
PAT: ${{ secrets.PAT }}
DEPLOY_KEY: ${{ secrets.DEPLOY_KEY }}
DEPLOY_HOST: ${{ secrets.DEPLOY_HOST }}
POSTMARK_TOKEN: ${{ secrets.POSTMARK_TOKEN }}
SENTRY_DSN : ${{ secrets.SENTRY_DSN }}
if: >-
startsWith(github.ref, 'refs/tags/v')