Skip to content

Commit

Permalink
Merge pull request #1290 from archesproject/1263-add-project-tests
Browse files Browse the repository at this point in the history
Add action to run project tests #1263
  • Loading branch information
chiatt authored Sep 14, 2023
2 parents 85f3904 + a47659f commit e2350cd
Show file tree
Hide file tree
Showing 3 changed files with 82 additions and 1 deletion.
64 changes: 64 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
name: CI

on:
# push: -- just run on PRs for now
pull_request:
workflow_dispatch:

jobs:
build:
runs-on: ubuntu-latest
services:
postgres:
image: postgis/postgis:13-3.0
env:
POSTGRES_PASSWORD: postgis
POSTGRES_DB: arches
ports:
- 5432:5432
options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5

steps:
- name: Check out arches
uses: actions/checkout@v3
with:
repository: archesproject/arches
ref: dev/7.5.x
path: arches

- name: Check out afs
uses: actions/checkout@v2
with:
path: afs

- name: Set up Python 3.10
uses: actions/setup-python@v4
with:
python-version: '3.10'

- name: Install afs
working-directory: afs
run: |
python -m pip install --upgrade pip
pip install .
echo Project installed
- name: Install Java, GDAL, and other system dependencies
run: |
sudo apt update
sudo apt-get install libxml2-dev libpq-dev openjdk-8-jdk libgdal-dev
echo Postgres and ES dependencies installed
- uses: ankane/setup-elasticsearch@v1
with:
elasticsearch-version: 8

- name: Check for missing migrations
working-directory: afs
run: |
PYTHONPATH="../arches" python manage.py makemigrations --check --settings=arches_for_science.test_settings
- name: Run afs unit tests
working-directory: afs
run: |
PYTHONPATH="../arches" python -W default::DeprecationWarning manage.py test --settings=arches_for_science.test_settings
11 changes: 11 additions & 0 deletions arches_for_science/test_settings.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import os

# Depends on /arches being on the python path, as arches.tests is not importable
from tests.test_settings import *

from arches_for_science.settings import INSTALLED_APPS, ROOT_URLCONF, APP_NAME
APP_ROOT = os.path.dirname(__file__)

# Further settings may need to be added from project, just don't
# want to clobber anything from core test settings for now.
# Also, settings can be overridden directly. See @override_settings
8 changes: 7 additions & 1 deletion arches_for_science/tests.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
import os
from pathlib import Path

from django.core.management import call_command

from django.test import TestCase
Expand All @@ -9,7 +12,10 @@
from arches.app.models.tile import Tile

def setUpModule():
call_command("packages", "-o load_package -s arches_for_science/pkg -y".split())
# TODO: when py 3.11 is min (soon), we can use contextlib.chdir() context mgr
os.chdir(Path(__file__).parent)
# TODO: this command isn't using a tempdir, so it's leaving behind files
call_command("packages", "-o load_package -s pkg -y".split())


class AnalysisAreaAndSampleTakingTests(TestCase):
Expand Down

0 comments on commit e2350cd

Please sign in to comment.