Skip to content

Commit

Permalink
chore: adds semgrep pre-commit and CI action (#51)
Browse files Browse the repository at this point in the history
* chore: adds semgrep pre-commit and CI action

Signed-off-by: Jennifer Power <[email protected]>

* chore: run pre-commit install in CI step

Signed-off-by: Jennifer Power <[email protected]>

---------

Signed-off-by: Jennifer Power <[email protected]>
  • Loading branch information
jpower432 committed Oct 9, 2023
1 parent 1f01c71 commit b522388
Show file tree
Hide file tree
Showing 6 changed files with 143 additions and 134 deletions.
10 changes: 7 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ name: CI
on:
push:
pull_request:
branches: main
branches:
- main

concurrency:
group: ${{ github.ref }}-${{ github.workflow }}
Expand Down Expand Up @@ -36,11 +37,14 @@ jobs:

- name: Set up poetry and install
uses: ./.github/actions/setup-poetry

- name: Pre-commit install
run: make pre-commit

- name: Run checks
- name: Run linting checks
run: make lint

- name: Run bandit
- name: Run security checks
run: make security-check

- name: Check dependencies
Expand Down
3 changes: 2 additions & 1 deletion .github/workflows/codecov.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ name: Code Coverage Check

on:
pull_request:
branches: main
branches:
- main

jobs:
test:
Expand Down
13 changes: 13 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
repos:
- repo: https://github.com/returntocorp/semgrep
rev: v1.42.0
hooks:
- id: semgrep
name: Semgrep Python
types: [python]
args: ["--config", "p/python", "--error", --metrics=off]
- id: semgrep
name: Semgrep Bandit
types: [python]
exclude: "^tests/.+$"
args: ["--config", "p/bandit", "--error", --metrics=off]
7 changes: 5 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,14 @@ TESTS := tests
all: develop lint test
.PHONY: all

develop:
develop: pre-commit
@poetry install
@poetry shell
.PHONY: develop

pre-commit:
@poetry run pre-commit install

lint:
@poetry lock --check
@poetry run isort --profile=black --lines-after-imports=2 \
Expand Down Expand Up @@ -38,7 +41,7 @@ dep-cve-check:
.PHONY: dep-cve-check

security-check:
@poetry run bandit -r $(PYMODULE)
@poetry run pre-commit run semgrep --all-files
.PHONY: security-check

build: clean-build
Expand Down
Loading

0 comments on commit b522388

Please sign in to comment.