-
Notifications
You must be signed in to change notification settings - Fork 2
247 lines (239 loc) · 8.71 KB
/
build.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
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
name: build
on:
push:
branches: [main, staging]
pull_request:
branches: [main]
repository_dispatch:
types: [build]
jobs:
# tests only on production hub
hub-prod:
runs-on: ubuntu-latest
timeout-minutes: 7
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
with:
python-version: "3.10" # run one job on 3.9
cache: "pip"
- uses: aws-actions/configure-aws-credentials@v4
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: eu-central-1
- run: pip install "laminci@git+https://x-access-token:${{ secrets.LAMIN_BUILD_DOCS }}@github.com/laminlabs/laminci"
- run: nox -s "install(group='hub-prod')"
- run: nox -s "build(lamin_env='prod', group='hub-prod')"
- uses: actions/upload-artifact@v4
with:
name: coverage--hub-prod
path: .coverage
include-hidden-files: true
# tests both on production and staging hub
hub-cloud:
runs-on: ubuntu-22.04
strategy:
fail-fast: false
matrix:
include:
- lamin_env: "prod"
python-version: "3.11"
- lamin_env: "staging"
python-version: "3.10" # test on 3.9
timeout-minutes: 7
steps:
- uses: aws-actions/configure-aws-credentials@v4
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: eu-central-1
- uses: actions/checkout@v4
- uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
cache: "pip"
cache-dependency-path: ".github/workflows/build.yml"
- uses: actions/checkout@v4
with:
repository: laminlabs/laminhub
token: ${{ secrets.GH_TOKEN_DEPLOY_LAMINAPP }}
path: laminhub
ref: main
- uses: actions/cache@v4
with:
path: ~/.cache/pre-commit
key: pre-commit-${{ runner.os }}-${{ hashFiles('.pre-commit-config.yaml') }}
- id: cache-postgres
uses: actions/cache@v4
with:
path: ~/postgres.tar
key: cache-postgres-0
- if: steps.cache-postgres.outputs.cache-hit != 'true'
run: docker pull postgres:latest && docker image save postgres:latest --output ~/postgres.tar
- if: steps.cache-postgres.outputs.cache-hit == 'true'
run: docker image load --input ~/postgres.tar
- run: pip install "laminci@git+https://x-access-token:${{ secrets.LAMIN_BUILD_DOCS }}@github.com/laminlabs/laminci"
# account for in a different job
# - uses: "google-github-actions/auth@v0"
# with:
# credentials_json: "${{ secrets.GCP_CREDENTIALS }}"
# - uses: "google-github-actions/setup-gcloud@v0"
- run: nox -s "install(group='hub-cloud')"
- run: nox -s "build(lamin_env='${{ matrix.lamin_env }}', group='hub-cloud')"
- uses: actions/upload-artifact@v4
if: ${{ matrix.lamin_env == 'prod' }}
with:
name: coverage--hub-cloud
path: .coverage
include-hidden-files: true
# test user access to storage
storage:
runs-on: ubuntu-latest
timeout-minutes: 7
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v4
with:
python-version: "3.9"
cache: "pip"
cache-dependency-path: ".github/workflows/build.yml"
- run: pip install "laminci@git+https://x-access-token:${{ secrets.LAMIN_BUILD_DOCS }}@github.com/laminlabs/laminci"
- run: nox -s "install(group='storage')"
- run: nox -s lint
- run: nox -s storage
env:
TEST_INSTANCE_PRIVATE_POSTGRES: ${{ secrets.TEST_INSTANCE_PRIVATE_POSTGRES }}
TMP_AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
TMP_AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
- uses: actions/upload-artifact@v4
with:
name: coverage--storage
path: .coverage
include-hidden-files: true
# test low-level hub functionality
hub-local:
runs-on: ubuntu-latest
timeout-minutes: 7
steps:
- uses: aws-actions/configure-aws-credentials@v4
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: eu-central-1
- uses: actions/checkout@v4
- uses: actions/checkout@v4
with:
repository: laminlabs/laminhub
token: ${{ secrets.GH_TOKEN_DEPLOY_LAMINAPP }}
path: laminhub
ref: main
- name: Set env file for local test of edge functions
run: |
touch .env.local
echo "AWS_ACCESS_KEY_ID_HOSTED_S3=${{ secrets.AWS_ACCESS_KEY_ID }}" >> .env.local
echo "AWS_SECRET_ACCESS_KEY_HOSTED_S3=${{ secrets.AWS_SECRET_ACCESS_KEY }}" >> .env.local
working-directory: laminhub/rest-hub/supabase
- uses: actions/setup-python@v4
with:
python-version: "3.11" # we need to run everything for coverage on 3.11
cache: "pip"
cache-dependency-path: ".github/workflows/build.yml"
- run: pip install "laminci@git+https://x-access-token:${{ secrets.LAMIN_BUILD_DOCS }}@github.com/laminlabs/laminci"
- run: nox -s "install(group='hub-local')"
- id: cache-supabase
uses: actions/cache@v4
with:
path: /var/lib/docker
key: cache-supabase
- uses: supabase/setup-cli@v1
- run: nox -s hub_local
env:
LAMIN_ENV: "local"
- uses: actions/upload-artifact@v4
with:
name: coverage--hub-local
path: .coverage
include-hidden-files: true
coverage:
needs: [hub-prod, hub-cloud, storage, hub-local]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v4
with:
python-version: "3.11"
cache: "pip"
- run: |
pip install coverage[toml]
pip install --no-deps .
- uses: actions/download-artifact@v4
- name: run coverage
run: |
coverage combine coverage--*/.coverage*
coverage report --fail-under=0
coverage xml
- uses: codecov/codecov-action@v2
with:
token: ${{ secrets.CODECOV_TOKEN }}
docs:
needs: hub-cloud
runs-on: ubuntu-latest
steps:
- uses: aws-actions/configure-aws-credentials@v4
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: eu-central-1
- uses: actions/checkout@v4
with:
submodules: recursive
fetch-depth: 0
- name: checkout lndocs
uses: actions/checkout@v4
with:
repository: laminlabs/lndocs
ssh-key: ${{ secrets.READ_LNDOCS }}
path: lndocs
ref: main
- uses: actions/setup-python@v4
with:
python-version: "3.10"
cache: "pip"
cache-dependency-path: ".github/workflows/build.yml"
- run: pip install "laminci@git+https://x-access-token:${{ secrets.LAMIN_BUILD_DOCS }}@github.com/laminlabs/laminci"
- run: nox -s "install(group='docs')"
- uses: actions/download-artifact@v4
- run: nox -s docs
- uses: nwtgck/[email protected]
with:
publish-dir: "_build/html"
production-deploy: ${{ github.event_name == 'push' }}
github-token: ${{ secrets.GITHUB_TOKEN }}
enable-commit-comment: false
env:
NETLIFY_AUTH_TOKEN: ${{ secrets.NETLIFY_AUTH_TOKEN }}
NETLIFY_SITE_ID: ${{ secrets.NETLIFY_SITE_ID }}
notify:
if: always()
# this here is only for notifying developers of laminhub
# hence, it only needs groups hub-local and hub-cloud
needs: [hub-local, hub-cloud]
runs-on: ubuntu-latest
steps:
- uses: voxmedia/github-action-slack-notify-build@v1
if: ${{ needs.hub-local.result == 'success' && needs.hub-cloud.result == 'success' && github.event_name == 'repository_dispatch' }}
env:
SLACK_BOT_TOKEN: ${{ secrets.SLACK_GITHUB_ACTION }}
with:
channel_id: C05S2C02JHM
status: SUCCESS
color: good
- uses: voxmedia/github-action-slack-notify-build@v1
if: ${{ ( needs.hub-local.result == 'failure' || needs.hub-cloud.result == 'failure' ) && github.event_name == 'repository_dispatch' }}
env:
SLACK_BOT_TOKEN: ${{ secrets.SLACK_GITHUB_ACTION }}
with:
channel_id: C05S2C02JHM
status: FAILURE
color: danger