-
Notifications
You must be signed in to change notification settings - Fork 0
199 lines (181 loc) · 5.95 KB
/
on-commit-main.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
# run on commit
name: CI-main
permissions:
contents: write
on:
push:
branches:
- main
workflow_dispatch:
env:
TAG_VERSION: v0.0.0
PREVIOUS_TAG: 0.0.0
LATEST_TAG: 0.0.0
TOML_VERSION: 0.0.0
#
RABBITMQ_DEFAULT_USER: admin
RABBITMQ_DEFAULT_PASS: password
# ---
POSTGRES_USER: agronom
POSTGRES_PASSWORD: root
POSTGRES_DB: garden
# ---
REDIS_PASS: admin
REDIS_COMMANDER_USER: admin
REDIS_COMMANDER_PASS: admin
# ---
DJANGO_SUPER_USER: admin
DJANGO_SUPER_PASSWORD: admin
DJANGO_SECRET_KEY: django-insecure-sihuf
# ---
RABBITMQ_WEB_UI_PORT: 15672
RABBITMQ_PORT: 5672
RABBITMQ_HOST: rabbitmq
RABBITMQ_VHOST: /
# ---
POSTGRES_PORT: 5432
# ---
NGINX_HTTP_PORT: 80
NGINX_HTTPS_PORT: 443
# ---
REDIS_USER: default
REDIS_PORT: 6379
REDIS_DB: 0
REDIS_HOST: redis
REDIS_MAXMEMORY: 256mb
REDIS_COMMANDER_PORT: 8081
# ---
PORTAINER_PORT: 9000
# ---
SWAGGER_PORT: 8956
# ---
NODEJS_PORT: 3000
# ---
DJANGO_PORT: 8000
DJANGO_DB_HOST: psql
# Web debug interface [True/>False<]
DJANGO_DEBUG: True
DJANGO_ALLOWED_HOSTS: 127.0.0.1,localhost,django
DJANGO_ASYNC_TIMEOUT_S: 30
# ---
# Whether to retry failed connections to the broker on startup [>True</False]
CELERY_BROKER_CONNECTION_RETRY_ON_STARTUP: True
# Whether to retry failed connections to the broker [>True</False]
CELERY_BROKER_CONNECTION_RETRY: True
CELERY_BROKER_CONNECTION_MAX_RETRIES: 10
CELERY_BROKER_HEARTBEAT: 10
# Late ack means the task messages will be acknowledged after the task has been executed, not right before [>True</False]
CELERY_TASK_ACKS_LATE: True
# Run tasks synchronously [True/>False<]
CELERY_TASK_ALWAYS_EAGER: False
# Worker process:
# [
# 'solo' - single process
# >'prefork'< - multiple processes (linux only)
# ]
CELERY_WORKER_POOL: prefork
# Restart worker after each task [>4</tasks]
CELERY_WORKER_MAX_TASKS_PER_CHILD: 4
# Number of worker processes [>2</precesses]
CELERY_WORKER_CONCURRENCY: 2
# Number of tasks to prefetch [>2</tasks]
CELERY_WORKER_PREFETCH_MULTIPLIER: 2
# Whether to store the task return values or not (tombstones) [True/>False<]
CELERY_TASK_IGNORE_RESULT: False
# Configure task logging [True/>False<]
CELERY_WORKER_REDIRECT_STDOUTS: False
# Log level for task logs [DEBUG/>INFO</WARNING/ERROR/CRITICAL]
CELERY_WORKER_REDIRECT_STDOUTS_LEVEL: INFO
# Custom logging format for tasks
CELERY_WORKER_TASK_LOG_FORMAT: "[%(asctime)s: %(levelname)s] Task %(task_name)s[%(task_id)s]: %(message)s"
jobs:
fetch-commit-message:
runs-on: ubuntu-latest
outputs:
commit_message: ${{ steps.get_commit_message.outputs.message }}
steps:
- uses: actions/checkout@v4
- name: "Fetch commit message"
id: get_commit_message
run: echo "::set-output name=message::$(git log -1 --pretty=%B)"
check-no-ci:
runs-on: ubuntu-latest
needs: fetch-commit-message
outputs:
no_ci: ${{ steps.check_no_ci.outputs.no_ci }}
steps:
- name: "Check for [no_ci] in commit message"
id: check_no_ci
run: |
if echo "${{ needs.fetch-commit-message.outputs.commit_message }}" | grep -iq '\[no_ci\]'; then
echo "no_ci=true" >> $GITHUB_OUTPUT
else
echo "no_ci=false" >> $GITHUB_OUTPUT
fi
spellcheck:
runs-on: ubuntu-latest
needs: check-no-ci
if: needs.check-no-ci.outputs.no_ci == 'false'
steps:
- name: checkout repository
uses: actions/checkout@v4
- name: Install codespell
shell: bash
run: |
sudo apt-get update || true
sudo apt-get install -y codespell
- name: Run Spellchecker
run: codespell --skip "./frontend/yarn.lock,./papers"
pytest:
# clone whole repo, run docker-compose-build.yml and run tests
runs-on: ubuntu-latest
needs: check-no-ci
if: needs.check-no-ci.outputs.no_ci == 'false'
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
- name: Install Docker Compose
run: |
sudo apt-get update
sudo apt-get install -y docker-compose
- name: Login to GitHub Container Registry
run: echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u ${{ github.actor }} --password-stdin
- name: Create env file from GitHub Environment
# use loop to create env file from env variables
run: |
for key in $(env | grep -E '^[A-Z_]+=' | cut -d= -f1); do
echo "$key=${!key}" >> .env
done
- name: Build and run containers
run: |
docker compose -f docker-compose-build.yml up -d
sleep 20 # Wait for containers to be ready
- name: Run tests
run: docker compose -f docker-compose-build.yml exec -T django pytest
update-release-draft:
needs:
- spellcheck
- pytest
permissions:
# write permission is required to create a github release
contents: write
# write permission is required for autolabeler
# otherwise, read permission is required at least
pull-requests: write
runs-on: ubuntu-latest
steps:
# (Optional) GitHub Enterprise requires GHE_HOST variable set
#- name: Set GHE_HOST
# run: |
# echo "GHE_HOST=${GITHUB_SERVER_URL##https:\/\/}" >> $GITHUB_ENV
# Drafts your next Release notes as Pull Requests are merged into "master"
- uses: release-drafter/release-drafter@v6
# (Optional) specify config name to use, relative to .github/. Default: release-drafter.yml
with:
config-name: release.yml
publish: true
# disable-autolabeler: true
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}