-
Notifications
You must be signed in to change notification settings - Fork 228
203 lines (197 loc) · 7.55 KB
/
test-build-pipeline.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
190
191
192
193
194
195
196
197
198
199
200
201
202
203
name: Test and Build Pipeline
on:
push:
branches:
- main
- develop
paths-ignore:
- .github/**
- docs/**
- README.md
- db.sqlite3.dist
workflow_dispatch:
permissions:
contents: write
pull-requests: write
jobs:
unit-tests:
runs-on: ubuntu-latest
steps:
- name: Checkout the Code
uses: actions/checkout@v4
- name: Set Up Python
uses: actions/setup-python@v5
with:
python-version: '3.12.8'
cache: 'pip'
- name: Install Swirl
run: ./install.sh
- name: Install the Unit Tests
run: ./install-test.sh
- name: Run the Unit Tests
run: pytest
db-dist:
needs: unit-tests
runs-on: ubuntu-latest
concurrency: db-dist-cgos
services:
redis:
image: redis
options: >-
--health-cmd "redis-cli ping"
--health-interval 10s
--health-timeout 5s
--health-retries 5
ports:
- 6379:6379
steps:
- name: Checkout the Code
uses: actions/checkout@v4
- name: Pull the Latest (for just this branch)
run: git pull origin ${{ github.ref_name }}
- name: Set Up Python
uses: actions/setup-python@v5
with:
python-version: '3.12.8'
cache: 'pip'
- name: Install Swirl (with a timeout)
run: ./install.sh
timeout-minutes: 10
- name: Delete the db.sqlite3 File
run: rm db.sqlite3
- name: Setup Swirl
run: python swirl.py setup
- name: Create the Superuser
run: DJANGO_SUPERUSER_PASSWORD=password python manage.py createsuperuser --email [email protected] --username admin --noinput
- name: Start Swirl
run: python swirl.py start
- name: Load the Default SearchProviders
run: python swirl_load.py -u admin -p password -s http://localhost:8000/ 'SearchProviders/preloaded.json'
- name: Stop Swirl
run: python swirl.py stop
- name: Create a New db.dist File
run: cp db.sqlite3 db.sqlite3.dist
- name: Create a Pull Request
id: createpr
uses: peter-evans/create-pull-request@v7
with:
add-paths: db.sqlite3.dist
branch: db_dist/autoupdate
delete-branch: true
commit-message: Update the db.sqlite3.dist file
committer: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
author: ${{ github.actor }} <${{ github.actor_id }}+${{ github.actor }}@users.noreply.github.com>
title: 'New db.sqlite3.dist generated by a db-dist.yml workflow'
body: |
New `db.sqlite3.dist` file generated by GitHub Action run ${{ github.run_number }}
- name: Auto-Approve the PR
if: steps.createpr.outputs.pull-request-operation == 'created'
run: |
echo "${{ secrets.GH_ACTIONS_TOKEN }}" | gh auth login --with-token
gh pr review --approve "${{ steps.createpr.outputs.pull-request-number }}"
- name: Auto-Merge the PR
if: steps.createpr.outputs.pull-request-operation == 'created'
run: |
echo "${{ secrets.GH_ACTIONS_TOKEN }}" | gh auth login --with-token
gh pr merge --merge --auto "${{ steps.createpr.outputs.pull-request-number }}"
qa-suite:
needs: db-dist
runs-on: ubuntu-latest
services:
redis:
image: redis
options: >-
--health-cmd "redis-cli ping"
--health-interval 10s
--health-timeout 5s
--health-retries 5
ports:
- 6379:6379
steps:
- name: Checkout the Code
uses: actions/checkout@v4
- name: Pull the Latest (for just this branch)
run: git pull origin ${{ github.ref_name }}
- name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.SBS_DOCKER_USER }}
password: ${{ secrets.SBS_DOCKER_PAT }}
- name: Set Up Python
uses: actions/setup-python@v5
with:
python-version: '3.12.8'
cache: 'pip'
- name: Install Swirl
run: ./install.sh
- name: Setup Swirl
run: python swirl.py setup
- name: Install the Galaxy UI Preview
run: ./install-ui.sh -p
env:
MSAL_CB_PORT: 8000
MSAL_HOST: localhost
- name: Start Swirl
run: |
echo "OPENAI_API_KEY='${{ secrets.QA_OPENAI_KEY }}'" >> .env
cat .env
python swirl.py start
env:
ALLOWED_HOSTS: localhost,host.docker.internal
- name: Decode BigQuery token and create JSON file
run: |
echo "$BIGQUERY_TOKEN_BASE64" | base64 --decode > "${{ github.workspace }}/token.json"
env:
BIGQUERY_TOKEN_BASE64: ${{ secrets.QA_BIGQUERY_TOKEN_BASE64 }}
- name: Run the QA Suite
run: |
echo "SWIRL_TEST_HOST=localhost" > .env.qa
echo "MSAL_HOST=localhost" >> .env.qa
echo "MSAL_CB_PORT=8000" >> .env.qa
echo "QA_ADMIN_PW=${{ secrets.QA_ADMIN_PW }}" >> .env.qa
echo "QA_OPENAI_KEY=${{ secrets.QA_OPENAI_KEY }}" >> .env.qa
echo "QA_NLR_USERNAME=${{ secrets.QA_NLR_USERNAME }}" >> .env.qa
echo "QA_NLR_PASSWORD=${{ secrets.QA_NLR_PASSWORD }}" >> .env.qa
echo "QA_CRUNCHBASE_KEY=${{ secrets.QA_CRUNCHBASE_KEY }}" >> .env.qa
echo "QA_BLOCKCHAIN_KEY=${{ secrets.QA_BLOCKCHAIN_KEY }}" >> .env.qa
echo "QA_YOUTRACK_TOKEN=${{ secrets.QA_YOUTRACK_TOKEN }}" >> .env.qa
echo "QA_GITHUB_TOKEN=${{ secrets.QA_GITHUB_TOKEN }}" >> .env.qa
echo "BIGQUERY_TOKEN_PATH=${{ github.workspace }}/token.json" >> .env.qa
echo "QA_TRELLO_KEYS=${{ secrets.QA_TRELLO_KEYS }}" >> .env.qa
echo "========"
cat .env.qa
echo "========"
docker run --net=host --env-file .env.qa -t swirlai/swirl-search-qa:automated-tests-develop sh -c "behave --tags=qa_suite,community"
swirl-docker:
needs: qa-suite
runs-on: ubuntu-latest
steps:
- name: Checkout the Code
uses: actions/checkout@v4
- name: Pull the Latest (for just this branch)
run: git pull origin ${{ github.ref_name }}
- name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.SBS_DOCKER_USER }}
password: ${{ secrets.SBS_DOCKER_PAT }}
- name: Build and Push Swirl Docker Image
run: |
BRANCH_NAME=${GITHUB_REF#refs/heads/}
TAG_NAME=$([ "$BRANCH_NAME" = "main" ] && echo "latest" || echo "$BRANCH_NAME")
docker buildx use devBuilder || docker buildx create --name devBuilder --use
docker buildx build -t swirlai/swirl-search:$TAG_NAME --platform linux/amd64,linux/arm64 --push .
- name: Update the Docker Repo Description
uses: peter-evans/dockerhub-description@v4
with:
username: ${{ secrets.SBS_DOCKER_USER }}
password: ${{ secrets.SBS_DOCKER_PAT }}
repository: swirlai/swirl-search
- name: Upload Log Files
if: always()
uses: actions/upload-artifact@v4
with:
name: log-files
path: |
logs/
/var/log/syslog*