Skip to content

Commit 54a8b48

Browse files
committed
Some workflow updates
1 parent 8511872 commit 54a8b48

File tree

5 files changed

+167
-12
lines changed

5 files changed

+167
-12
lines changed

.github/workflows/ci.yml

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,6 @@ jobs:
2020
- name: Checkout code
2121
uses: actions/checkout@85e6279cec87321a52edac9c87bce653a07cf6c2
2222

23-
- name: Setup Python ${{ matrix.python-version }}
24-
uses: actions/setup-python@5db1cf9a59fb97c40a68accab29236f0da7e94db
25-
with:
26-
python-version: ${{ matrix.python-version }}
27-
2823
- name: Install Poetry
2924
uses: abatilo/actions-poetry@b8f6fe29ba2eb78e0d45ccbf41cd14154c4e25b2
3025

@@ -33,13 +28,11 @@ jobs:
3328
poetry config virtualenvs.create true --local
3429
poetry config virtualenvs.in-project true --local
3530
36-
- name: Cache dependencies
37-
uses: actions/cache@5a3ec84eff668545956fd18022155c47e93e2684 # v4.2.3
31+
- name: Setup Python ${{ matrix.python-version }}
32+
uses: actions/setup-python@5db1cf9a59fb97c40a68accab29236f0da7e94db
3833
with:
39-
path: ./.venv
40-
key: venv-${{ runner.os }}-py${{ matrix.python-version }}-${{ hashFiles('poetry.lock') }}
41-
restore-keys: |
42-
venv-${{ runner.os }}-py${{ matrix.python-version }}-
34+
python-version: ${{ matrix.python-version }}
35+
cache: "poetry"
4336

4437
- name: Install package
4538
run: poetry install --all-extras
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
---
2+
name: "Semantic Lints PR"
3+
on:
4+
pull_request:
5+
branches:
6+
- main
7+
types:
8+
- opened
9+
- edited
10+
- synchronize
11+
- reopened
12+
13+
permissions:
14+
pull-requests: read
15+
16+
jobs:
17+
main:
18+
name: Validate PR title
19+
runs-on: ubuntu-latest
20+
steps:
21+
- uses: amannn/action-semantic-pull-request@0723387faaf9b38adef4775cd42cfd5155ed6017 # v5.5.3
22+
env:
23+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

.github/workflows/semgrep.yaml

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
---
2+
name: Semgrep Analysis
3+
on:
4+
merge_group:
5+
pull_request:
6+
branches:
7+
- main
8+
types:
9+
- opened
10+
- synchronize
11+
- reopened
12+
push:
13+
branches:
14+
- main
15+
schedule:
16+
- cron: "0 0 * * *" # Run daily at midnight UTC
17+
18+
concurrency:
19+
group: pre-commit-${{ github.run_id }}
20+
cancel-in-progress: true
21+
22+
permissions:
23+
actions: read
24+
checks: write
25+
contents: read
26+
pull-requests: write # Allows merge queue updates
27+
security-events: write # Required for GitHub Security tab
28+
29+
jobs:
30+
semgrep:
31+
name: Semgrep Analysis
32+
runs-on: ubuntu-latest
33+
container:
34+
image: returntocorp/semgrep
35+
36+
# Skip any PR created by dependabot to avoid permission issues:
37+
if: (github.actor != 'dependabot[bot]')
38+
39+
steps:
40+
- name: Set up git repository
41+
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
42+
with:
43+
token: ${{ secrets.GITHUB_TOKEN }}
44+
45+
- name: Configure Git Safe Directory
46+
run: git config --global --add safe.directory "${GITHUB_WORKSPACE}"
47+
48+
- name: Semgrep Analysis
49+
env:
50+
SEMGREP_RULES: >-
51+
p/python
52+
p/security-audit
53+
p/secrets
54+
p/owasp-top-ten
55+
p/supply-chain
56+
SEMGREP_TIMEOUT: 300 # 5-minute timeout per rule
57+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
58+
run: |
59+
semgrep ci \
60+
--config="${SEMGREP_RULES}" \
61+
--timeout="${SEMGREP_TIMEOUT}" \
62+
--sarif --output=semgrep-results.sarif
Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
---
2+
name: Template Sync
3+
on:
4+
# checkov:skip=CKV_GHA_7: "Workflow dispatch inputs are required for manual debugging and configuration"
5+
workflow_dispatch:
6+
inputs:
7+
dryRun:
8+
description: Dry Run
9+
default: "false"
10+
required: false
11+
logLevel:
12+
description: Log Level
13+
default: "debug"
14+
required: false
15+
16+
schedule:
17+
# Run on the 1st of every month at 00:00 UTC
18+
- cron: "0 0 1 * *"
19+
20+
push:
21+
branches: ["main"]
22+
paths:
23+
- ".github/**"
24+
- ".hooks/**"
25+
- ".pre-commit-config.yaml"
26+
- ".mdlrc"
27+
- ".editorconfig"
28+
- "Taskfile.yaml"
29+
- ".task/**"
30+
31+
permissions:
32+
contents: write
33+
pull-requests: write
34+
35+
concurrency:
36+
group: ${{ github.workflow }}-${{ github.run_number || github.ref }}
37+
cancel-in-progress: true
38+
39+
jobs:
40+
template-sync:
41+
name: Template Sync
42+
runs-on: ubuntu-latest
43+
steps:
44+
- name: Generate Token
45+
uses: actions/create-github-app-token@df432ceedc7162793a195dd1713ff69aefc7379e # v2.0.6
46+
id: app-token
47+
with:
48+
app-id: "${{ secrets.BOT_APP_ID }}"
49+
private-key: "${{ secrets.BOT_APP_PRIVATE_KEY }}"
50+
owner: "${{ github.repository_owner }}"
51+
52+
- name: Checkout
53+
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
54+
with:
55+
token: "${{ steps.app-token.outputs.token }}"
56+
57+
- name: Template Sync
58+
uses: AndreasAugustin/actions-template-sync@v2
59+
with:
60+
source_gh_token: ${{ steps.app-token.outputs.token }}
61+
git_user_name: github-actions[bot]
62+
git_user_email: github-actions[bot]@users.noreply.github.com
63+
pr_title: "chore: sync infrastructure files with template"
64+
pr_labels: sync,template
65+
pr_body: |
66+
🤖 A new version of the python template files is available.
67+
68+
This PR was automatically created to sync the following:
69+
- GitHub Actions workflows
70+
- Pre-commit hooks and configs
71+
- Task definitions
72+
- Editor configs and linter rules
73+
74+
Please review the changes carefully before merging.
75+
source_repo_path: dreadnode/python-template
76+
steps: "prechecks,pull,commit,push,pr"
77+
upstream_branch: main

.github/scripts/generate_pr_description.py renamed to .hooks/generate_pr_description.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ def main(
6666
base_ref: str = "origin/main",
6767
source_ref: str = "HEAD",
6868
generator_id: str = "openai/gpt-4o-mini",
69-
max_diff_lines: int = 1000,
69+
max_diff_lines: int = 10_000,
7070
exclude: list[str] | None = None,
7171
) -> None:
7272
"""

0 commit comments

Comments
 (0)