Skip to content

Commit

Permalink
Merge pull request #33 from CSCI-GA-2820-FA23-001/luoyantao99-patch-1
Browse files Browse the repository at this point in the history
Create ci.yml
  • Loading branch information
luoyantao99 authored Nov 9, 2023
2 parents f303aca + 44fd889 commit 8d99467
Show file tree
Hide file tree
Showing 2 changed files with 75 additions and 1 deletion.
73 changes: 73 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
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
# use a known build environment
container: python:3.11-slim

# Required services
services:
# Label used to access the service container
postgres:
image: postgres
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@v2

- name: Install libraries for PostgreSQL
run: |
apt-get update
apt-get install -y gcc libpq-dev
- name: Install dependencies
run: |
python -m pip install --upgrade pip wheel
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
- 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
green -q
coverage report --fail-under=95
env:
DATABASE_URI: "postgresql://postgres:pgs3cr3t@postgres:5432/testdb"

- name: Upload code coverage
uses: codecov/codecov-action@v3.1.4
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# NYU DevOps Project Template

[![Build Status](https://github.com/CSCI-GA-2820-FA23-001/products/actions/workflows/ci.yml/badge.svg)](https://github.com/CSCI-GA-2820-FA23-001/products/actions)
[![codecov](https://codecov.io/gh/CSCI-GA-2820-FA23-001/products/graph/badge.svg?token=XFLEJRHXIJ)](https://codecov.io/gh/CSCI-GA-2820-FA23-001/products)
[![License](https://img.shields.io/badge/License-Apache_2.0-blue.svg)](https://opensource.org/licenses/Apache-2.0)
[![Python](https://img.shields.io/badge/Language-Python-blue.svg)](https://python.org/)

Expand Down

0 comments on commit 8d99467

Please sign in to comment.