-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #6 from tryolabs/develop
Release 1
- Loading branch information
Showing
20 changed files
with
793 additions
and
33 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
*.env |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
name: 'Continuous Delivery' | ||
|
||
on: | ||
push: | ||
branches: | ||
- "main" | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
steps: | ||
# Checkout code | ||
- name: Checkout code | ||
uses: actions/checkout@v3 | ||
|
||
# Authenticate to Google Cloud | ||
- name: Authenticate to Google Cloud | ||
env: | ||
GOOGLE_CREDENTIALS: ${{ secrets.GOOGLE_CREDENTIALS }} | ||
run: | | ||
echo "$GOOGLE_CREDENTIALS" > /tmp/google-credentials.json | ||
gcloud auth activate-service-account --key-file=/tmp/google-credentials.json | ||
# Build and push Docker image | ||
- name: Build and push Docker image | ||
env: | ||
CONTAINER_IMAGE_URL: ${{ secrets.CONTAINER_IMAGE_URL }} | ||
GCLOUD_REGION: ${{ secrets.GCLOUD_REGION }} | ||
run: | | ||
docker build -t $CONTAINER_IMAGE_URL:latest . | ||
gcloud auth configure-docker $GCLOUD_REGION | ||
docker push $CONTAINER_IMAGE_URL:latest | ||
deploy: | ||
needs: build | ||
runs-on: ubuntu-latest | ||
steps: | ||
# Checkout code | ||
- name: Checkout code | ||
uses: actions/checkout@v3 | ||
|
||
# Authenticate to Google Cloud | ||
- id: 'auth' | ||
name: 'Authenticate to Google Cloud' | ||
uses: 'google-github-actions/auth@v1' | ||
with: | ||
credentials_json: '${{ secrets.GOOGLE_CREDENTIALS }}' | ||
|
||
# Deploy container to Cloud Run and capture URL | ||
- name: Deploy container to Cloud Run | ||
env: | ||
CONTAINER_IMAGE_URL: ${{ secrets.CONTAINER_IMAGE_URL }} | ||
GCLOUD_REGION: ${{ secrets.GCLOUD_REGION }} | ||
GCLOUD_PROJECT_ID: ${{ secrets.GCLOUD_PROJECT_ID }} | ||
id: deploy | ||
run: | | ||
echo "Deployment running." | ||
URL=$(gcloud run deploy latam-challenge \ | ||
--image=$CONTAINER_IMAGE_URL:latest \ | ||
--platform=managed \ | ||
--allow-unauthenticated \ | ||
--region=$GCLOUD_REGION \ | ||
--port=8000 \ | ||
--project=$GCLOUD_PROJECT_ID \ | ||
--format="value(status.url)") | ||
echo "::set-output name=url::$URL" | ||
echo "Image URL: $URL" | ||
# Set STRESS_URL environment variable for later use | ||
- name: Set STRESS_URL as env variable to use later the Makefile | ||
run: echo "STRESS_URL=${{ steps.deploy.outputs.url }}" >> $GITHUB_ENV | ||
|
||
# Run stress tests | ||
- name: Run stress tests | ||
run: | | ||
make stress-test STRESS_URL=${{ env.STRESS_URL }} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
name: 'Continuous Integration' | ||
|
||
on: | ||
pull_request: | ||
branches: | ||
- "develop" | ||
|
||
jobs: | ||
test: | ||
runs-on: ubuntu-latest | ||
steps: | ||
# Checkout code | ||
- name: Checkout code | ||
uses: actions/checkout@v3 | ||
|
||
# Setup Python | ||
- name: Setup Python | ||
uses: actions/setup-python@v4 | ||
with: | ||
python-version: "3.9" | ||
|
||
# Cache dependencies to speed up workflow | ||
- name: Cache dependencies | ||
uses: actions/cache@v3 | ||
with: | ||
path: ~/.cache/pip | ||
key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements*.txt') }} | ||
restore-keys: | | ||
${{ runner.os }}-pip- | ||
# Install dependencies | ||
- name: Install dependencies | ||
run: | | ||
python -m pip install --upgrade pip | ||
pip install -r requirements.txt -r requirements-dev.txt -r requirements-test.txt | ||
# Run tests | ||
- name: Run tests | ||
run: | | ||
make model-test | ||
make api-test |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,24 @@ | ||
# Environments | ||
.env | ||
.venv | ||
env/ | ||
*env/ | ||
venv/ | ||
|
||
# Unit test / coverage reports | ||
htmlcov/ | ||
.tox/ | ||
.nox/ | ||
.coverage | ||
.coverage.* | ||
.cache | ||
nosetests.xml | ||
coverage.xml | ||
*.cover | ||
*.py,cover | ||
.hypothesis/ | ||
.pytest_cache/ | ||
cover/ | ||
reports/ | ||
|
||
__pycache__/ | ||
/challenge/models |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,24 @@ | ||
# syntax=docker/dockerfile:1.2 | ||
FROM python:latest | ||
# put you docker configuration here | ||
FROM python:3.9-slim | ||
|
||
# Set the working directory | ||
WORKDIR /app | ||
|
||
# Install build dependencies | ||
RUN apt-get update && \ | ||
apt-get install -y build-essential gcc libssl-dev | ||
|
||
# Copy requirements files for the container | ||
COPY requirements*.txt ./ | ||
|
||
# Install Python dependencies | ||
RUN pip install -r requirements.txt -r requirements-dev.txt | ||
|
||
# Copy the entire project into the container | ||
COPY . . | ||
|
||
# Expose port | ||
EXPOSE 8000 | ||
|
||
# Run the application inside the container | ||
CMD ["uvicorn", "challenge.api:app", "--host", "0.0.0.0", "--port", "8000"] |
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
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
Oops, something went wrong.