generated from nyu-devops/project-template
-
Notifications
You must be signed in to change notification settings - Fork 2
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 #58 from CSCI-GA-2820-SP24-003/setup-ci-cd
Added CI workflow
- Loading branch information
Showing
5 changed files
with
70 additions
and
0 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,66 @@ | ||
name: CI Build | ||
on: | ||
push: | ||
branches: | ||
- master | ||
paths-ignore: | ||
- 'README.md' | ||
- '.vscode/**' | ||
|
||
pull_request: | ||
branches: | ||
- master | ||
paths-ignore: | ||
- 'README.md' | ||
- '.vscode/**' | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
container: python:3.11-slim | ||
|
||
# Required services | ||
services: | ||
postgres: | ||
image: postgres:15-alpine | ||
env: | ||
POSTGRES_PASSWORD: pgs3cr3t | ||
POSTGRES_DB: testdb | ||
ports: | ||
- 5432:5432 | ||
# Set health checks to wait until postgres has started | ||
options: >- | ||
--health-cmd pg_isready | ||
--health-interval 10s | ||
--health-timeout 5s | ||
--health-retries 5 | ||
# Steps for the build | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v3 | ||
|
||
- name: Install dependencies | ||
run: | | ||
python -m pip install -U pip poetry | ||
poetry config virtualenvs.create false | ||
poetry install | ||
- name: Linting | ||
run: | | ||
# stop the build if there are Python syntax errors or undefined names | ||
flake8 service tests --count --select=E9,F63,F7,F82 --show-source --statistics | ||
# check for complexity. The GitHub editor is 127 chars wide | ||
flake8 service tests --count --max-complexity=10 --max-line-length=127 --statistics | ||
# Run pylint on the service | ||
pylint service tests --max-line-length=127 | ||
- name: Run unit tests with green | ||
run: | | ||
export FLASK_APP=service:app | ||
pytest --pspec --cov=service --cov-fail-under=95 --disable-warnings | ||
env: | ||
DATABASE_URI: "postgresql+psycopg://postgres:pgs3cr3t@postgres:5432/testdb" | ||
|
||
- name: Upload code coverage | ||
uses: codecov/[email protected] |
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
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