Skip to content

Commit

Permalink
Adds CodeQL, static analysis, and unit test checks (#12)
Browse files Browse the repository at this point in the history
  • Loading branch information
chrisguidry authored Aug 2, 2024
1 parent 04c7457 commit 00d84ee
Show file tree
Hide file tree
Showing 3 changed files with 137 additions and 0 deletions.
4 changes: 4 additions & 0 deletions .github/codeql-config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
query-filters:

paths-ignore:
- tests/**/test_*.py
78 changes: 78 additions & 0 deletions .github/workflows/static-analysis.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
name: Static analysis

on:
push:
branches:
- main

pull_request:
branches:
- main
paths:
- .github/workflows/static-analysis.yaml
- "**/*.py"
- requirements.txt
- requirements-dev.txt
- pyproject.toml

permissions:
contents: read

concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
cancel-in-progress: ${{ github.event_name == 'pull_request' }}

jobs:
pre-commit-checks:
name: Pre-commit checks
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4
with:
persist-credentials: false
fetch-depth: 0

- name: Set up Python
uses: actions/setup-python@v5
id: setup_python
with:
python-version: "3.12.4"

- name: UV Cache
uses: actions/cache@v4
id: cache-uv
with:
path: ~/.cache/uv
key: uvcache-${{ runner.os }}-${{ steps.setup_python.outputs.python-version }}-${{ hashFiles('requirements.txt', 'requirements-dev.txt') }}

- name: Install packages
run: |
python -m pip install -U uv pre-commit
uv pip install --upgrade --system -r requirements-dev.txt
- name: Run pre-commit
run: pre-commit run --show-diff-on-failure --color=always --all-files

analyze:
name: Analyze
runs-on: ubuntu-latest

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

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

- name: Initialize CodeQL
uses: github/codeql-action/init@v3
with:
languages: python
config-file: ./.github/codeql-config.yml
queries: security-extended

- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v3
55 changes: 55 additions & 0 deletions .github/workflows/unit-tests.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
name: Unit tests

on:
push:
branches:
- main

pull_request:
branches:
- main
paths:
- .github/workflows/unit-tests.yaml
- "**/*.py"
- requirements.txt
- requirements-dev.txt
- pyproject.toml

permissions:
contents: read

concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
cancel-in-progress: ${{ github.event_name == 'pull_request' }}

jobs:
unit-tests:
name: Unit tests
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4
with:
persist-credentials: false
fetch-depth: 0

- name: Set up Python
uses: actions/setup-python@v5
id: setup_python
with:
python-version: "3.12.4"

- name: UV Cache
uses: actions/cache@v4
id: cache-uv
with:
path: ~/.cache/uv
key: uvcache-${{ runner.os }}-${{ steps.setup_python.outputs.python-version }}-${{ hashFiles('requirements.txt', 'requirements-dev.txt') }}

- name: Install packages
run: |
python -m pip install -U uv pre-commit
uv pip install --upgrade --system -r requirements-dev.txt
- name: Run pytest
run: pytest

0 comments on commit 00d84ee

Please sign in to comment.