Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding workflows for unit tests and linting #11

Merged
merged 18 commits into from
Sep 16, 2024
Merged
Show file tree
Hide file tree
Changes from 12 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
version: 2
updates:
- package-ecosystem: "pip"
directory: "/"
schedule:
interval: "weekly"
commit-message:
prefix: "[deps] "
open-pull-requests-limit: 3
ericbuckley marked this conversation as resolved.
Show resolved Hide resolved
37 changes: 37 additions & 0 deletions .github/workflows/check_code_vulnerabilities.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
name: code vulnerabilities check

on:
push:
branches: [main]
pull_request:
branches: [main]

jobs:
codeql:
runs-on: ubuntu-latest

permissions:
packages: read
actions: read
contents: read
security-events: write

strategy:
matrix:
language: ['python']

steps:
- name: Checkout code
uses: actions/checkout@v3

- name: Initialize CodeQL
uses: github/codeql-action/init@v3
with:
languages: ${{ matrix.language }}

- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v3
with:
category: "/language:${{matrix.language}}"
config: |
paths: ["src"]
35 changes: 35 additions & 0 deletions .github/workflows/check_lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
name: lint check

# When the workflow will be triggered
ericbuckley marked this conversation as resolved.
Show resolved Hide resolved
on:
push:
branches: [main]
pull_request:
branches: [main]

jobs:
lint:
runs-on: ubuntu-latest

steps:
# Step 1: Check out the repository
- name: Checkout code
uses: actions/checkout@v3

# Step 2: Set up Python
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.11'
cache: 'pip'

# Step 3: Install dependencies
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install '.[dev]'

# Step 4: Run lint checks
- name: Run lint checks
run: |
ruff check src/
65 changes: 65 additions & 0 deletions .github/workflows/check_unit_tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
name: unit tests check

# When the workflow will be triggered
on:
push:
branches: [main]
ericbuckley marked this conversation as resolved.
Show resolved Hide resolved
pull_request:
branches: [main]

jobs:
test:
runs-on: ubuntu-latest

services:
postgres:
image: postgres:13 # Use the latest version of PostgreSQL you need
ports:
- 5432:5432
env:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: pw
POSTGRES_DB: testdb
options: >-
--health-cmd "pg_isready -U testuser"
--health-interval 10s
--health-timeout 5s
--health-retries 5

steps:
# Step 1: Check out the repository
- name: Checkout code
uses: actions/checkout@v3

# Step 2: Set up Python
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.11'
cache: 'pip'

# Step 3: Install dependencies
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install '.[dev]'

# Step 4: Wait for PostgreSQL to be ready
- name: Wait for PostgreSQL to be ready
run: |
until pg_isready -h localhost -p 5432 -U postgres; do
echo "Waiting for PostgreSQL to be ready..."
sleep 1
done

# Step 5: Run the tests
- name: Run unit tests
env:
MPI_DB_TYPE: postgres
ericbuckley marked this conversation as resolved.
Show resolved Hide resolved
MPI_DBNAME: testdb
MPI_HOST: localhost
MPI_PORT: 5432
MPI_USER: postgres
MPI_PASSWORD: pw
run: |
pytest --cov=recordlinker --cov-report=xml tests/unit
8 changes: 0 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,14 +45,6 @@ To run a single unit test, use the following command:
./scripts/test_unit.sh tests/unit/test_linkage.py::test_link_record_against_mpi
```

### Building the Docker Image

To build the Docker image for the record linkage service from source code instead of downloading it from the DIBBs repository follow these steps.
1. Ensure that both [Git](https://git-scm.com/book/en/v2/Getting-Started-Installing-Git) and [Docker](https://docs.docker.com/get-docker/) are installed.
2. Clone the DIBBs repository with `git clone https://github.com/CDCgov/phdi`.
3. Navigate to `/phdi/containers/record-linkage/`.
4. Run `docker build -t record-linkage .`.

## Standard Notices

### Public Domain Standard Notice
Expand Down
3 changes: 1 addition & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,8 @@ dependencies = [
[project.optional-dependencies]
dev = [
"pytest>=8.3",
"pytest-cov",
"ruff",
"pip-audit",
"bandit",
"mypy",
"pyarrow",
"httpx"
Expand Down
11 changes: 0 additions & 11 deletions scripts/vulnerability_check.sh

This file was deleted.

2 changes: 1 addition & 1 deletion src/recordlinker/config.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
from functools import lru_cache
from typing import Optional

from pydantic_settings import BaseSettings
from pydantic import Field
from pydantic_settings import BaseSettings


class Settings(BaseSettings):
Expand Down
1 change: 1 addition & 0 deletions src/recordlinker/linkage/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

from pydantic_settings import BaseSettings


class DBSettings(BaseSettings):
mpi_db_type: str
mpi_dbname: str
Expand Down
Loading