-
Notifications
You must be signed in to change notification settings - Fork 10
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 #203 from DSC-McMaster-U/raymondtaoo/jenkins
Create Jenkins Pipeline
- Loading branch information
Showing
5 changed files
with
226 additions
and
14 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,49 @@ | ||
pipeline { | ||
agent any | ||
environment { | ||
// Path for homebrew installed Poetry | ||
PATH = "/opt/homebrew/bin:$PATH" | ||
} | ||
|
||
stages { | ||
stage('Checkout') { | ||
steps { | ||
// Make sure it is the correct branch | ||
git branch: 'main', url: 'https://github.com/DSC-McMaster-U/Auto-ML.git' | ||
} | ||
} | ||
|
||
stage('Set Up Backend Environment') { | ||
steps { | ||
dir('backend') { | ||
sh 'poetry install' | ||
} | ||
} | ||
} | ||
|
||
stage('Start FastAPI Server') { | ||
steps { | ||
dir('backend') { | ||
// Start FastAPI server | ||
sh 'poetry run uvicorn main:app --reload --host 0.0.0.0 --port 8000 &' | ||
// Add a sleep command to give the server time to start | ||
sh 'sleep 10' | ||
} | ||
} | ||
} | ||
|
||
stage('Run Tests') { | ||
steps { | ||
dir('backend') { | ||
sh 'poetry run pytest tests/api_test.py' | ||
} | ||
} | ||
} | ||
} | ||
post { | ||
always { | ||
// Commands to clean up, stop server, etc. | ||
sh 'kill $(lsof -t -i: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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
import requests | ||
import pytest | ||
|
||
BASE_URL = "http://127.0.0.1:8000" | ||
|
||
def test_root(): | ||
response = requests.get(f"{BASE_URL}/") | ||
assert response.status_code == 200 | ||
|
||
def test_python(): | ||
response = requests.get(f"{BASE_URL}/api/python") | ||
assert response.status_code == 200 | ||
|
||
def test_datasets(): | ||
response = requests.get(f"{BASE_URL}/api/datasets") | ||
assert response.status_code == 200 | ||
|
||
def test_bigquery(): | ||
response = requests.get(f"{BASE_URL}/api/bq?filename=sample_contacts") | ||
assert response.status_code == 200 | ||
|
||
def test_get_data(): | ||
response = requests.get(f"{BASE_URL}/api/data?filename=data") | ||
assert response.status_code == 200 | ||
|
||
def test_automl(): | ||
response = requests.get(f"{BASE_URL}/api/automl") | ||
assert response.status_code == 200 | ||
|
||
def test_upload_data(): | ||
url = f"{BASE_URL}/api/upload?filename=test-data" | ||
files = {'file': ('data.csv', open('data.csv', 'rb'), 'text/csv')} | ||
response = requests.put(url, files=files) | ||
assert response.status_code == 200 | ||
|
||
def test_eda(): | ||
response = requests.get(f"{BASE_URL}/api/eda?filename=data") | ||
assert response.status_code == 200 |