Skip to content

Commit

Permalink
Merge pull request #117 from Geosyntec/v0.5.0rc2
Browse files Browse the repository at this point in the history
V0.5.0rc2
  • Loading branch information
austinorr authored Feb 25, 2022
2 parents 33e8afe + 2b1f559 commit da8373f
Show file tree
Hide file tree
Showing 90 changed files with 1,707 additions and 893 deletions.
2 changes: 1 addition & 1 deletion .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
**/.pytest_cache
**/.mypy_cache
**/.coverage
**/.env
**/.env
76 changes: 76 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
name: Build and Push Image

on:
push:
branches:
- develop
- master
workflow_dispatch:

jobs:
build-and-push:
strategy:
fail-fast: false
matrix:
targets: [nereid, redis, celeryworker]
runs-on: ubuntu-latest
env:
DOCKER_BUILDKIT: 1
COMPOSE_DOCKER_CLI_BUILD: 1
steps:
- name: Checkout
uses: actions/checkout@v2

- name: Prepare
id: prep
run: |
DOCKER_IMAGE=${{ secrets.ACR_SERVER }}/nereid/${{ matrix.image }}
VERSION=edge
if [[ $GITHUB_REF == refs/tags/* ]]; then
VERSION=${GITHUB_REF#refs/tags/v}
fi
if [ "${{ github.event_name }}" = "schedule" ]; then
VERSION=nightly
fi
TAGS="${DOCKER_IMAGE}:${VERSION}"
if [[ $VERSION =~ ^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$ ]]; then
TAGS="$TAGS,${DOCKER_IMAGE}:latest"
fi
echo "tags: $TAGS"
echo ::set-output name=tags::${TAGS}
- name: Set up Docker Buildx
id: buildx
uses: docker/setup-buildx-action@v1

- name: Inspect builder
run: |
echo "Name: ${{ steps.buildx.outputs.name }}"
echo "Endpoint: ${{ steps.buildx.outputs.endpoint }}"
echo "Status: ${{ steps.buildx.outputs.status }}"
echo "Flags: ${{ steps.buildx.outputs.flags }}"
echo "Platforms: ${{ steps.buildx.outputs.platforms }}"
- name: Login to Azure
if: github.event_name != 'pull_request'
uses: docker/login-action@v1
with:
registry: ${{ secrets.ACR_SERVER }}
username: ${{ secrets.ACR_USERNAME }}
password: ${{ secrets.ACR_PASSWORD }}

- name: Build and Push
id: docker_build
uses: docker/build-push-action@v2
with:
builder: ${{ steps.buildx.outputs.name }}
context: ./nereid
file: ./nereid/Dockerfile.multi
target: ${{ matrix.image }}
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.prep.outputs.tags }}
cache-from: type=gha
cache-to: type=gha,mode=max

- name: Image digest
run: echo ${{ steps.docker_build.outputs.digest }}
20 changes: 11 additions & 9 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ on:
workflow_dispatch:
schedule:
# every other sunday at noon.
- cron: '0 12 1-7,15-21,29-31 * 0'
- cron: "0 12 1-7,15-21,29-31 * 0"

jobs:
python-test:
runs-on: ubuntu-latest
Expand All @@ -20,7 +20,7 @@ jobs:
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: 3.8
python-version: 3.9
- name: Install Deps
run: pip install -r nereid/requirements.txt -r nereid/requirements_tests.txt
- name: Run Tests
Expand All @@ -36,11 +36,11 @@ jobs:
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: 3.8
python-version: 3.9
- name: Install nereid as library
run: |
pip install .
pip install -r nereid/requirements_tests.txt
pip install .
pip install pytest
- name: Run Tests
run: pytest nereid/nereid/tests/test_src -xv

Expand All @@ -64,7 +64,7 @@ jobs:
- name: Run Edge Tests
continue-on-error: true
run: |
pytest nereid/nereid/tests/test_src -xv
pytest nereid/nereid/tests -xv
- name: Exit
run: exit 0

Expand All @@ -77,10 +77,12 @@ jobs:
- name: build stack
run: |
docker --version
bash ./scripts/build_deploy.sh
bash ./scripts/build_dev.sh
docker-compose up -d nereid-tests
- name: run tests
run: docker-compose exec -T nereid-tests coverage run -m pytest -xv
run: |
docker compose exec -T nereid-tests coverage run --branch -m pytest nereid/tests -xs
docker compose exec -T nereid-tests coverage run -a --branch -m pytest nereid/tests/test_api -xs --async
- name: coverage
run: |
docker-compose exec -T nereid-tests coverage report -mi
Expand Down
12 changes: 6 additions & 6 deletions docker-compose.deploy.images.yml
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
version: '3.7'
version: "3.7"
services:
nereid:
image: sitkacontainers.azurecr.io/ocstormwatertools/nereid_nereid:${NEREID_IMAGE_TAG:-latest}
image: ${ACR_SERVER}/nereid/nereid:${NEREID_IMAGE_TAG:-latest}
celeryworker:
image: sitkacontainers.azurecr.io/ocstormwatertools/nereid_celeryworker:${NEREID_IMAGE_TAG:-latest}
image: ${ACR_SERVER}/nereid/celeryworker:${NEREID_IMAGE_TAG:-latest}
nereid-tests:
image: sitkacontainers.azurecr.io/ocstormwatertools/nereid_nereid-tests:${NEREID_IMAGE_TAG:-latest}
image: ${ACR_SERVER}/nereid/nereid-tests:${NEREID_IMAGE_TAG:-latest}
redis:
image: sitkacontainers.azurecr.io/ocstormwatertools/nereid_redis:${NEREID_IMAGE_TAG:-latest}
image: ${ACR_SERVER}/nereid/redis:${NEREID_IMAGE_TAG:-latest}
flower:
image: sitkacontainers.azurecr.io/ocstormwatertools/nereid_flower:${NEREID_IMAGE_TAG:-latest}
image: ${ACR_SERVER}/nereid/flower:${NEREID_IMAGE_TAG:-latest}
2 changes: 2 additions & 0 deletions docker-compose.shared.env.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
version: '3.7'
services:
nereid:
environment:
- NEREID_ASYNC_MODE=replace
env_file:
- env.env
nereid-tests:
Expand Down
4 changes: 2 additions & 2 deletions docker-compose.shared.ports.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
version: '3.7'
services:
redis:
ports:
- 6379:6379
expose:
- 6379
nereid:
ports:
- '80:80'
Expand Down
4 changes: 1 addition & 3 deletions env.env
Original file line number Diff line number Diff line change
@@ -1,4 +1,2 @@
__CELERY_BROKER_URL=redis://guest@redis:6379/0
__CELERY_RESULT_BACKEND=redis://guest@redis:6379/0
CELERY_BROKER_URL=redis://redis:6379/0
CELERY_RESULT_BACKEND=redis://redis:6379/0
CELERY_RESULT_BACKEND=redis://redis:6379/0
40 changes: 38 additions & 2 deletions make.bat
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,14 @@ if /i %1 == up goto :up
if /i %1 == down goto :down
if /i %1 == typecheck goto :typecheck
if /i %1 == coverage goto :coverage
if /i %1 == coverage-sync goto :coverage-sync
if /i %1 == coverage-async goto :coverage-async
if /i %1 == coverage-all goto :coverage-all
if /i %1 == cover-src goto :cover-src
if /i %1 == dev-server goto :dev-server
if /i %1 == restart goto :restart
if /i %1 == lint goto :lint
if /i %1 == login goto :login

:help
echo Commands:
Expand All @@ -31,10 +35,15 @@ goto :eof

set COMPOSE_DOCKER_CLI_BUILD=1

:login
bash scripts/az-login.sh
goto :eof

:test
call make clean
call make restart
docker compose exec nereid-tests pytest %2 %3 %4 %5 %6
for /f "tokens=1,* delims= " %%a in ("%*") do set ALL_BUT_FIRST=%%b
docker compose exec nereid-tests pytest %ALL_BUT_FIRST%
goto :eof

:typecheck
Expand All @@ -59,7 +68,29 @@ goto :eof
:coverage
call make clean
call make restart
docker compose exec nereid-tests coverage run -m pytest -x
docker compose exec nereid-tests coverage run --branch -m pytest nereid/tests -xs
docker compose exec nereid-tests coverage report -m
goto :eof

:coverage-sync
call make clean
call make restart
docker compose exec nereid-tests coverage run --branch -m pytest nereid/tests -xs
docker compose exec nereid-tests coverage report -m --omit=*test*,*bg_*,*celery_*
goto :eof

:coverage-async
call make clean
call make restart
docker compose exec nereid-tests coverage run --branch -m pytest nereid/tests -xs --async
docker compose exec nereid-tests coverage report -m --omit=*test*,*_sync*
goto :eof

:coverage-all
call make clean
call make restart
docker compose exec nereid-tests coverage run --branch -m pytest nereid/tests -xs
docker compose exec nereid-tests coverage run -a --branch -m pytest nereid/tests/test_api -xs --async
docker compose exec nereid-tests coverage report -m
goto :eof

Expand All @@ -85,3 +116,8 @@ goto :eof
:lint
bash scripts/lint.sh
goto :eof

rem docker build --target nereid_install -t nereid_install -f nereid/Dockerfile.multi .
rem docker run -it -v %cd%:/nereid -p 8088:80 --expose 80 nereid_install bash
rem pip install -e .[app]
rem uvicorn nereid.main:app --port 80 --host 0.0.0.0 --reload
2 changes: 1 addition & 1 deletion nereid/.coveragerc
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@ branch = True
[report]
include = nereid/*.py
ignore_errors = True
omit = nereid/data/*
omit = nereid/data/*,*main.py
Loading

0 comments on commit da8373f

Please sign in to comment.