-
Notifications
You must be signed in to change notification settings - Fork 0
220 lines (209 loc) · 6.6 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
220
name: basic-ci
on:
push:
branches:
- master
pull_request:
jobs:
linux-build-libs-1:
runs-on: ubuntu-latest
container: swift:5.10-focal
steps:
- name: checkout
uses: actions/checkout@v4
- name: build-duet
run: cd duet && swift build
- name: build-pairql
run: cd pairql && swift build
- name: build-pairql-macapp
run: cd pairql-macapp && swift build
linux-build-libs-2:
runs-on: ubuntu-latest
container: swift:5.10-focal
steps:
- name: checkout
uses: actions/checkout@v4
- name: build-gertie
run: cd gertie && swift build
- name: build-ts-interop
run: cd ts-interop && swift build
- name: build-x-expect
run: cd x-expect && swift build
- name: build-x-http
run: cd x-http && swift build
- name: build-x-kit
run: cd x-kit && swift build
- name: build-x-postmark
run: cd x-postmark && swift build
- name: build-x-sendgrid
run: cd x-sendgrid && swift build
- name: build-x-slack
run: cd x-slack && swift build
- name: build-x-stripe
run: cd x-stripe && swift build
linux-lib-test-libs-1:
runs-on: ubuntu-latest
container: swift:5.10-focal
steps:
- name: checkout
uses: actions/checkout@v4
- name: test-duet
run: cd duet && swift test
- name: test-pairql
run: cd pairql && swift test
linux-lib-test-libs-2:
runs-on: ubuntu-latest
container: swift:5.10-focal
steps:
- name: checkout
uses: actions/checkout@v4
- name: test-pairql-macapp
run: cd pairql-macapp && swift test
- name: test-ts-interop
run: cd ts-interop && swift test
- name: test-gertie
run: cd gertie && swift test
- name: test-x-http
run: cd x-http && swift test
- name: test-x-kit
run: cd x-kit && swift test
- name: test-x-slack
run: cd x-slack && swift test
linux-api-build:
runs-on: ubuntu-latest
container: swift:5.10-focal
steps:
- name: checkout
uses: actions/checkout@v4
- uses: actions/cache@v4
with:
path: api/.build
key: api-${{ hashFiles('api/Package.resolved') }}
restore-keys: api-
- name: meta
id: meta
uses: friends-library/dev/actions/ts-pack/actions/meta@master
with:
github_token: ${{ github.token }}
- name: set-env-vars
run: |
DATESTR=$(TZ=America/New_York date +'%Y.%m.%d_%I.%M%p')
SHORTSHA=${{ steps.meta.outputs.latest_commit_sha_short }}
if [ "${{ github.ref }}" = "refs/heads/master" ]; then
API_ENV=production
echo "SRCDIR=api/.build/release" >> $GITHUB_ENV
echo "DESTDIR=builds/production" >> $GITHUB_ENV
echo "CONFIGURATION=release" >> $GITHUB_ENV
else
API_ENV=staging
echo "SRCDIR=api/.build/debug" >> $GITHUB_ENV
echo "DESTDIR=builds/staging" >> $GITHUB_ENV
echo "CONFIGURATION=debug" >> $GITHUB_ENV
fi
echo "FILENAME=api_${API_ENV}_${DATESTR}_${SHORTSHA}" >> $GITHUB_ENV
- name: build-api
run: |
cd api && swift build --static-swift-stdlib -c $CONFIGURATION
cd ../ && cp ${SRCDIR}/Run ${FILENAME}
- name: scp-bin
uses: appleboy/[email protected]
with:
host: api.gertrude.app
username: ${{ secrets.API_SERVER_SSH_USER }}
key: ${{ secrets.API_SERVER_SSH_KEY }}
source: '${{ env.FILENAME }}'
target: '${{ env.DESTDIR }}'
- name: ssh-tasks
uses: appleboy/[email protected]
with:
host: api.gertrude.app
username: ${{ secrets.API_SERVER_SSH_USER }}
key: ${{ secrets.API_SERVER_SSH_KEY }}
envs: DESTDIR,FILENAME
script: |
ln -sf "./${FILENAME}" "${DESTDIR}/latest"
chmod +x "${DESTDIR}/${FILENAME}" "${DESTDIR}/latest"
cd ~/builds/production && ls -r api_* | grep -v $(basename $(readlink -f current)) | tail -n +11 | xargs rm
cd ~/builds/staging && ls -r api_* | tail -n +6 | xargs rm
pm2 restart staging
linux-api-test:
runs-on: ubuntu-latest
container: swift:5.10-focal
env:
DATABASE_HOST: postgres
AUTO_INCLUDED_KEYCHAIN_ID: 77777777-7777-7777-7777-777777777777
SLACK_API_TOKEN: not-real
services:
postgres:
image: postgres:latest
env:
POSTGRES_USER: vapor_username
POSTGRES_PASSWORD: vapor_password
POSTGRES_DB: vapor_database
steps:
- name: checkout
uses: actions/checkout@v4
# only restore, job:linux-api-build will save, to save execution time
- uses: actions/cache/restore@v4
with:
path: api/.build
key: api-${{ hashFiles('api/Package.resolved') }}
restore-keys: api-
- name: test-api
run: cd api && swift test
files-changed:
runs-on: ubuntu-latest
outputs:
macapplib: ${{ steps.changes.outputs.macapplib }}
steps:
- name: checkout
uses: actions/checkout@v4
- uses: dorny/paths-filter@v3
id: changes
with:
filters: |
macapplib:
- macapp/App/**
macapp-lib:
needs: files-changed
if: needs.files-changed.outputs.macapplib == 'true'
runs-on: macos-14
steps:
- name: checkout
uses: actions/checkout@v4
- name: setup xcode
uses: maxim-lobanov/setup-xcode@v1
with:
xcode-version: 15.3.0
- uses: actions/cache@v4
with:
path: macapp/App/.build
key: macapp-spm--${{ hashFiles('macapp/App/Package.resolved') }}
restore-keys: macapp-spm--
- name: build
run: cd macapp/App && swift build
- name: test
run: cd macapp/App && swift test
# env
env:
DATABASE_NAME: vapor_database
DATABASE_USERNAME: vapor_username
DATABASE_PASSWORD: vapor_password
TEST_DATABASE_NAME: vapor_database
CLOUD_STORAGE_KEY: not-real
CLOUD_STORAGE_SECRET: not-real
CLOUD_STORAGE_ENDPOINT: not-real
CLOUD_STORAGE_BUCKET: not-real
CLOUD_STORAGE_BUCKET_URL: /not-real
TWILIO_ACCOUNT_SID: not-real
TWILIO_AUTH_TOKEN: not-real
TWILIO_FROM_PHONE: not-real
DASHBOARD_URL: /dashboard
ANALYTICS_SITE_URL: /analytics
SENDGRID_API_KEY: not-real
POSTMARK_API_KEY: not-real
PRIMARY_SUPPORT_EMAIL: not-real
SUPER_ADMIN_EMAIL: not-real
STRIPE_SUBSCRIPTION_PRICE_ID: not-real
STRIPE_SECRET_KEY: not-real
SWIFT_DETERMINISTIC_HASHING: 1