Skip to content

Commit df6b3fc

Browse files
authored
Merge pull request #4 from avinashbhatv/github-actions-ci
Add GitHub Actions CI and post-merge validation
2 parents e1c3ce8 + 6aae3f1 commit df6b3fc

6 files changed

Lines changed: 252 additions & 1 deletion

File tree

‎.github/workflows/ci-cd-pr.yml‎

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
name: CI-CD Pre-Merge Validation
2+
3+
on:
4+
pull_request:
5+
branches:
6+
- main
7+
push:
8+
branches:
9+
- github-actions-ci
10+
11+
permissions:
12+
contents: read
13+
14+
jobs:
15+
lint-test-build:
16+
runs-on: ubuntu-latest
17+
18+
steps:
19+
- name: Checkout Code
20+
uses: actions/checkout@v4
21+
22+
- name: Set up Python
23+
uses: actions/setup-python@v5
24+
with:
25+
python-version: '3.12'
26+
cache: 'pip'
27+
28+
- name: Upgrade pip
29+
run: |
30+
python -m pip install --upgrade pip
31+
32+
- name: Install Development Dependencies
33+
run: |
34+
python -m pip install -e '.[dev]'
35+
36+
- name: Run Ruff Lint
37+
continue-on-error: true
38+
run: |
39+
ruff check .
40+
41+
- name: Run Unit Tests
42+
run: |
43+
pytest -q
44+
45+
- name: Compile Python Sources
46+
run: |
47+
python -m compileall -q salt_config_cli
48+
49+
- name: Run Release Checks
50+
run: |
51+
python scripts/check_release.py

‎.github/workflows/docker-pr.yml‎

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
name: Docker Pre-Merge Validation
2+
3+
on:
4+
pull_request:
5+
branches:
6+
- main
7+
push:
8+
branches:
9+
- github-actions-ci
10+
11+
permissions:
12+
contents: read
13+
14+
jobs:
15+
docker-build:
16+
runs-on: ubuntu-latest
17+
18+
steps:
19+
- name: Checkout Code
20+
uses: actions/checkout@v4
21+
22+
- name: Set up Docker Buildx
23+
uses: docker/setup-buildx-action@v3
24+
25+
- name: Test Docker Image Build
26+
uses: docker/build-push-action@v6
27+
with:
28+
context: .
29+
file: docker/Dockerfile
30+
push: false
31+
tags: salt-cli-api:test
32+
build-args: |
33+
PIP_INDEX_URL=https://pypi.org/simple
34+
cache-from: type=gha,scope=raas-cli-docker
35+
cache-to: type=gha,mode=max,scope=raas-cli-docker

‎.github/workflows/package-pr.yml‎

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
name: Python Package Pre-Merge Validation
2+
3+
on:
4+
pull_request:
5+
branches:
6+
- main
7+
push:
8+
branches:
9+
- github-actions-ci
10+
11+
permissions:
12+
contents: read
13+
14+
jobs:
15+
package-check:
16+
runs-on: ubuntu-latest
17+
18+
steps:
19+
- name: Checkout Code
20+
uses: actions/checkout@v4
21+
22+
- name: Set up Python
23+
uses: actions/setup-python@v5
24+
with:
25+
python-version: '3.12'
26+
27+
- name: Install Build Tools
28+
run: |
29+
python -m pip install --upgrade pip
30+
python -m pip install build twine
31+
32+
- name: Build Package
33+
run: |
34+
python -m build
35+
36+
- name: Validate Package Metadata
37+
run: |
38+
python -m twine check dist/*

‎.github/workflows/post-merge.yml‎

Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
name: Post-Merge Build & Security Scan
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
8+
permissions:
9+
contents: read
10+
11+
jobs:
12+
build-and-scan:
13+
runs-on: ubuntu-latest
14+
15+
steps:
16+
- name: Checkout Code
17+
uses: actions/checkout@v4
18+
19+
# ------------------------------------------------------------
20+
# 1. Python Setup
21+
# ------------------------------------------------------------
22+
- name: Set up Python
23+
uses: actions/setup-python@v5
24+
with:
25+
python-version: '3.12'
26+
cache: 'pip'
27+
28+
- name: Upgrade pip
29+
run: |
30+
python -m pip install --upgrade pip
31+
32+
- name: Install Development Dependencies
33+
run: |
34+
python -m pip install -e '.[dev]'
35+
36+
# ------------------------------------------------------------
37+
# 2. Python Validation
38+
# ------------------------------------------------------------
39+
- name: Run Ruff Lint
40+
continue-on-error: true
41+
run: |
42+
ruff check .
43+
44+
- name: Run Unit Tests
45+
run: |
46+
pytest -q
47+
48+
- name: Run Release Checks
49+
run: |
50+
python scripts/check_release.py
51+
52+
# ------------------------------------------------------------
53+
# 3. Build Python Package
54+
# ------------------------------------------------------------
55+
- name: Build Python Package
56+
run: |
57+
python -m build
58+
59+
- name: List Python Build Artifacts
60+
run: |
61+
ls -lh dist/
62+
63+
# ------------------------------------------------------------
64+
# 4. Docker Build
65+
# ------------------------------------------------------------
66+
- name: Set up Docker Buildx
67+
uses: docker/setup-buildx-action@v3
68+
69+
- name: Build Docker Image Locally
70+
uses: docker/build-push-action@v6
71+
with:
72+
context: .
73+
file: docker/Dockerfile
74+
load: true
75+
push: false
76+
tags: salt-cli-api:local
77+
build-args: |
78+
PIP_INDEX_URL=https://pypi.org/simple
79+
cache-from: type=gha,scope=raas-cli
80+
cache-to: type=gha,mode=max,scope=raas-cli
81+
82+
# ------------------------------------------------------------
83+
# 5. Security Scan
84+
# ------------------------------------------------------------
85+
- name: Run Trivy Vulnerability Scan
86+
uses: aquasecurity/trivy-action@v0.36.0
87+
with:
88+
image-ref: 'salt-cli-api:local'
89+
format: 'table'
90+
exit-code: '0'
91+
ignore-unfixed: true
92+
vuln-type: 'os,library'
93+
severity: 'HIGH,CRITICAL'
94+
95+
- name: Show Docker Image
96+
run: |
97+
docker images salt-cli-api

‎.github/workflows/security-pr.yml‎

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
name: Security Pre-Merge Validation
2+
3+
on:
4+
pull_request:
5+
branches:
6+
- main
7+
push:
8+
branches:
9+
- github-actions-ci
10+
11+
permissions:
12+
contents: read
13+
14+
jobs:
15+
security-scan:
16+
runs-on: ubuntu-latest
17+
18+
steps:
19+
- name: Checkout Code
20+
uses: actions/checkout@v4
21+
22+
- name: Run Trivy Filesystem Scan
23+
uses: aquasecurity/trivy-action@v0.36.0
24+
with:
25+
scan-type: fs
26+
scan-ref: .
27+
format: table
28+
severity: HIGH,CRITICAL
29+
ignore-unfixed: true
30+
exit-code: '0'

‎tests/test_gitops_direct_v072.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,7 @@ def test_save_job_is_explicit_safe_and_contains_no_customer_values(
208208
by_name = {name: kwargs for name, kwargs in calls}
209209
assert list(name for name, _ in calls) == ["upload", "job-create", "run"]
210210
saved = by_name["job-create"]
211-
assert saved["kwargs"] == ("test=True",)
211+
assert saved["kwargs"] == ("test=False",)
212212
assert saved["pillars"] == ()
213213
assert saved["target_group"] == "prod-vcenters"
214214
assert by_name["run"]["test"] is False

0 commit comments

Comments
 (0)