Skip to content

Commit

Permalink
Muck about with pipeline
Browse files Browse the repository at this point in the history
  • Loading branch information
tyler-romero committed Dec 8, 2023
1 parent 9b69008 commit f2d6a7b
Show file tree
Hide file tree
Showing 2 changed files with 117 additions and 21 deletions.
136 changes: 116 additions & 20 deletions .github/workflows/pipeline.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,14 @@
name: cicd
on: [push]

on:
push:
# All pushes
workflow_dispatch:
# This allows it to be triggered manually in the github console
# You could put inputs here, but we don't need them.
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
# This causes it to cancel previous in-progress actions in the same PR
cancel-in-progress: true
env:
PYTHON_VERSION: "3.11"
POETRY_VERSION: "1.5.1"
Expand Down Expand Up @@ -121,10 +129,7 @@ jobs:
if: always()
run: docker stop ${{ steps.start_container.outputs.container_id }}

# Run Groundlight SDK tests against the
# edge proxy endpoint set in nginx.conf file
# and run unit tests.
test-sdk-and-unit-tests:
test-general-edge-endpoint:
runs-on: ubuntu-22.04
steps:
- name: Check out code
Expand Down Expand Up @@ -168,19 +173,6 @@ jobs:
virtualenvs-in-project: true
installer-parallel: true

# Note that we're pulling the latest main from the SDK repo
# This might be ahead of what's published to pypi, but it's useful to test things before they're released.
- name: Checkout Groundlight SDK
uses: actions/checkout@v3
with:
repository: groundlight/python-sdk
path: groundlight-sdk

- name: Install Groundlight SDK dependencies
run: |
cd groundlight-sdk
make install
- name: Load Cached venv
id: cached-poetry-dependencies
uses: actions/cache@v3
Expand All @@ -197,6 +189,81 @@ jobs:
source test/setup_plain_test_env.sh
poetry run pytest -k "not test_motdet"
- name: Dump Logs from Docker Container
if: always()
run: docker logs ${{ steps.start_container.outputs.container_id }}

- name: Stop Docker Container
# This ensures that we always stop the container regardless of the outcomes of
# the previous steps
if: always()
run: docker stop ${{ steps.start_container.outputs.container_id }}

# Run Groundlight SDK tests against the edge proxy endpoint
test-sdk:
runs-on: ubuntu-22.04
steps:
- name: Check out code
uses: actions/checkout@v3

- name: Set up python
uses: actions/setup-python@v4
with:
python-version: ${{ env.PYTHON_VERSION }}

- name: Install Docker
run: |
sudo apt-get update
sudo apt-get remove moby-runc
sudo apt-get install apt-transport-https ca-certificates curl software-properties-common
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"
sudo apt-get update
sudo apt-get install docker-ce
- name: Build Docker Image
run: docker build --tag groundlight-edge .

- name: Start Docker Container
id: start_container
run: |
source test/setup_plain_test_env.sh
echo "EDGE_CONFIG=$EDGE_CONFIG"
container_id=$(docker run \
-e LOG_LEVEL=DEBUG \
-e EDGE_CONFIG \
-d -p 6717:6717 \
groundlight-edge)
echo "::set-output name=container_id::$container_id"
- name: Install poetry
uses: snok/install-poetry@v1
with:
version: ${{ env.POETRY_VERSION }}
virtualenvs-create: true
virtualenvs-in-project: true
installer-parallel: true

- name: Load Cached venv
id: cached-poetry-dependencies
uses: actions/cache@v3
with:
path: .venv
key: venv-${{ runner.os }}-${{ steps.setup-python.outputs.python-version }}-${{hashFiles('**/poetry.lock') }}

# Note that we're pulling the latest main from the SDK repo
# This might be ahead of what's published to pypi, but it's useful to test things before they're released.
- name: Checkout Groundlight SDK
uses: actions/checkout@v3
with:
repository: groundlight/python-sdk
path: groundlight-sdk

- name: Install Groundlight SDK dependencies
run: |
cd groundlight-sdk
make install
- name: Run Groundlight SDK tests against Prod API via Edge Proxy Endpoint
run: |
cd groundlight-sdk
Expand All @@ -211,4 +278,33 @@ jobs:
# This ensures that we always stop the container regardless of the outcomes of
# the previous steps
if: always()
run: docker stop ${{ steps.start_container.outputs.container_id }}
run: docker stop ${{ steps.start_container.outputs.container_id }}


build-push-edge-endpoint-multiplatform:
# if: github.ref == 'refs/heads/main' || github.event_name == 'workflow_dispatch')
# We only run this action if all the prior test actions succeed
needs:
- test-in-k3s
- test-motion-detection
- test-general-edge-endpoint
- test-sdk
runs-on: ubuntu-22.04
steps:
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v4
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: us-west-2
- name: Login to Amazon ECR
id: login-ecr
uses: aws-actions/amazon-ecr-login@v1
with:
mask-password: "true"
- name: Check out code
uses: actions/checkout@v4
- name: Build and Push Multiplatform edge-endpoint Image to ECR
timeout-minutes: 45
run:
./deploy/bin/build-push-edge-endpoint-image.sh
2 changes: 1 addition & 1 deletion test/api/test_image_queries.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ def test_post_image_query_want_async(gl: Groundlight, detector: Detector):
"""
image = Image.open("test/assets/dog.jpeg")
image_bytes = pil_image_to_bytes(img=image)
iq = gl.submit_image_query(detector=detector.id, image=image_bytes, wait=10.0, want_async=True)
iq = gl.submit_image_query(detector=detector.id, image=image_bytes, wait=0.0, want_async=True)
assert iq is not None, "ImageQuery should not be None."
assert iq.id.startswith("iq_"), "ImageQuery id should start with 'iq_' because it was created on the cloud."
assert iq.result is None, "Result should be None because the query is still being processed."
Expand Down

0 comments on commit f2d6a7b

Please sign in to comment.