Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
36 changes: 36 additions & 0 deletions .github/workflows/check_code_vulnerabilities.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
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:
# Using a matrix in case we need to test Javascript code in the future
language: ['python']

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

- 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}}"
30 changes: 30 additions & 0 deletions .github/workflows/check_lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
name: lint check

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

jobs:
ruff:
runs-on: ubuntu-latest

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

- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.13'
cache: 'pip'

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

- name: Run lint checks
run: |
ruff check
30 changes: 30 additions & 0 deletions .github/workflows/check_types.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
name: type check

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

jobs:
ty:
runs-on: ubuntu-latest

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

- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.13'
cache: 'pip'

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

- name: Run type checks
run: |
ty check
42 changes: 42 additions & 0 deletions .github/workflows/check_unit_tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
name: unit tests check

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

jobs:
pytest:
runs-on: ubuntu-latest

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

- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.13'
cache: 'pip'

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

- name: Run unit tests
shell: bash
run: |
pytest --cov=dibbs_text_to_code

- name: Generate coverage report
run: |
coverage xml -o coverage.xml

- name: Upload combined coverage to Codecov
uses: codecov/codecov-action@v4
with:
token: ${{ secrets.CODECOV_TOKEN }}
files: coverage.xml
verbose: true
26 changes: 26 additions & 0 deletions .github/workflows/slack_notifier_merged.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: "post merged pull to slack"

on:
pull_request_target:
branches: [main]
types:
- closed

jobs:
slack-pr-merged:
runs-on: ubuntu-latest
if: ${{ github.event.pull_request.merged }}

steps:
- name: Send GitHub trigger payload to Slack
uses: slackapi/slack-github-action@v2.1.1
with:
webhook: ${{ secrets.SLACK_WEBHOOK_URL }}
webhook-type: incoming-webhook
payload: |
text: ":github-merged: Pull request merged by ${{ github.event.pull_request.user.login }}\n\n<${{ github.event.pull_request.html_url }}|${{ github.event.pull_request.title }}>",
blocks:
- type: "section",
text:
type: "mrkdwn"
text: ":github-merged: Pull request merged by ${{ github.event.pull_request.user.login }}\n\n<${{ github.event.pull_request.html_url }}|${{ github.event.pull_request.title }}>"
52 changes: 52 additions & 0 deletions .github/workflows/slack_notifier_open_pulls.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
name: "post open pulls to slack"

on:
schedule:
# Run weekdays at 13:00 Eastern / 10:00 Pacific
- cron: "0 17 * * 1-5"

jobs:
list-open-prs:
runs-on: ubuntu-latest
permissions:
pull-requests: read
issues: read

steps:
- name: Check out the repository
uses: actions/checkout@v4

- name: List open pull requests
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GITHUB_REPO: ${{ github.repository }}
run: >
PR_LIST=$(scripts/open_pulls.sh)

MSG=":code-review: Open Pull Requests\n\n"

while IFS= read -r line; do
MSG+="$line\n"
done < <(echo "$PR_LIST" | jq -r '.[] | " - <\(.html_url)|\(.title)> opened by \(.user) \(.time_since) days ago"')

echo "MSG=$MSG" >> $GITHUB_ENV
# Check if PR_LIST is empty and set a flag
if [ "$PR_LIST" == "[]" ]; then
echo "SHOULD_POST_TO_SLACK=false" >> $GITHUB_ENV
else
echo "SHOULD_POST_TO_SLACK=true" >> $GITHUB_ENV
fi

- name: Post to Slack
uses: slackapi/slack-github-action@v2.1.1
if: ${{ env.SHOULD_POST_TO_SLACK == 'true' }}
with:
webhook: ${{ env.SLACK_WEBHOOK_URL }}
webhook-type: incoming-webhook
payload: |
text: "${{ env.MSG }}",
blocks:
- type: "section"
text:
type: "mrkdwn"
text: "${{ env.MSG }}"
29 changes: 29 additions & 0 deletions .github/workflows/slack_notifier_review.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
name: "post ready pull to slack"

on:
pull_request_target:
branches: [main]
types:
- opened
- reopened
- ready_for_review

jobs:
slack-ready-for-review:
runs-on: ubuntu-latest
if: ${{ !github.event.pull_request.draft }}

steps:
- name: Send GitHub trigger payload to Slack
uses: slackapi/slack-github-action@v2.1.1
with:
webhook: ${{ secrets.SLACK_WEBHOOK_URL }}
webhook-type: incoming-webhook
payload: |
text: ":pr-open: Pull request ready for review by ${{ github.event.pull_request.user.login }}\n\n<${{ github.event.pull_request.html_url }}|${{ github.event.pull_request.title }}>",
blocks:
- type: "section"
text:
type: "mrkdwn"
text: ":pr-open: Pull request ready for review by ${{ github.event.pull_request.user.login }}\n\n<${{ github.event.pull_request.html_url }}|${{ github.event.pull_request.title }}>"

19 changes: 17 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,13 +1,28 @@
# Build output
target/
*.class
*_version.py
*.egg-info
build/

# Log file
*.log

# Project environment files
.env

# Python-Virtual Environments
.venv
.python-version

# Python Cache
__pycache__/
.pytest_cache/

# Python-Coverage
.coverage
coverage.xml

# VS Code
/.vscode/settings.json
# Editor settings
/.vscode/settings.json
.exrc
7 changes: 7 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
repos:
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.12.3 # Ruff version.
hooks:
- id: ruff-check # Run the linter.
args: [ --fix ]
- id: ruff-format # Run the formatter.
16 changes: 14 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# DIBBs Text to Code

[![codecov](https://codecov.io/github/CDCgov/dibbs-text-to-code/graph/badge.svg)](https://codecov.io/github/CDCgov/dibbs-text-to-code)
[![python](https://img.shields.io/badge/python-3.11%2B-yellow)](https://docs.python.org/3.11/)

**General disclaimer** This repository was created for use by CDC programs to collaborate on public health related projects in support of the [CDC mission](https://www.cdc.gov/about/cdc/#cdc_about_cio_mission-our-mission). GitHub is not hosted by the CDC, but is a third party website used by CDC and its partners to share information and collaborate on software. CDC use of GitHub does not imply an endorsement of any one particular service, product, or enterprise.

## Related documents
Expand All @@ -21,11 +24,20 @@

### Pre-requisites

🚧 Under Construction 🚧
- Python 3.11 or higher
- [Docker](https://docs.docker.com/get-docker/)

### Setup

🚧 Under Construction 🚧
Set up a Python virtual environment and install the required development dependencies:
NOTE: Sourcing the script is recommended over simply executing the script. This allows
the virtual environment to stay active in your shell.

```bash
source scripts/bootstrap.sh
```

Note: If you are running in on a Windows machine, will need to run the bootstrap file directly with `./scripts/bootstrap.sh` and then activate the virtual environment by running `.\.venv\Scripts\Activate.ps1`.

### Testing

Expand Down
Loading
Loading