-
Notifications
You must be signed in to change notification settings - Fork 20
147 lines (126 loc) · 3.76 KB
/
client-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
name: Grai Client CI
on:
pull_request:
paths:
- "grai-client/**"
- "grai-server/**"
- ".github/workflows/client-ci.yml"
concurrency:
group: ${{ github.ref }}-client-ci
cancel-in-progress: true
env:
py_ver: "${{ vars.PY_VER }}"
poetry_ver: "${{ vars.POETRY_VER }}"
project_dir: "grai-client"
jobs:
lint-client:
runs-on: ubuntu-latest
defaults:
run:
working-directory: ${{ env.project_dir }}
steps:
- name: Check out Git repository
uses: actions/checkout@v4
- name: Install Python
id: setup-python
uses: actions/setup-python@v5
with:
python-version: "${{ env.py_ver }}"
- run: pip install black isort
- run: |
black . --check
isort . --profile black --check
build-server:
runs-on: ubuntu-latest
permissions:
contents: write
packages: write
outputs:
image-digest: ${{ steps.docker-build.outputs.digest }}
defaults:
run:
working-directory: grai-server/app
steps:
- uses: actions/checkout@v4
- name: Log in to the Container registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v5
with:
images: ghcr.io/${{ github.repository }}/grai-server-temp
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@master
- name: Build
id: docker-build
uses: docker/build-push-action@v5
with:
context: grai-server/app
push: true
labels: ${{ steps.meta.outputs.labels }}
target: grai-server
tags: ghcr.io/grai-io/grai-core/grai-server-temp:latest
cache-from: type=gha
cache-to: type=gha,mode=max
tests-client:
needs:
- lint-client
- build-server
runs-on: ubuntu-latest
defaults:
run:
working-directory: ${{ env.project_dir }}
services:
postgres:
image: ankane/pgvector:latest
env:
POSTGRES_USER: grai
POSTGRES_PASSWORD: grai
POSTGRES_DB: grai
ports:
- 5432:5432
# needed because the postgres container does not provide a healthcheck
options: --health-cmd pg_isready --health-interval 2s --health-timeout 5s --health-retries 15
the_guide:
image: ghcr.io/grai-io/grai-core/grai-server-temp@${{ needs.build-server.outputs.image-digest }}
credentials:
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
env:
DB_USER: grai
DB_PASSWORD: grai
DB_NAME: grai
DB_PORT: "5432"
DB_HOST: "postgres"
DJANGO_SUPERUSER_USERNAME: null@grai.io
DJANGO_SUPERUSER_PASSWORD: super_secret
CELERY_BROKER_URL: redis://redis:6379/0
CELERY_RESULT_BACKEND: redis://redis:6379/0
REDIS_GRAPH_CACHE_HOST: redis
DEBUG: true
ports:
- 8000:8000
options: >-
--health-cmd "curl -f http://localhost:8000/health/ || exit 1"
--health-interval 2s
--health-retries 10
--health-start-period 60s
redis:
image: redis/redis-stack-server:6.2.6-v9
ports:
- 6379:6379
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: "${{ env.py_ver }}"
- uses: abatilo/actions-poetry@v2
with:
poetry-version: "${{ env.poetry_ver }}"
- run: poetry install
- name: Run Client Tests
run: poetry run pytest