Skip to content

Commit

Permalink
ci: dependencies, code scanning, tests
Browse files Browse the repository at this point in the history
  • Loading branch information
thekaveman committed Jan 30, 2025
1 parent 95e9167 commit a571487
Show file tree
Hide file tree
Showing 5 changed files with 153 additions and 0 deletions.
27 changes: 27 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# To get started with Dependabot version updates, you'll need to specify which
# package ecosystems to update and where the package manifests are located.
# Please see the documentation for all configuration options:
# https://help.github.com/github/administering-a-repository/configuration-options-for-dependency-updates

version: 2
updates:
- package-ecosystem: "pip"
directory: "/" # pyproject.toml
schedule:
interval: "daily"
commit-message:
prefix: "chore"
include: "scope"
labels:
- "dependencies"
- package-ecosystem: "github-actions"
# Workflow files stored in the
# default location of `.github/workflows`
directory: "/"
schedule:
interval: "daily"
commit-message:
prefix: "chore"
include: "scope"
labels:
- "dependencies"
1 change: 1 addition & 0 deletions .github/workflows/.python-version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
3.12
64 changes: 64 additions & 0 deletions .github/workflows/codeql.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
# https://codeql.github.com/
name: CodeQL

on:
push:
paths:
- "**.py"
pull_request:
branches: [main]
paths:
- "**.py"
schedule:
- cron: "24 9 * * 6"

jobs:
setup:
name: Set up CodeQL analysis
runs-on: ubuntu-latest
# Required permissions
permissions:
pull-requests: read
outputs:
# changes is a JSON array with names of all filters matching any of the changed files
languages: ${{ steps.filter.outputs.changes }}
steps:
- uses: actions/checkout@v4
- uses: dorny/paths-filter@v3
id: filter
with:
filters: |
python: "**.py"
codeql:
name: CodeQL Analyze
runs-on: ubuntu-latest
needs: setup
if: ${{ needs.setup.outputs.languages != '[]' }}
permissions:
actions: read
contents: read
security-events: write

strategy:
fail-fast: false
matrix:
# Parse JSON array containing names of all filters matching any of changed files
# e.g. ['javascript', 'python'] if both file types had changes
language: ${{ fromJSON(needs.setup.outputs.languages) }}

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

- name: Initialize CodeQL
uses: github/codeql-action/init@v3
with:
languages: ${{ matrix.language }}
# https://docs.github.com/en/code-security/code-scanning/creating-an-advanced-setup-for-code-scanning/customizing-your-advanced-setup-for-code-scanning#specifying-configuration-details-using-the-config-input
config: |
paths-ignore:
- tests
- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v3
18 changes: 18 additions & 0 deletions .github/workflows/dependency-triage.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
name: "Dependency PR triage"

on:
pull_request:
types: [opened]

jobs:
dependency-triage:
runs-on: ubuntu-latest
permissions:
pull-requests: write
# see https://docs.github.com/en/code-security/dependabot/working-with-dependabot/automating-dependabot-with-github-actions#responding-to-events
if: github.actor == 'dependabot[bot]' || github.actor == 'pre-commit-ci[bot]'
steps:
- name: add-label
uses: andymckay/labeler@master
with:
add-labels: "dependencies"
43 changes: 43 additions & 0 deletions .github/workflows/tests-pytest.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
name: Pytest

on: [push, pull_request, workflow_call]

jobs:
pytest:
runs-on: ubuntu-latest
permissions:
# Gives the action the necessary permissions for publishing new
# comments in pull requests.
pull-requests: write
# Gives the action the necessary permissions for pushing data to the
# python-coverage-comment-action branch, and for editing existing
# comments (to avoid publishing multiple comments in the same PR)
contents: write
steps:
- name: Check out code
uses: actions/checkout@v4

- uses: actions/setup-python@v5
with:
python-version-file: .github/workflows/.python-version
cache: pip
cache-dependency-path: "**/pyproject.toml"

- name: Install Python dependencies
run: pip install -e .[test]

- name: Run tests
run: ./tests/run.sh

- name: Upload coverage report
uses: actions/upload-artifact@v4
with:
name: coverage-report
path: tests/coverage

- name: Coverage comment
uses: py-cov-action/python-coverage-comment-action@v3
with:
GITHUB_TOKEN: ${{ github.token }}
MINIMUM_GREEN: 90
MINIMUM_ORANGE: 80

0 comments on commit a571487

Please sign in to comment.