Merge pull request #113 from mikeiken:test-12 #324
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# run on commit | |
name: CI-dev | |
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 |