-
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 #4 from tryolabs/feature/part4
Feature/part4
- Loading branch information
Showing
7 changed files
with
138 additions
and
17 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,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 |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import pandas as pd | ||
|
||
from sklearn.model_selection import train_test_split | ||
from challenge.model import DelayModel | ||
|
||
model = DelayModel() | ||
data = pd.read_csv(filepath_or_buffer="data/data.csv") | ||
|
||
features, target = model.preprocess( | ||
data=data, | ||
target_column="delay" | ||
) | ||
|
||
_, features_validation, _, target_validation = train_test_split(features, target, test_size = 0.33, random_state = 42) | ||
|
||
model.fit( | ||
features=features, | ||
target=target | ||
) |
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 |
---|---|---|
|
@@ -4,7 +4,6 @@ pytest~=6.2.5 | |
pytest-cov~=2.12.1 | ||
mockito~=1.2.2 | ||
Jinja2~=3.0.3 | ||
Flask~=2.0.3 | ||
itsdangerous==2.0.1 | ||
Werkzeug==2.0.3 | ||
|
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 was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.