Skip to content

Commit 61ecc79

Browse files
feat: Add CI, CodeQL, and Release workflows for automated testing, security analysis, and builds
1 parent de2a291 commit 61ecc79

3 files changed

Lines changed: 271 additions & 0 deletions

File tree

.github/workflows/ci.yml

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
# CI Testing Workflow
2+
# Runs tests on every push and pull request across multiple Python versions and OS platforms
3+
4+
name: CI Tests
5+
6+
on:
7+
push:
8+
branches: [main, develop]
9+
pull_request:
10+
branches: [main]
11+
12+
jobs:
13+
test:
14+
name: Test (Python ${{ matrix.python-version }}, ${{ matrix.os }})
15+
runs-on: ${{ matrix.os }}
16+
strategy:
17+
fail-fast: false
18+
matrix:
19+
os: [ubuntu-latest, windows-latest, macos-latest]
20+
python-version: ['3.10', '3.11', '3.12', '3.13']
21+
22+
steps:
23+
- name: Checkout code
24+
uses: actions/checkout@v4
25+
26+
- name: Set up Python ${{ matrix.python-version }}
27+
uses: actions/setup-python@v5
28+
with:
29+
python-version: ${{ matrix.python-version }}
30+
31+
- name: Install dependencies
32+
run: |
33+
python -m pip install --upgrade pip
34+
pip install -r requirements.txt
35+
36+
- name: Run tests
37+
run: |
38+
pytest -v --tb=short
39+
40+
- name: Run smoke tests
41+
run: |
42+
pytest tests/test_release_smoke.py -v
43+
44+
coverage:
45+
name: Coverage Report
46+
runs-on: ubuntu-latest
47+
needs: test
48+
49+
steps:
50+
- name: Checkout code
51+
uses: actions/checkout@v4
52+
53+
- name: Set up Python
54+
uses: actions/setup-python@v5
55+
with:
56+
python-version: '3.12'
57+
58+
- name: Install dependencies
59+
run: |
60+
python -m pip install --upgrade pip
61+
pip install -r requirements.txt
62+
pip install coverage
63+
64+
- name: Run tests with coverage
65+
run: |
66+
coverage run -m pytest
67+
coverage report -m
68+
coverage xml
69+
70+
- name: Upload coverage to Codecov
71+
uses: codecov/codecov-action@v4
72+
with:
73+
files: coverage.xml
74+
fail_ci_if_error: false
75+
continue-on-error: true

.github/workflows/codeql.yml

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
# CodeQL Security Analysis
2+
# Scans code for security vulnerabilities and coding errors
3+
4+
name: CodeQL Security
5+
6+
on:
7+
push:
8+
branches: [main]
9+
pull_request:
10+
branches: [main]
11+
schedule:
12+
# Run weekly on Sundays at midnight UTC
13+
- cron: '0 0 * * 0'
14+
15+
jobs:
16+
analyze:
17+
name: Analyze
18+
runs-on: ubuntu-latest
19+
permissions:
20+
actions: read
21+
contents: read
22+
security-events: write
23+
24+
strategy:
25+
fail-fast: false
26+
matrix:
27+
language: [python]
28+
29+
steps:
30+
- name: Checkout repository
31+
uses: actions/checkout@v4
32+
33+
- name: Initialize CodeQL
34+
uses: github/codeql-action/init@v3
35+
with:
36+
languages: ${{ matrix.language }}
37+
# Use extended security queries for more thorough analysis
38+
queries: +security-extended,security-and-quality
39+
40+
- name: Autobuild
41+
uses: github/codeql-action/autobuild@v3
42+
43+
- name: Perform CodeQL Analysis
44+
uses: github/codeql-action/analyze@v3
45+
with:
46+
category: "/language:${{ matrix.language }}"

.github/workflows/release.yml

Lines changed: 150 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,150 @@
1+
# Release Build Workflow
2+
# Automatically builds Windows executable and creates GitHub release when a version tag is pushed
3+
4+
name: Release Build
5+
6+
on:
7+
push:
8+
tags:
9+
- 'v*'
10+
11+
permissions:
12+
contents: write
13+
14+
jobs:
15+
build-windows:
16+
name: Build Windows Executable
17+
runs-on: windows-latest
18+
19+
steps:
20+
- name: Checkout code
21+
uses: actions/checkout@v4
22+
23+
- name: Set up Python
24+
uses: actions/setup-python@v5
25+
with:
26+
python-version: '3.12'
27+
28+
- name: Install dependencies
29+
run: |
30+
python -m pip install --upgrade pip
31+
pip install -r requirements.txt
32+
pip install pyinstaller
33+
34+
- name: Run tests
35+
run: |
36+
pytest tests/test_release_smoke.py -v
37+
38+
- name: Build executable
39+
run: |
40+
pyinstaller --onefile --name TechCompressor --console techcompressor/cli.py
41+
42+
- name: Test executable
43+
run: |
44+
dist\TechCompressor.exe --version
45+
dist\TechCompressor.exe --help
46+
47+
- name: Get version from tag
48+
id: get_version
49+
shell: bash
50+
run: echo "VERSION=${GITHUB_REF#refs/tags/}" >> $GITHUB_OUTPUT
51+
52+
- name: Create release ZIP
53+
run: |
54+
Compress-Archive -Path dist\TechCompressor.exe -DestinationPath dist\TechCompressor-${{ steps.get_version.outputs.VERSION }}-Windows-x64.zip
55+
56+
- name: Upload artifact
57+
uses: actions/upload-artifact@v4
58+
with:
59+
name: windows-executable
60+
path: |
61+
dist/TechCompressor.exe
62+
dist/TechCompressor-*.zip
63+
64+
build-linux:
65+
name: Build Linux Executable
66+
runs-on: ubuntu-latest
67+
68+
steps:
69+
- name: Checkout code
70+
uses: actions/checkout@v4
71+
72+
- name: Set up Python
73+
uses: actions/setup-python@v5
74+
with:
75+
python-version: '3.12'
76+
77+
- name: Install dependencies
78+
run: |
79+
python -m pip install --upgrade pip
80+
pip install -r requirements.txt
81+
pip install pyinstaller
82+
83+
- name: Run tests
84+
run: |
85+
pytest tests/test_release_smoke.py -v
86+
87+
- name: Build executable
88+
run: |
89+
pyinstaller --onefile --name techcompressor --console techcompressor/cli.py
90+
91+
- name: Test executable
92+
run: |
93+
chmod +x dist/techcompressor
94+
dist/techcompressor --version
95+
dist/techcompressor --help
96+
97+
- name: Get version from tag
98+
id: get_version
99+
run: echo "VERSION=${GITHUB_REF#refs/tags/}" >> $GITHUB_OUTPUT
100+
101+
- name: Create release tarball
102+
run: |
103+
cd dist
104+
tar -czvf techcompressor-${{ steps.get_version.outputs.VERSION }}-Linux-x64.tar.gz techcompressor
105+
106+
- name: Upload artifact
107+
uses: actions/upload-artifact@v4
108+
with:
109+
name: linux-executable
110+
path: |
111+
dist/techcompressor
112+
dist/techcompressor-*.tar.gz
113+
114+
create-release:
115+
name: Create GitHub Release
116+
runs-on: ubuntu-latest
117+
needs: [build-windows, build-linux]
118+
119+
steps:
120+
- name: Checkout code
121+
uses: actions/checkout@v4
122+
123+
- name: Download Windows artifact
124+
uses: actions/download-artifact@v4
125+
with:
126+
name: windows-executable
127+
path: dist/windows
128+
129+
- name: Download Linux artifact
130+
uses: actions/download-artifact@v4
131+
with:
132+
name: linux-executable
133+
path: dist/linux
134+
135+
- name: Get version from tag
136+
id: get_version
137+
run: echo "VERSION=${GITHUB_REF#refs/tags/}" >> $GITHUB_OUTPUT
138+
139+
- name: Create Release
140+
uses: softprops/action-gh-release@v2
141+
with:
142+
name: TechCompressor ${{ steps.get_version.outputs.VERSION }}
143+
draft: false
144+
prerelease: false
145+
generate_release_notes: true
146+
files: |
147+
dist/windows/TechCompressor-*.zip
148+
dist/linux/techcompressor-*.tar.gz
149+
env:
150+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

0 commit comments

Comments
 (0)