-
Notifications
You must be signed in to change notification settings - Fork 1
115 lines (93 loc) · 2.84 KB
/
js-client-test.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
name: JavaScript client tests
on:
pull_request:
push:
branches:
- master
env:
RUST_BACKTRACE: 1
jobs:
test:
name: test
runs-on: ${{matrix.os}}
strategy:
matrix:
os: [ubuntu-22.04]
node-version: [20]
services:
postgres:
image: postgres:13
env:
POSTGRES_PASSWORD: postgres
POSTGRES_DB: nittei
ports:
- 5432:5432
env:
# Needed for sqlx
DATABASE_URL: postgresql://postgres:postgres@localhost/nittei
NITTEI__HTTP_PORT: 5000
NITTEI__DATABASE_URL: postgresql://postgres:postgres@localhost/nittei
steps:
- name: Checkout repository
uses: actions/checkout@v4
- uses: pnpm/action-setup@v4
# Setup Rust as we need to run the server
- uses: dtolnay/rust-toolchain@stable
- name: Setup Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
- uses: actions/cache@v4
with:
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
target/
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
- name: Start server
run: |
# run the migrations first
cargo install sqlx-cli --no-default-features --features postgres || true
(cd crates/infra && sqlx migrate run)
export RUST_LOG=error,tracing=info
cargo build
./target/debug/nittei &> output.log &
echo "Started server in background"
sleep 10
- name: Install JS modules
run: |
cd clients/javascript
pnpm i
- name: Check if generated types are up-to-date
run: |
# Copy the generated types to a temporary folder for comparison
cd clients/javascript
cp -r ./lib/gen_types ./lib/gen_types_copy
cd ../..
bash ./scripts/generate_ts_types.sh
# Compare the generated types with the copied ones
cd clients/javascript
diff -r ./lib/gen_types ./lib/gen_types_copy
# Get the exit code of the diff command
exit_code=$?
if [ $exit_code -ne 0 ]; then
echo "Generated types are not up-to-date"
echo "Generate them with 'just generate-ts-types' and commit the changes"
exit 1
fi
# Remove the temporary folder
rm -rf ./lib/gen_types_copy
- name: Build JS
run: |
cd clients/javascript
pnpm run build
- name: Run tests
run: |
cd clients/javascript
pnpm run test
- name: Stop server
run: |
kill $(lsof -t -i:${NITTEI__HTTP_PORT}) || true
echo "Stopped server"