-
Notifications
You must be signed in to change notification settings - Fork 51
186 lines (165 loc) · 6.2 KB
/
Copy pathhaskell.yml
File metadata and controls
186 lines (165 loc) · 6.2 KB
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
name: Deploy
on:
workflow_dispatch:
push:
branches: [master]
env:
LANG: C.UTF-8
jobs:
# Build frontend once and share via artifacts
frontend:
name: Build Frontend
runs-on: blacksmith-4vcpu-ubuntu-2404
steps:
- uses: actions/checkout@v6
- name: Setup Node.js
uses: actions/setup-node@v6
with:
node-version: '22'
cache: 'npm'
cache-dependency-path: |
package-lock.json
web-components/package-lock.json
- name: Build frontend assets
run: |
mkdir -p static/public/assets/css
mkdir -p static/public/assets/web-components/dist/js
mkdir -p static/public/assets/web-components/dist/css
npm ci
npx tailwindcss -i ./static/public/assets/css/tailwind.css -o ./static/public/assets/css/tailwind.min.css --minify
cd web-components
npm ci
NODE_ENV=production npx vite build --mode production --sourcemap false
- name: Upload frontend artifacts
uses: actions/upload-artifact@v7
with:
name: frontend-assets
path: |
static/public/assets/css/tailwind.min.css
static/public/assets/web-components/dist
retention-days: 1
build-and-test:
name: Build and Test
needs: frontend
runs-on: blacksmith-4vcpu-ubuntu-2404
container:
image: ghcr.io/monoscope-tech/monoscope-deps:latest
credentials:
username: ${{ github.repository_owner }}
password: ${{ secrets.GH_TOKEN }}
env:
CABAL_DIR: /root/.cabal
services:
postgres:
image: timescale/timescaledb-ha:pg16-all
env:
POSTGRES_PASSWORD: postgres
POSTGRES_DB: monoscope
options: >-
--health-cmd="pg_isready -U postgres"
--health-interval=10s
--health-timeout=5s
--health-retries=5
minio:
image: bitnami/minio:latest
env:
MINIO_ROOT_USER: minioadmin
MINIO_ROOT_PASSWORD: minioadmin
MINIO_DEFAULT_BUCKETS: monoscope-test
options: >-
--health-cmd="curl -fsS http://localhost:9000/minio/health/live"
--health-interval=5s
--health-timeout=3s
--health-retries=20
steps:
- uses: actions/checkout@v6
- name: Cache dist-newstyle
uses: actions/cache@v5
with:
path: dist-newstyle
key: ${{ runner.os }}-container-cabal-${{ hashFiles('**/*.cabal', '**/cabal.project*') }}-${{ github.sha }}
restore-keys: |
${{ runner.os }}-container-cabal-${{ hashFiles('**/*.cabal', '**/cabal.project*') }}-
${{ runner.os }}-container-cabal-
- name: Download frontend artifacts
uses: actions/download-artifact@v8
with:
name: frontend-assets
path: static/public/assets
- name: Setup static directories
run: |
mkdir -p static/public/assets/css
mkdir -p static/public/assets/web-components/dist/js
mkdir -p static/public/assets/web-components/dist/css
- name: Install hpack
run: cabal install --install-method=copy --overwrite-policy=always hpack
- name: Regenerate cabal file
run: hpack
- name: Build
run: cabal build all -j --ghc-options="-O0 +RTS -A64m -n2m -RTS"
- name: Run doctests
run: cabal test doctests --ghc-options="-O0" --test-show-details=direct
- name: Run unit-tests
run: cabal test unit-tests --ghc-options="-O0" --test-show-details=direct
- name: Run integration-tests
env:
USE_EXTERNAL_DB: true
DB_HOST: postgres
TWILIO_ACCOUNT_SID: ${{ vars.TWILIO_ACCOUNT_SID }}
DISCORD_CLIENT_ID: "1328384474395967631"
LOG_LEVEL: warn
MINIO_ENDPOINT: http://minio:9000
MINIO_ACCESS_KEY: minioadmin
MINIO_SECRET_KEY: minioadmin
MINIO_BUCKET: monoscope-test
run: cabal test integration-tests --ghc-options="-O0" --test-show-details=direct
build-and-deploy:
name: Build and Deploy Docker Image
runs-on: blacksmith-4vcpu-ubuntu-2404
if: always()
permissions:
contents: 'read'
id-token: 'write'
env:
FORCE_JAVASCRIPT_ACTIONS_TO_NODE24: true
steps:
- uses: actions/checkout@v6
- name: Setup Blacksmith Builder
uses: useblacksmith/setup-docker-builder@v1
- name: Login to Container Registry
uses: docker/login-action@v4
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GH_TOKEN }}
- name: Build and push Docker Image
uses: useblacksmith/build-push-action@v2
with:
context: .
file: ./Dockerfile
push: true
tags: |
ghcr.io/${{ github.repository_owner }}/${{ github.event.repository.name }}:${{ github.sha }}
ghcr.io/${{ github.repository_owner }}/${{ github.event.repository.name }}:latest
# cache-from/cache-to and platforms are incompatible with docker driver.
# Caching is handled by --mount=type=cache in Dockerfile instead.
# Re-enable these if switching back to docker-container driver (ubuntu-latest).
# cache-from: |
# type=gha
# type=registry,ref=ghcr.io/${{ github.repository_owner }}/${{ github.event.repository.name }}:buildcache
# cache-to: |
# type=gha,mode=max
# type=registry,ref=ghcr.io/${{ github.repository_owner }}/${{ github.event.repository.name }}:buildcache,mode=max
# platforms: linux/amd64
provenance: false
build-args: |
BUILDKIT_INLINE_CACHE=1
GIT_HASH=${{ github.sha }}
GIT_COMMIT_DATE=${{ github.event.head_commit.timestamp || 'unknown' }}
- name: Deploy Image to CapRrover
uses: caprover/deploy-from-github@v1.2.0
with:
server: '${{ secrets.CAPTAINROVER_SERVER }}'
app: '${{ secrets.CAPTAINROVER_APP_NAME }}'
token: '${{ secrets.CAPTAINROVER_APP_TOKEN }}'
image: 'ghcr.io/${{ github.repository_owner }}/${{ github.event.repository.name }}:${{ github.sha }}'