Fix a few code-formatting issues #4292
Workflow file for this run
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
name: CI | |
on: | |
pull_request: | |
push: | |
branches: | |
- "develop" | |
- "main" | |
jobs: | |
# Currently GH Actions provides no simple method for "sharing" | |
# our setup steps. Ideally this would be in an action, but we would need to use | |
# actions inside of our actions which you cannot currently do (see https://github.com/actions/runner/issues/438) | |
# | |
# As a result, the DRYest method for now is to use a testing matrix and | |
# use conditional steps for actually running the tests. | |
unittests: | |
runs-on: ubuntu-20.04 | |
strategy: | |
matrix: | |
test_env: [django, functional, api] | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v2 | |
- name: Cache Docker layers | |
uses: actions/cache@v3 | |
with: | |
path: /tmp/.buildx-cache | |
# using `-v3` in key to clear old cache due to errors | |
# See: https://stackoverflow.com/questions/63521430/clear-cache-in-github-actions | |
key: ${{ runner.os }}-buildx-v3-${{ github.sha }} | |
restore-keys: | | |
${{ runner.os }}-buildx-v3- | |
- name: Build Docker dev image | |
run: /usr/bin/docker buildx build --tag seedplatform/seed:develop --cache-from type=local,src=/tmp/.buildx-cache --cache-to type=local,dest=/tmp/.buildx-cache,mode=max --load --file Dockerfile-dev . | |
- name: Start the stack | |
env: | |
DJANGO_LOG_LEVEL: ERROR | |
run: | | |
docker volume create --name=seed_pgdata | |
docker volume create --name=seed_media | |
docker-compose -f docker-compose.yml -f docker-compose.dev.yml up -d | |
- name: Migrate | |
env: | |
DJANGO_LOG_LEVEL: ERROR | |
run: | | |
# verify no migrations need to be made... | |
docker exec seed_web python manage.py makemigrations --check --dry-run | |
# run migrations | |
docker exec --env DJANGO_LOG_LEVEL seed_web ./manage.py migrate | |
docker exec --env DJANGO_LOG_LEVEL seed_web ./manage.py create_default_user --username=demo@example.com --password=demo123 | |
docker exec --env DJANGO_LOG_LEVEL seed_web /bin/bash -c 'echo "y" | ./manage.py make_superuser --user demo@example.com' | |
- uses: actions/setup-node@v3 | |
- name: Install dependencies | |
run: | | |
npm install | |
sudo apt update | |
sudo apt install -y xvfb | |
# Available chrome-driver versions: https://chromedriver.storage.googleapis.com/ | |
# Available google-chrome versions: https://www.ubuntuupdates.org/package/google_chrome/stable/main/base/google-chrome-stable?id=202706 | |
# Lock to 114.0.5735.90 | |
wget --no-verbose -O /tmp/chrome.deb https://dl.google.com/linux/chrome/deb/pool/main/g/google-chrome-stable/google-chrome-stable_114.0.5735.90-1_amd64.deb | |
sudo apt install -y --allow-downgrades /tmp/chrome.deb | |
google-chrome --version | |
- name: Test Django | |
if: ${{ matrix.test_env == 'django' }} | |
env: | |
SEED_PM_UN: ${{ secrets.SEED_PM_UN }} | |
SEED_PM_PW: ${{ secrets.SEED_PM_PW }} | |
SF_INSTANCE: ${{ secrets.SF_INSTANCE }} | |
SF_USERNAME: ${{ secrets.SF_USERNAME }} | |
SF_PASSWORD: ${{ secrets.SF_PASSWORD }} | |
SF_DOMAIN: ${{ vars.SF_DOMAIN }} | |
SF_SECURITY_TOKEN: ${{ secrets.SF_SECURITY_TOKEN }} | |
COVERALLS_REPO_TOKEN: ${{ secrets.COVERALLS_REPO_TOKEN }} | |
DJANGO_LOG_LEVEL: ERROR | |
run: | | |
docker exec seed_web touch /seed/config/settings/local_untracked.py | |
docker exec --env SEED_PM_UN --env SEED_PM_PW --env DJANGO_LOG_LEVEL --env SF_INSTANCE --env SF_USERNAME --env SF_PASSWORD --env SF_SECURITY_TOKEN --env SF_DOMAIN seed_web coverage run manage.py test --settings=config.settings.docker_dev | |
if [[ ! -z "${COVERALLS_REPO_TOKEN}" ]]; then | |
docker exec --env COVERALLS_REPO_TOKEN seed_web coveralls | |
else | |
echo "INFO: Env var COVERALLS_REPO_TOKEN was not found, skipping coveralls update" | |
fi | |
- name: Test Frontend | |
if: ${{ matrix.test_env == 'functional' }} | |
env: | |
DISPLAY: ":99" | |
run: | | |
CHROME_VERSION=$(google-chrome --version | awk '{ print $NF }') | |
echo "Getting webdriver for chrome version ${CHROME_VERSION}" | |
./node_modules/protractor/bin/webdriver-manager update --versions.chrome=${CHROME_VERSION} --gecko=false | |
Xvfb :99 & | |
./node_modules/protractor/bin/protractor seed/static/seed/tests/protractor-tests/protractorConfig.js | |
- name: Test API | |
if: ${{ matrix.test_env == 'api' }} | |
run: | | |
docker exec seed_web ./manage.py create_test_user_json --username demo@example.com --host http://localhost --file ./seed/tests/api/api_test_user.json | |
docker exec seed_web python seed/tests/api/test_seed_host_api.py --noinput --nofile | |
- name: Web container logs | |
if: ${{ always() }} | |
run: docker logs seed_web | |
formatting: | |
runs-on: ubuntu-20.04 | |
strategy: | |
matrix: | |
tox_env: [docs, precommit, mypy] | |
steps: | |
- uses: actions/checkout@v3 | |
- uses: actions/setup-python@v4 | |
with: | |
python-version: "3.9" | |
- name: Install deps | |
run: | | |
pip install --upgrade pip | |
pip install tox==2.7.0 | |
sudo apt update | |
sudo apt install gdal-bin | |
- name: Setup config | |
run: | | |
cat <<EOF > config/settings/local_untracked.py | |
{ | |
'default': { | |
'BACKEND': 'django.core.cache.backends.locmem.LocMemCache', | |
} | |
} | |
EOF | |
- name: Run tox | |
run: tox -e ${{ matrix.tox_env }} |