Skip to content

Commit 3e340a4

Browse files
committed
Merge branch 'main' into feat/cli-scanner-tool
Signed-off-by: S3B4SZ17 <[email protected]>
2 parents b9dc1f0 + 045ccd6 commit 3e340a4

File tree

30 files changed

+1193
-104
lines changed

30 files changed

+1193
-104
lines changed

.github/workflows/helm_test.yaml

Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
---
2+
name: Lint & Test helm chart
3+
4+
on:
5+
pull_request:
6+
branches:
7+
- beta
8+
paths:
9+
- 'charts/**'
10+
push:
11+
branches:
12+
- main
13+
- beta
14+
paths:
15+
- 'charts/**'
16+
workflow_call:
17+
workflow_dispatch:
18+
19+
concurrency:
20+
group: 'helm-test-${{ github.workflow }}-${{ github.event.pull_request.head.label || github.head_ref || github.ref }}'
21+
cancel-in-progress: true
22+
23+
jobs:
24+
set-charts:
25+
# Required permissions
26+
permissions:
27+
contents: read
28+
pull-requests: read
29+
outputs:
30+
charts: ${{ steps.charts.outputs.changes }}
31+
name: "Set Charts"
32+
runs-on: [ubuntu-latest]
33+
steps:
34+
- uses: actions/checkout@v4
35+
- uses: dorny/paths-filter@v2
36+
id: charts
37+
with:
38+
base: ${{ github.ref_name }}
39+
filters: |
40+
sysdig-mcp:
41+
- 'charts/sysdig-mcp/**'
42+
lint-charts:
43+
needs: set-charts
44+
name: Lint new helm charts
45+
runs-on: [ubuntu-latest]
46+
strategy:
47+
matrix:
48+
chart: ${{ fromJSON(needs.set-charts.outputs.charts) }}
49+
# When set to true, GitHub cancels all in-progress jobs if any matrix job fails.
50+
fail-fast: false
51+
# The maximum number of jobs that can run simultaneously
52+
max-parallel: 3
53+
steps:
54+
55+
- uses: actions/checkout@v4
56+
with:
57+
fetch-depth: 0
58+
59+
- name: Set up Helm
60+
uses: azure/setup-helm@v4
61+
with:
62+
version: v3.5.0
63+
64+
- uses: actions/setup-python@v4
65+
with:
66+
python-version: '3.10'
67+
check-latest: true
68+
69+
- name: Set up chart-testing
70+
uses: helm/[email protected]
71+
72+
- name: Run chart-testing (list-changed)
73+
id: list-changed
74+
run: |
75+
changed=$(ct list-changed --target-branch ${{ github.event.repository.default_branch }} --chart-dirs charts)
76+
if [[ -n "$changed" ]]; then
77+
echo "changed=true" >> "$GITHUB_OUTPUT"
78+
fi
79+
80+
- name: Run chart-testing (lint)
81+
if: steps.list-changed.outputs.changed == 'true'
82+
run: ct lint --target-branch ${{ github.event.repository.default_branch }} --chart-dirs charts
83+
84+
- name: Create kind cluster
85+
if: steps.list-changed.outputs.changed == 'true'
86+
uses: helm/[email protected]
87+
88+
- name: Run chart-testing (install)
89+
if: steps.list-changed.outputs.changed == 'true'
90+
run: ct install --target-branch ${{ github.event.repository.default_branch }} --chart-dirs charts

.github/workflows/publish.yaml

Lines changed: 62 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,54 @@
1+
---
12
name: Publish Docker image
23

34
on:
45
push:
56
branches:
67
- main
8+
- beta
79
paths:
810
- pyproject.toml
11+
- Dockerfile
12+
- '*.py'
13+
- tests/**
14+
- tools/**
15+
- utils/**
916
workflow_dispatch:
10-
inputs:
11-
version:
12-
description: "Version to publish"
13-
required: false
14-
default: "latest"
15-
type: string
17+
18+
concurrency:
19+
group: 'publish-${{ github.workflow }}-${{ github.event.pull_request.head.label || github.head_ref || github.ref }}'
20+
cancel-in-progress: true
1621

1722
jobs:
23+
tests:
24+
permissions:
25+
checks: write
26+
pull-requests: write
27+
contents: write
28+
uses: ./.github/workflows/test.yaml
29+
secrets: inherit
1830
push_to_registry:
1931
name: Push Docker image to GitHub Packages
2032
runs-on: ubuntu-latest
33+
needs: tests
2134
permissions:
2235
contents: read # required for actions/checkout
2336
packages: write # required for pushing to ghcr.io
2437
id-token: write # required for signing with cosign
38+
outputs:
39+
version: ${{ steps.extract_version.outputs.VERSION }}
40+
tag: ${{ steps.extract_version.outputs.TAG }}
2541
steps:
2642
- name: Check out the repo
2743
uses: actions/checkout@v4
2844

2945
- name: Extract version
3046
id: extract_version
3147
run: |
32-
VERSION=$(grep 'version =' pyproject.toml | sed -e 's/version = "\(.*\)"/\1/')-$(echo $GITHUB_SHA | cut -c1-7)
48+
VERSION=$(grep 'version =' pyproject.toml | sed -e 's/version = "\(.*\)"/\1/')
3349
echo "VERSION=$VERSION" >> "$GITHUB_OUTPUT"
50+
TAG=v$(grep 'version =' pyproject.toml | sed -e 's/version = "\(.*\)"/\1/')
51+
echo "TAG=$TAG" >> "$GITHUB_OUTPUT"
3452
3553
- name: Log in to GitHub Container Registry
3654
uses: docker/login-action@v3
@@ -61,3 +79,40 @@ jobs:
6179
ghcr.io/sysdiglabs/sysdig-mcp-server:v${{ steps.extract_version.outputs.VERSION }}
6280
DIGEST: ${{ steps.build-and-push.outputs.digest }}
6381
run: echo "${TAGS}" | xargs -I {} cosign sign --yes {}@${DIGEST}
82+
83+
tag_release:
84+
name: Tag Release
85+
runs-on: ubuntu-latest
86+
needs: push_to_registry
87+
steps:
88+
- name: Check out repository
89+
uses: actions/checkout@v4
90+
with:
91+
ref: ${{ github.sha }} # required for better experience using pre-releases
92+
fetch-depth: '0' # Required due to the way Git works, without it this action won't be able to find any or the correct tags
93+
94+
- name: Get tag version
95+
id: semantic_release
96+
uses: anothrNick/[email protected]
97+
env:
98+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
99+
DEFAULT_BUMP: "patch"
100+
TAG_CONTEXT: 'repo'
101+
WITH_V: true
102+
PRERELEASE_SUFFIX: "beta"
103+
PRERELEASE: ${{ (github.base_ref == 'beta') && 'true' || (github.base_ref == 'main') && 'false' || (github.base_ref == 'integration') && 'false' || 'true' }}
104+
105+
- name: Summary
106+
run: |
107+
echo "## Release Summary
108+
- Tag: ${{ steps.semantic_release.outputs.tag }}
109+
- Docker Image: ghcr.io/sysdiglabs/sysdig-mcp-server:v${{ needs.push_to_registry.outputs.version }}" >> $GITHUB_STEP_SUMMARY
110+
111+
test_helm_chart:
112+
name: Test Helm Chart
113+
needs: push_to_registry
114+
permissions:
115+
contents: read # required for actions/checkout
116+
pull-requests: write # required for creating a PR with the chart changes
117+
uses: ./.github/workflows/helm_test.yaml
118+
secrets: inherit

.github/workflows/test.yaml

Lines changed: 63 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,21 @@
1+
---
12
name: Test
23

34
on:
4-
push:
5-
branches:
6-
- main
75
pull_request:
6+
paths:
7+
- pyproject.toml
8+
- Dockerfile
9+
- '*.py'
10+
- tests/**
11+
- tools/**
12+
- utils/**
13+
workflow_call:
14+
workflow_dispatch:
15+
16+
concurrency:
17+
group: 'tests-${{ github.workflow }}-${{ github.event.pull_request.head.label || github.head_ref || github.ref }}'
18+
cancel-in-progress: true
819

920
jobs:
1021
test:
@@ -34,3 +45,52 @@ jobs:
3445

3546
- name: Run Unit Tests
3647
run: make test
48+
49+
check_version:
50+
name: Check Version
51+
runs-on: ubuntu-latest
52+
needs: test
53+
permissions:
54+
contents: write # required for creating a tag
55+
steps:
56+
- name: Check out repository
57+
uses: actions/checkout@v4
58+
with:
59+
ref: ${{ github.sha }} # required for better experience using pre-releases
60+
fetch-depth: '0' # Required due to the way Git works, without it this action won't be able to find any or the correct tags
61+
62+
- name: Extract current version
63+
id: pyproject_version
64+
run: |
65+
TAG=v$(grep 'version =' pyproject.toml | sed -e 's/version = "\(.*\)"/\1/')
66+
echo "TAG=$TAG" >> "$GITHUB_OUTPUT"
67+
68+
- name: Get tag version
69+
id: semantic_release
70+
uses: anothrNick/[email protected]
71+
env:
72+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
73+
DEFAULT_BUMP: "patch"
74+
TAG_CONTEXT: 'repo'
75+
WITH_V: true
76+
PRERELEASE_SUFFIX: "beta"
77+
PRERELEASE: ${{ (github.base_ref == 'beta') && 'true' || (github.base_ref == 'main') && 'false' || (github.base_ref == 'integration') && 'false' || 'true' }}
78+
DRY_RUN: true
79+
80+
- name: Compare versions
81+
run: |
82+
echo "Current version: ${{ steps.pyproject_version.outputs.TAG }}"
83+
echo "New version: ${{ steps.semantic_release.outputs.tag }}"
84+
if [ "${{ steps.pyproject_version.outputs.TAG }}" != "${{ steps.semantic_release.outputs.tag }}" ]; then
85+
echo "### Version mismatch detected! :warning:
86+
Current pyproject version: ${{ steps.pyproject_version.outputs.TAG }}
87+
New Tag version: **${{ steps.semantic_release.outputs.tag }}**
88+
Current Tag: ${{ steps.semantic_release.outputs.old_tag }}
89+
Please update the version in pyproject.toml." >> $GITHUB_STEP_SUMMARY
90+
exit 1
91+
else
92+
echo "### Version match confirmed! :rocket:
93+
Current pyproject version: ${{ steps.pyproject_version.outputs.TAG }}
94+
New Tag version: **${{ steps.semantic_release.outputs.tag }}**
95+
The version is up-to-date." >> $GITHUB_STEP_SUMMARY
96+
fi

0 commit comments

Comments
 (0)