Skip to content

Commit 7c11d2e

Browse files
committed
feat Updating overall code format/standards and added tests
Signed-off-by: S3B4SZ17 <[email protected]>
1 parent acdf52e commit 7c11d2e

32 files changed

+1670
-709
lines changed

.github/pull_request_template.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# PR Name
2+
3+
## Changes
4+
5+
Please provide a brief description of the major and minor changes made in this pull request.

.github/workflows/publish.yaml

Lines changed: 116 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,116 @@
1+
name: Publish Docker image
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
paths:
8+
- pyproject.toml
9+
workflow_dispatch:
10+
inputs:
11+
version:
12+
description: 'Version to publish'
13+
required: false
14+
default: 'latest'
15+
type: string
16+
17+
jobs:
18+
push_to_registry:
19+
name: Push Docker image to GitHub Packages
20+
runs-on: ubuntu-latest
21+
permissions:
22+
contents: read # required for actions/checkout
23+
packages: write # required for pushing to ghcr.io
24+
steps:
25+
- name: Check out the repo
26+
uses: actions/checkout@v4
27+
28+
- name: Setup python
29+
uses: actions/setup-python@v5
30+
with:
31+
python-version: '3.10'
32+
cache: 'poetry'
33+
34+
- name: Install dependencies
35+
run: poetry install
36+
37+
- name: Install uv
38+
uses: astral-sh/setup-uv@v5
39+
with:
40+
version: "0.7.17"
41+
42+
- name: Download dependencies
43+
run: |
44+
uv sync
45+
46+
- name: Run ruff
47+
run: |
48+
uvx ruff check --fix --config ruff.toml
49+
50+
- name: Run Unit Tests
51+
run: |
52+
uv run pytest --capture=tee-sys --junitxml=pytest.xml
53+
54+
- name: Run Test Coverage
55+
run: |
56+
uv run pytest --cov=. --cov-report=xml
57+
58+
- name: Extract version
59+
id: extract_version
60+
run: |
61+
VERSION=$(grep 'version =' pyproject.toml | sed -e 's/version = "\(.*\)"/\1/')-$(echo $GITHUB_SHA | cut -c1-7)
62+
echo "VERSION=$VERSION" >> "$GITHUB_OUTPUT"
63+
64+
- name: Log in to GitHub Container Registry
65+
uses: docker/login-action@v3
66+
with:
67+
registry: ghcr.io
68+
username: ${{ github.actor }}
69+
password: ${{ secrets.GITHUB_TOKEN }}
70+
71+
- name: Build and push Docker image
72+
uses: docker/build-push-action@v5
73+
with:
74+
context: .
75+
push: true
76+
tags: |
77+
ghcr.io/sysdiglabs/sysdig-mcp-server:latest
78+
ghcr.io/sysdiglabs/sysdig-mcp-server:v${{ steps.extract_version.outputs.VERSION }}
79+
80+
- name: "Check test reports exists"
81+
if: always()
82+
id: check-test-results-exists
83+
uses: andstor/file-existence-action@v3
84+
with:
85+
files: "pytest.xml, coverage.xml"
86+
87+
- name: Create pack-wise pytest report
88+
run: poetry run python .github/github_workflow_scripts/parse_junit_per_pack.py
89+
if: |
90+
always() &&
91+
steps.check-test-results-exists.outputs.files_exists == 'true' &&
92+
github.event.pull_request.head.repo.fork == false
93+
94+
- name: Upload junit & pack-wise pytest report
95+
uses: PaloAltoNetworks/[email protected]
96+
if: |
97+
always() &&
98+
steps.check-test-results-exists.outputs.files_exists == 'true' &&
99+
github.event.pull_request.head.repo.fork == false
100+
with:
101+
name: pytest
102+
path: |
103+
coverage.xml
104+
if-no-files-found: error
105+
106+
- name: Pytest coverage comment
107+
if: |
108+
always() &&
109+
steps.check-test-results-exists.outputs.files_exists == 'true' &&
110+
steps.check-test-results-exists.outputs.files_exists == 'true' &&
111+
! github.event.pull_request.head.repo.fork
112+
uses: MishaKav/[email protected]
113+
continue-on-error: true # may fail on output > 65k chars
114+
with:
115+
pytest-xml-coverage-path: coverage.xml
116+
junitxml-path: coverage.xml

.github/workflows/publish.yml

Lines changed: 0 additions & 41 deletions
This file was deleted.

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ htmlcov/
4444
.cache
4545
nosetests.xml
4646
coverage.xml
47+
pytest.xml
4748
*,cover
4849
.hypothesis/
4950
venv/

.pre-commit-config.yaml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
repos:
2+
- repo: local
3+
hooks:
4+
- id: ruff-format
5+
name: Ruff Format
6+
description: Format code with ruff.
7+
entry: bash -c 'uvx ruff format --config ruff.toml'
8+
language: system
9+
stages: ["commit", "push"]
10+
- id: ruff-check
11+
name: Ruff Check
12+
description: Check code style with ruff.
13+
entry: bash -c 'uvx ruff check --config ruff.toml'
14+
language: system
15+
stages: ["commit", "push"]

CODEOWNERS

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# These owners will be the default owners for everything in
2+
# the repo. Unless a later match takes precedence,
3+
# @S3B4SZ17 @alecron and @sysdiglabs/sysdig-training will be requested for
4+
# review when someone opens a pull request.
5+
* @S3B4SZ17 @alecron @sysdiglabs/sysdig-training

Dockerfile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,9 @@ COPY . /app
1111
RUN --mount=type=cache,target=/root/.cache/uv \
1212
--mount=type=bind,source=uv.lock,target=uv.lock \
1313
--mount=type=bind,source=pyproject.toml,target=pyproject.toml \
14-
uv sync --locked --no-install-project --no-editable
14+
uv sync --locked --no-install-project --no-editable --no-dev
1515
RUN --mount=type=cache,target=/root/.cache/uv \
16-
uv sync --locked --no-editable
16+
uv sync --locked --no-editable --no-dev
1717

1818
# Dinal image without uv
1919
FROM python:3.12-slim

0 commit comments

Comments
 (0)