Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 41 additions & 0 deletions .github/workflows/malware-scan.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
name: Malware Scan

on:
pull_request:
branches: [master, main, develop]

jobs:
clamav-scan:
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Install ClamAV
run: |
sudo apt-get update
sudo apt-get install -y clamav clamav-daemon

- name: Update ClamAV database
run: |
sudo systemctl stop clamav-freshclam || true
sudo freshclam

- name: Run ClamAV scan
run: |
clamscan --recursive --infected --exclude-dir=.git --exclude-dir=venv . | tee scan-results.txt
if grep -q "Infected files: 0" scan-results.txt; then
echo "No malware detected"
else
echo "Potential malware detected!"
exit 1
fi

- name: Upload scan results
if: always()
uses: actions/upload-artifact@v4
with:
name: clamav-scan-results
path: scan-results.txt
retention-days: 30
139 changes: 139 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,139 @@
name: Release

on:
push:
branches: [main, master]

permissions:
contents: write
pull-requests: write

jobs:
release:
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Get latest tag
id: get_tag
run: |
git fetch --tags
LATEST_TAG=$(git tag -l 'v*' --sort=-v:refname | head -n1)
if [ -z "$LATEST_TAG" ]; then
LATEST_TAG="v0.0.0"
fi
echo "latest_tag=$LATEST_TAG" >> $GITHUB_OUTPUT
echo "Latest tag: $LATEST_TAG"

- name: Calculate next version
id: next_version
run: |
LATEST_TAG="${{ steps.get_tag.outputs.latest_tag }}"
VERSION=${LATEST_TAG#v}

MAJOR=$(echo $VERSION | cut -d. -f1)
MINOR=$(echo $VERSION | cut -d. -f2)
PATCH=$(echo $VERSION | cut -d. -f3)

# Get commits since last tag
if [ "$LATEST_TAG" = "v0.0.0" ]; then
COMMITS=$(git log --pretty=format:"%s" HEAD)
else
COMMITS=$(git log --pretty=format:"%s" $LATEST_TAG..HEAD)
fi

if [ -z "$COMMITS" ]; then
echo "No new commits since last tag"
echo "skip=true" >> $GITHUB_OUTPUT
exit 0
fi

echo "Commits since $LATEST_TAG:"
echo "$COMMITS"

# Determine version bump based on conventional commits
BUMP="none"

if echo "$COMMITS" | grep -qE "^(feat|fix|docs|style|refactor|perf|test|chore)(\(.+\))?!:|BREAKING CHANGE"; then
BUMP="major"
MAJOR=$((MAJOR + 1))
MINOR=0
PATCH=0
elif echo "$COMMITS" | grep -qE "^feat(\(.+\))?:"; then
BUMP="minor"
MINOR=$((MINOR + 1))
PATCH=0
elif echo "$COMMITS" | grep -qE "^(fix|docs|style|refactor|perf|test|chore)(\(.+\))?:"; then
BUMP="patch"
PATCH=$((PATCH + 1))
else
echo "No conventional commits found, defaulting to patch"
BUMP="patch"
PATCH=$((PATCH + 1))
fi

NEW_VERSION="v$MAJOR.$MINOR.$PATCH"
echo "Version bump: $BUMP"
echo "New version: $NEW_VERSION"

echo "new_version=$NEW_VERSION" >> $GITHUB_OUTPUT
echo "bump=$BUMP" >> $GITHUB_OUTPUT
echo "skip=false" >> $GITHUB_OUTPUT

- name: Generate changelog
id: changelog
if: steps.next_version.outputs.skip != 'true'
run: |
LATEST_TAG="${{ steps.get_tag.outputs.latest_tag }}"

if [ "$LATEST_TAG" = "v0.0.0" ]; then
COMMITS=$(git log --pretty=format:"- %s (%h)" HEAD)
else
COMMITS=$(git log --pretty=format:"- %s (%h)" $LATEST_TAG..HEAD)
fi

# Create changelog grouped by type
echo "## What's Changed" > changelog.md
echo "" >> changelog.md

# Features
FEATURES=$(echo "$COMMITS" | grep -E "^- feat" || true)
if [ -n "$FEATURES" ]; then
echo "### Features" >> changelog.md
echo "$FEATURES" >> changelog.md
echo "" >> changelog.md
fi

# Bug Fixes
FIXES=$(echo "$COMMITS" | grep -E "^- fix" || true)
if [ -n "$FIXES" ]; then
echo "### Bug Fixes" >> changelog.md
echo "$FIXES" >> changelog.md
echo "" >> changelog.md
fi

# Other changes
OTHER=$(echo "$COMMITS" | grep -vE "^- (feat|fix)" || true)
if [ -n "$OTHER" ]; then
echo "### Other Changes" >> changelog.md
echo "$OTHER" >> changelog.md
echo "" >> changelog.md
fi

cat changelog.md

- name: Create release
if: steps.next_version.outputs.skip != 'true'
uses: softprops/action-gh-release@v1
with:
tag_name: ${{ steps.next_version.outputs.new_version }}
name: Release ${{ steps.next_version.outputs.new_version }}
body_path: changelog.md
draft: false
prerelease: false
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
32 changes: 32 additions & 0 deletions .github/workflows/security.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
name: Security Scan

on:
pull_request:
branches: [master, main, develop]

jobs:
trivy-scan:
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Run Trivy vulnerability scanner (filesystem)
uses: aquasecurity/trivy-action@master
with:
scan-type: 'fs'
scan-ref: '.'
format: 'table'
exit-code: '1'
ignore-unfixed: true
severity: 'CRITICAL,HIGH'

- name: Run Trivy scanner (config files)
uses: aquasecurity/trivy-action@master
with:
scan-type: 'config'
scan-ref: '.'
format: 'table'
exit-code: '0'
severity: 'CRITICAL,HIGH,MEDIUM'
56 changes: 56 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
name: Tests

on:
pull_request:
branches: [master, main, develop]
push:
branches: [master, main, develop]

jobs:
test:
runs-on: ubuntu-latest

strategy:
matrix:
python-version: ['3.10', '3.11', '3.12']

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
cache: 'pip'

- name: Install system dependencies
run: |
sudo apt-get update
sudo apt-get install -y \
libxkbcommon-x11-0 \
libxcb-icccm4 \
libxcb-image0 \
libxcb-keysyms1 \
libxcb-randr0 \
libxcb-render-util0 \
libxcb-xinerama0 \
libxcb-xfixes0 \
libxcb-shape0 \
libglib2.0-0 \
libegl1 \
libgl1-mesa-glx \
libspatialindex-dev \
xvfb

- name: Install Python dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
pip install pytest

- name: Run tests
env:
QT_QPA_PLATFORM: offscreen
run: |
python -m pytest -v --tb=short
82 changes: 80 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,82 @@
*.pyc
# Python
__pycache__/
*.py[cod]
*$py.class
*.so
.Python
build/
develop-eggs/
dist/
downloads/
eggs/
.eggs/
lib/
lib64/
parts/
sdist/
var/
wheels/
*.egg-info/
.installed.cfg
*.egg

# Virtual environments
venv/
ENV/
env/
.venv/

# pytest
.pytest_cache/
.coverage
htmlcov/
.tox/
.nox/
coverage.xml
*.cover
*.py,cover

# IDEs
.idea/
.vscode/
*.swp
*.swo
*~
.project
.pydevproject
.settings/
*.sublime-project
*.sublime-workspace

# OS files
.DS_Store
.DS_Store?
._*
.Spotlight-V100
.Trashes
ehthumbs.db
Thumbs.db

# FlatCAM specific
tests/tmp/
build/
*.log
*.gcode
*.nc
*.cnc
recent.json
recent_files.json

# Claude
.claude/

# Jupyter
.ipynb_checkpoints/

# mypy
.mypy_cache/
.dmypy.json
dmypy.json

# Distribution
*.manifest
*.spec
Loading