-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adds CodeQL, static analysis, and unit test checks (#12)
- Loading branch information
1 parent
04c7457
commit 00d84ee
Showing
3 changed files
with
137 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,4 @@ | ||
query-filters: | ||
|
||
paths-ignore: | ||
- tests/**/test_*.py |
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,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 |
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,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 |