-
Notifications
You must be signed in to change notification settings - Fork 3
189 lines (182 loc) · 5.5 KB
/
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
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
name: CI
on:
push:
branches:
- main
pull_request:
branches:
- main
jobs:
lint:
name: Lint
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [20.x]
steps:
- uses: actions/checkout@v3
- name: Restore node_modules
id: yarn-cache
uses: actions/cache@v3
with:
path: "**/node_modules"
key: ${{ runner.os }}-modules-${{ hashFiles('**/yarn.lock') }}
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
- name: Install
if: steps.yarn-cache.outputs.cache-hit != 'true'
run: yarn install
- run: yarn lint
test:
name: Test
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [20.x]
steps:
- uses: actions/checkout@v3
- name: Restore node_modules
id: yarn-cache
uses: actions/cache@v3
with:
path: "**/node_modules"
key: ${{ runner.os }}-modules-${{ hashFiles('**/yarn.lock') }}
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
- name: Install
if: steps.yarn-cache.outputs.cache-hit != 'true'
run: yarn install
- run: yarn test
build:
name: Build
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [20.x]
steps:
- uses: actions/checkout@v3
- name: Restore node_modules
id: yarn-cache
uses: actions/cache@v3
with:
path: "**/node_modules"
key: ${{ runner.os }}-modules-${{ hashFiles('**/yarn.lock') }}
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
- name: Install
if: steps.yarn-cache.outputs.cache-hit != 'true'
run: yarn install
- run: CI=false yarn build
lint-python:
name: Lint Python
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set up Python 3.12
uses: actions/setup-python@v5
with:
python-version: "3.12"
- name: Install dependencies
run: pip install ruff
- name: Lint
run: ruff check
run-python:
name: Run Python
runs-on: ubuntu-latest
services:
valkey:
image: valkey/valkey
options: >-
--health-cmd "valkey-cli ping"
--health-interval 10s
--health-timeout 5s
--health-retries 5
postgres:
image: postgres:latest
env:
POSTGRES_PASSWORD: postgres
steps:
- uses: actions/checkout@v3
- name: Set up Python 3.12
uses: actions/setup-python@v5
with:
python-version: "3.12"
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
- name: Run service
env:
GOOGLE_PRIVATE_KEY: ${{ secrets.PRIVATE_KEY }}
GOOGLE_PRIVATE_KEY_ID: ${{ secrets.PRIVATE_KEY_ID }}
DATABASE_URL: postgresql://postgres:postgres@localhost:5432/postgres
SECRET_KEY: secret_key
VALKEY_HOST: localhost
VALKEY_PORT: 6379
GH_TOKEN: token
REPO_ORG: https://github.com/canonical
JIRA_EMAIL: [email protected]
JIRA_TOKEN: jiratoken
JIRA_URL: https://example.atlassian.net
JIRA_LABELS: somelabel
JIRA_COPY_UPDATES_EPIC: WD-9999999
GOOGLE_DRIVE_FOLDER_ID: folderid
COPYDOC_TEMPLATE_ID: templateid
run: |
gunicorn webapp.app:app --daemon --bind 0.0.0.0:8104
curl --head --fail --retry-delay 1 --retry 30 --retry-connrefused http://localhost:8104
run-image:
name: Run Image
runs-on: ubuntu-latest
timeout-minutes: 15
services:
valkey:
image: valkey/valkey
options: >-
--health-cmd "valkey-cli ping"
--health-interval 10s
--health-timeout 5s
--health-retries 5
ports:
- 6379:6379
postgres:
image: postgres:latest
env:
POSTGRES_PASSWORD: postgres
ports:
- 5432:5432
steps:
- uses: actions/checkout@v4
- name: Build image
run: DOCKER_BUILDKIT=1 docker build --tag websites-content-system .
- name: Run image
env:
GOOGLE_PRIVATE_KEY: ${{ secrets.PRIVATE_KEY }}
GOOGLE_PRIVATE_KEY_ID: ${{ secrets.PRIVATE_KEY_ID }}
run: |
docker run \
-p 8104:8104 \
-e SECRET_KEY=secret_key \
-e VALKEY_HOST=localhost \
-e VALKEY_PORT=6379 \
-e GH_TOKEN=token \
-e REPO_ORG=https://github.com/canonical \
-e DATABASE_URL=postgresql://postgres:postgres@localhost:5432/postgres \
-e [email protected] \
-e JIRA_TOKEN=jiratoken \
-e JIRA_URL=https://example.atlassian.net \
-e JIRA_LABELS=somelabel \
-e JIRA_COPY_UPDATES_EPIC=WD-9999999 \
-e GOOGLE_DRIVE_FOLDER_ID=folderid \
-e COPYDOC_TEMPLATE_ID=templateid \
-e GOOGLE_PRIVATE_KEY="$GOOGLE_PRIVATE_KEY" \
-e GOOGLE_PRIVATE_KEY_ID="$GOOGLE_PRIVATE_KEY_ID" \
--network host \
websites-content-system & sleep 1
curl --head --fail --retry-delay 1 --retry 30 --retry-connrefused http://localhost