Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

basic CI and fixing client linting #11

Merged
merged 8 commits into from
Jan 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
127 changes: 127 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,127 @@
name: CI
on:
pull_request:
types: [opened, synchronize]
push:
branches:
- "main"
env:
DJANGO_CONFIGURATION: DevelopmentConfiguration
DJANGO_DATABASE_URL: postgres://postgres:postgres@postgres:5432/django
DJANGO_CELERY_BROKER_URL: amqp://rabbitmq:5672/
DJANGO_MINIO_STORAGE_ACCESS_KEY: minioAccessKey
DJANGO_MINIO_STORAGE_SECRET_KEY: minioSecretKey
DJANGO_STORAGE_BUCKET_NAME: django-storage
jobs:
lint-python:
name: Lint Python
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Setup Python environment
uses: actions/setup-python@v4
with:
python-version: "3.10"
- name: Install pre-commit
run: pip install pre-commit
- name: Cache pre-commit hooks
uses: actions/cache@v3
with:
path: ~/.cache/pre-commit/
key: pre-commit-cache|${{ env.pythonLocation }}|${{ hashFiles('.pre-commit-config.yaml') }}
- name: Run pre-commit checks
run: pre-commit run --all-files
lint-node:
strategy:
fail-fast: false
matrix:
linter: [eslint, typescript]
name: Lint [${{ matrix.linter }}]
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Setup Node environment
uses: actions/setup-node@v4
with:
cache: npm
cache-dependency-path: client/package-lock.json
- name: Install packages
run: npm ci
working-directory: client
- name: Run ${{ matrix.linter }}
run: npm run lint:${{ matrix.linter }}
working-directory: client
test-django:
name: Test Django [${{ matrix.tox-env }}]
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
tox-env: [test, check-migrations]
services:
postgres:
image: postgis/postgis:latest
env:
POSTGRES_DB: django
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgres
ports:
- 5432:5432
rabbitmq:
image: rabbitmq:latest
ports:
- 5672:5672
minio:
# This image does not require any command arguments (which GitHub Actions don't support)
image: bitnami/minio:latest
env:
MINIO_ROOT_USER: minioAccessKey
MINIO_ROOT_PASSWORD: minioSecretKey
ports:
- 9000:9000
options: >-
--health-cmd "curl -I http://localhost:9000/minio/health/live"
--health-interval 10s
--health-timeout 5s
--health-retries 6
--health-start-period 30s

steps:
- name: Update Package References
run: sudo apt-get update
- name: Install system dependencies
run: apt-fast install --no-install-recommends --yes
libgdal30
libproj22
python3-cachecontrol
python3-dev
- name: Checkout repository
uses: actions/checkout@v4
- name: Setup Python environment
uses: actions/setup-python@v4
with:
python-version: "3.10"
- name: Install tox
run: pip install tox
- name: Run tests
run: tox -e ${{ matrix.tox-env }}
working-directory: bats_ai
test-vue:
name: Test [vue]
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Setup Node environment
uses: actions/setup-node@v4
with:
cache: npm
cache-dependency-path: client/package-lock.json
- name: Install packages
run: npm ci
working-directory: client
- name: Run tests
run: npm run test
working-directory: client
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ To do so, before running any `docker compose` commands, set any of the environme

The Django server must be informed about the changes:
* When running the "Develop with Docker" configuration, override the environment variables:
* `DJANGO_MINIO_STORAGE_MEDIA_URL`, using the port from `DOCKER_MINIO_PORT`.
* `DJANGO_MINIO_STORAGE_ENDPOINT`, using the port from `DOCKER_MINIO_PORT`.
* When running the "Develop Natively" configuration, override the environment variables:
* `DJANGO_DATABASE_URL`, using the port from `DOCKER_POSTGRES_PORT`
* `DJANGO_CELERY_BROKER_URL`, using the port from `DOCKER_RABBITMQ_PORT`
Expand Down
29 changes: 29 additions & 0 deletions bats_ai/core/migrations/0002_species.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# Generated by Django 4.1.13 on 2024-01-04 15:27

from django.db import migrations, models


class Migration(migrations.Migration):
dependencies = [
('core', '0001_initial'),
]

operations = [
migrations.CreateModel(
name='Species',
fields=[
(
'id',
models.BigAutoField(
auto_created=True, primary_key=True, serialize=False, verbose_name='ID'
),
),
('species_code', models.CharField(blank=True, max_length=10, null=True)),
('family', models.CharField(blank=True, max_length=50, null=True)),
('genus', models.CharField(blank=True, max_length=50, null=True)),
('species', models.CharField(blank=True, max_length=100, null=True)),
('common_name', models.CharField(blank=True, max_length=100, null=True)),
('species_code_6', models.CharField(blank=True, max_length=10, null=True)),
],
),
]
18 changes: 17 additions & 1 deletion bats_ai/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,23 @@ def DATABASES(self): # noqa


class DevelopmentConfiguration(BatsAiMixin, DevelopmentBaseConfiguration):
pass
SECRET_KEY = 'secretkey' # Dummy value for local development configuration

DEFAULT_FILE_STORAGE = 'minio_storage.storage.MinioMediaStorage'
MINIO_STORAGE_ENDPOINT = values.Value(
'localhost:9000',
)
MINIO_STORAGE_USE_HTTPS = values.BooleanValue(False)
MINIO_STORAGE_ACCESS_KEY = values.SecretValue()
MINIO_STORAGE_SECRET_KEY = values.SecretValue()
MINIO_STORAGE_MEDIA_BUCKET_NAME = values.Value(
environ_name='STORAGE_BUCKET_NAME',
environ_required=True,
)
MINIO_STORAGE_AUTO_CREATE_MEDIA_BUCKET = True
MINIO_STORAGE_AUTO_CREATE_MEDIA_POLICY = 'READ_WRITE'
MINIO_STORAGE_MEDIA_USE_PRESIGNED = True
MINIO_STORAGE_MEDIA_URL = 'http://127.0.0.1:9000/rdwatch'


class TestingConfiguration(BatsAiMixin, TestingBaseConfiguration):
Expand Down
Loading
Loading