Skip to content

Commit

Permalink
Resolve "Add CodeQL to CI" (#49)
Browse files Browse the repository at this point in the history
  • Loading branch information
btschwertfeger authored Jan 13, 2025
1 parent ee5cb40 commit 358f0db
Show file tree
Hide file tree
Showing 4 changed files with 116 additions and 1 deletion.
81 changes: 81 additions & 0 deletions .github/workflows/_codeql.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
# For most projects, this workflow file will not need changing; you simply need
# to commit it to your repository.
#

name: CodeQL

on:
workflow_call:

# Don't change this permissions. These must match those of the analyze job.
permissions:
actions: read
contents: read
security-events: write

jobs:
analyze:
name: Analyze
runs-on: ubuntu-latest
permissions:
actions: read
contents: read
security-events: write

strategy:
fail-fast: false
matrix:
language: ["python"]
# CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python', 'ruby' ]
# Learn more about CodeQL language support at https://aka.ms/codeql-docs/language-support

steps:
- name: Harden Runner
uses: step-security/harden-runner@0080882f6c36860b6ba35c610c98ce87d4e2f26f # v2.10.2
with:
egress-policy: audit
disable-sudo: true
allowed-endpoints: >
api.github.com:443
api.securityscorecards.dev
github.com:443
uploads.github.com:443
- name: Checkout repository
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2

- name: "Dependency Review"
if: github.event_name == 'pull_request'
uses: actions/dependency-review-action@3b139cfc5fae8b618d3eae3675e383bb1769c019 # v4.5.0

# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
uses: github/codeql-action/init@48ab28a6f5dbc2a99bf1e0131198dd8f1df78169 # v3.28.0
with:
languages: python
# If you wish to specify custom queries, you can do so here or in a config file.
# By default, queries listed here will override any specified in a config file.
# Prefix the list here with "+" to use these queries and those in the config file.

# Details on CodeQL's query packs refer to : https://docs.github.com/en/code-security/code-scanning/automatically-scanning-your-code-for-vulnerabilities-and-errors/configuring-code-scanning#using-queries-in-ql-packs
queries: security-extended,security-and-quality

# Autobuild attempts to build any compiled languages (C/C++, C#, Go, or Java).
# If this step fails, then you should remove it and run the build manually (see below)
- name: Autobuild
uses: github/codeql-action/autobuild@48ab28a6f5dbc2a99bf1e0131198dd8f1df78169 # v3.28.0

# ℹ️ Command-line programs to run using the OS shell.
# 📚 See https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsrun

# If the Autobuild fails above, remove it and uncomment the following three lines.
# modify them (or add more) to build your code if your project, please refer to the EXAMPLE below for guidance.

# - run: |
# echo "Run, Build Application using script"
# ./location_of_script_within_repo/buildscript.sh

- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@48ab28a6f5dbc2a99bf1e0131198dd8f1df78169 # v3.28.0
with:
category: "/language:python"
13 changes: 13 additions & 0 deletions .github/workflows/cicd.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,19 @@ concurrency:
cancel-in-progress: true

jobs:
## ===========================================================================
## Checks the code logic, style and more
##
Pre-Commit:
uses: ./.github/workflows/_pre_commit.yaml

## ===========================================================================
## Discover vulnerabilities
##
CodeQL:
uses: ./.github/workflows/_codeql.yaml

## ===========================================================================
## Builds the package on multiple OS for multiple
## Python versions
##
Expand All @@ -43,6 +51,7 @@ jobs:
os: ${{ matrix.os }}
python-version: ${{ matrix.python-version }}

## ===========================================================================
## Build the Docker image
##
Build-Docker:
Expand All @@ -52,6 +61,7 @@ jobs:
with:
TAG: dev

## ===========================================================================
## Build the documentation
##
Build-Doc:
Expand All @@ -61,6 +71,7 @@ jobs:
os: "ubuntu-latest"
python-version: "3.11"

## ===========================================================================
## Run the unit and integration tests
##
Test:
Expand All @@ -85,6 +96,7 @@ jobs:
&& (github.event_name == 'push' || github.event_name == 'release')
needs:
- Build
- Build-Doc
- Test
name: Upload development version to Test PyPI
uses: ./.github/workflows/_pypi_test_publish.yaml
Expand All @@ -101,6 +113,7 @@ jobs:
&& github.event_name == 'release'
needs:
- Build
- Build-Doc
- Test
name: Upload release to PyPI
uses: ./.github/workflows/_pypi_publish.yaml
Expand Down
21 changes: 21 additions & 0 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# -*- coding: utf-8 -*-
# Copyright (C) 2025 Benjamin Thomas Schwertfeger
# GitHub: https://github.com/btschwertfeger
#

include README.md LICENSE pyproject.toml

graft src
prune .cache
prune .github
prune doc
prune tools
prune tests
prune .venv

prune .gitignore
prune .pre-commit-config.yaml
prune .readthedocs.yaml
prune Makefile
prune Dockerfile
prune docker-compose.yaml
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ package-dir = { "" = "src" }
[tool.setuptools.packages.find]
where = ["src"]
include = ["kraken_infinity_grid*"]
exclude = [".env", "tests"]
exclude = [".env", "tests", ".venv", "tools", ".github", ".cache"]

[tool.setuptools_scm]
write_to = "src/kraken_infinity_grid/_version.py"
Expand Down

0 comments on commit 358f0db

Please sign in to comment.