-
-
Notifications
You must be signed in to change notification settings - Fork 2
149 lines (134 loc) · 4.47 KB
/
setup.yml
File metadata and controls
149 lines (134 loc) · 4.47 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
on:
workflow_call:
secrets:
AUTH0_SECRET:
required: false
env:
APP_ENV: ci
jobs:
# Install dependencies once and cache for other jobs
setup:
runs-on: ubuntu-latest
outputs:
BACKUP_AUTH0_SECRET: ${{ steps.set-vars.outputs.BACKUP_AUTH0_SECRET }}
steps:
- uses: actions/checkout@v5
- uses: actions/setup-node@v5
with:
node-version: 24
cache: 'npm'
cache-dependency-path: package-lock.json
- name: Get environment info
id: set-vars
run: |
echo Node version
node --version
npm --version
echo
echo Docker version
docker --version
BACKUP_AUTH0_SECRET=$(hexdump -vn32 -e'8/4 "%08x" 1 "\n"' /dev/urandom)
echo "BACKUP_AUTH0_SECRET=${BACKUP_AUTH0_SECRET}" >> $GITHUB_OUTPUT
- name: Restore node_modules cache
id: restore-cache
uses: actions/cache@v4
with:
path: node_modules
key: ${{ runner.os }}-node-modules-${{ hashFiles('package-lock.json', 'src/lib/prisma/schema.prisma') }}
- name: Install dependencies
if: steps.restore-cache.outputs.cache-hit != 'true'
run: |
echo "Installing dependencies..."
npm ci
- name: Cache node_modules
if: steps.restore-cache.outputs.cache-hit != 'true'
uses: actions/cache@v4
with:
path: node_modules
key: ${{ runner.os }}-node-modules-${{ hashFiles('package-lock.json', 'src/lib/prisma/schema.prisma') }}
# Type checking and linting
typecheck-lint:
runs-on: ubuntu-latest
needs: setup
env:
# Required for type checking. Leaving empty for now until needed for testing?
BUILD_ENGINE_ARTIFACTS_BUCKET: ""
AWS_ACCESS_KEY_ID: ""
AWS_SECRET_ACCESS_KEY: ""
BUILD_ENGINE_SECRETS_BUCKET: ""
SCRIPTURE_EARTH_KEY: ""
ORIGIN: ""
API_ACCESS_TOKEN: ""
steps:
- uses: actions/checkout@v5
- uses: actions/setup-node@v5
with:
node-version: 24
- name: Restore node_modules cache
uses: actions/cache@v4
with:
path: node_modules
key: ${{ runner.os }}-node-modules-${{ hashFiles('package-lock.json', 'src/lib/prisma/schema.prisma') }}
- name: Run svelte-check
run: |
echo "Running svelte-check..."
npm run check
- name: Run lint
run: |
echo "Running lint..."
npm run lint
# Build and run a smoke test
build-and-test:
runs-on: ubuntu-latest
needs: setup
env:
CI: true
AUTH0_SECRET: ${{ secrets.AUTH0_SECRET || needs.setup.outputs.BACKUP_AUTH0_SECRET }}
steps:
- uses: actions/checkout@v5
- uses: actions/setup-node@v5
with:
node-version: 24
- name: Restore node_modules cache
uses: actions/cache@v4
with:
path: node_modules
key: ${{ runner.os }}-node-modules-${{ hashFiles('package-lock.json', 'src/lib/prisma/schema.prisma') }}
- name: Build and seed database
run: |
echo "Building .env file..."
echo "AUTH0_SECRET=" >> .env
echo "Building the docker project..."
mkdir -p command-output
(./run ci build > command-output/build-output.txt 2>&1 || echo $? > command-output/build-exit-code.txt) &
echo "Beginning pull of images"
./run ci pull valkey > /dev/null &
echo "Starting database..."
./run ci up -d db
sleep 1
echo "Resetting the database..."
npx prisma migrate reset -f --skip-seed --skip-generate
echo "Waiting for build to finish..."
wait
if [ -f command-output/build-exit-code.txt ]; then
BUILD_EXIT_CODE=$(cat command-output/build-exit-code.txt)
echo "Build failed with exit code $BUILD_EXIT_CODE"
cat command-output/build-output.txt
exit $BUILD_EXIT_CODE
fi
echo "Build completed."
env:
DATABASE_URL: 'postgresql://db-user:1234@localhost:5432/dev-buildengine?schema=public'
- name: Start docker-compose services
run: |
echo "Starting docker-compose services..."
./run ci up -d
- name: Run tests
run: |
# Is the port open
sleep 1
nc -zv localhost 8443 || {
echo "Port 8443 is not open"
./run ci logs build-engine
exit 1
}