mirror of
https://github.com/tw93/Mole.git
synced 2026-02-04 18:34:46 +00:00
Automated test optimization increased to 132
This commit is contained in:
63
.github/workflows/quality.yml
vendored
Normal file
63
.github/workflows/quality.yml
vendored
Normal file
@@ -0,0 +1,63 @@
|
||||
name: Quality
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [main]
|
||||
pull_request:
|
||||
|
||||
permissions:
|
||||
contents: write
|
||||
|
||||
jobs:
|
||||
shell-quality:
|
||||
name: Code Quality
|
||||
runs-on: macos-latest
|
||||
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Cache Homebrew
|
||||
uses: actions/cache@v4
|
||||
with:
|
||||
path: |
|
||||
~/Library/Caches/Homebrew
|
||||
/usr/local/Cellar/shfmt
|
||||
/usr/local/Cellar/shellcheck
|
||||
key: ${{ runner.os }}-brew-quality-${{ hashFiles('**/Brewfile') }}
|
||||
restore-keys: |
|
||||
${{ runner.os }}-brew-quality-
|
||||
|
||||
- name: Install tools
|
||||
run: brew install shfmt shellcheck
|
||||
|
||||
- name: Format check
|
||||
run: |
|
||||
echo "Checking shell script formatting..."
|
||||
./scripts/format.sh
|
||||
if [[ -n $(git status --porcelain) ]]; then
|
||||
echo "Code formatting issues found:"
|
||||
git diff
|
||||
exit 1
|
||||
fi
|
||||
echo "✓ All scripts properly formatted"
|
||||
|
||||
- name: ShellCheck
|
||||
run: |
|
||||
echo "Running ShellCheck on all shell scripts..."
|
||||
shellcheck mole
|
||||
shellcheck bin/*.sh
|
||||
find lib -name "*.sh" -exec shellcheck {} +
|
||||
echo "✓ ShellCheck passed"
|
||||
|
||||
- name: Syntax check
|
||||
run: |
|
||||
echo "Checking Bash syntax..."
|
||||
bash -n mole
|
||||
for script in bin/*.sh; do
|
||||
bash -n "$script"
|
||||
done
|
||||
find lib -name "*.sh" | while read -r script; do
|
||||
bash -n "$script"
|
||||
done
|
||||
echo "✓ All scripts have valid syntax"
|
||||
55
.github/workflows/shell-quality-checks.yml
vendored
55
.github/workflows/shell-quality-checks.yml
vendored
@@ -1,55 +0,0 @@
|
||||
name: Shell Script Quality Checks
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [main]
|
||||
pull_request:
|
||||
|
||||
permissions:
|
||||
contents: write
|
||||
|
||||
jobs:
|
||||
shell-quality-checks:
|
||||
runs-on: macos-latest
|
||||
|
||||
steps:
|
||||
- name: Checkout source code
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Set up Go
|
||||
uses: actions/setup-go@v5
|
||||
with:
|
||||
go-version: "1.24.6"
|
||||
cache: true
|
||||
|
||||
- name: Cache Homebrew packages
|
||||
uses: actions/cache@v4
|
||||
with:
|
||||
path: |
|
||||
~/Library/Caches/Homebrew
|
||||
/usr/local/Cellar/bats-core
|
||||
/usr/local/Cellar/shfmt
|
||||
/usr/local/Cellar/shellcheck
|
||||
key: ${{ runner.os }}-brew-v1
|
||||
restore-keys: |
|
||||
${{ runner.os }}-brew-
|
||||
|
||||
- name: Install shell linting and testing tools
|
||||
run: brew install bats-core shfmt shellcheck
|
||||
|
||||
- name: Auto-format shell scripts with shfmt
|
||||
run: ./scripts/format.sh
|
||||
|
||||
- name: Run shellcheck linter and bats tests
|
||||
run: |
|
||||
./scripts/check.sh
|
||||
echo "✓ All quality checks passed"
|
||||
|
||||
- name: Run all bats tests with summary
|
||||
run: |
|
||||
echo "Running all test suites..."
|
||||
bats tests/*.bats --formatter tap
|
||||
echo ""
|
||||
echo "Test summary:"
|
||||
echo " Total test files: $(ls tests/*.bats | wc -l | tr -d ' ')"
|
||||
echo " Total tests: $(grep -c "^@test" tests/*.bats | awk -F: '{sum+=$2} END {print sum}')"
|
||||
140
.github/workflows/tests.yml
vendored
Normal file
140
.github/workflows/tests.yml
vendored
Normal file
@@ -0,0 +1,140 @@
|
||||
name: Tests
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [main, dev]
|
||||
pull_request:
|
||||
branches: [main, dev]
|
||||
|
||||
jobs:
|
||||
unit-tests:
|
||||
name: Unit Tests
|
||||
runs-on: macos-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
|
||||
- name: Install bats
|
||||
run: brew install bats-core
|
||||
|
||||
- name: Run all test suites
|
||||
run: |
|
||||
echo "Running all test suites..."
|
||||
bats tests/*.bats --formatter tap
|
||||
echo ""
|
||||
echo "Test summary:"
|
||||
echo " Total test files: $(ls tests/*.bats | wc -l | tr -d ' ')"
|
||||
echo " Total tests: $(grep -c "^@test" tests/*.bats | awk -F: '{sum+=$2} END {print sum}')"
|
||||
echo "✓ All tests passed"
|
||||
|
||||
go-tests:
|
||||
name: Go Tests
|
||||
runs-on: macos-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
|
||||
- name: Set up Go
|
||||
uses: actions/setup-go@v5
|
||||
with:
|
||||
go-version: '1.24'
|
||||
|
||||
- name: Build Go binaries
|
||||
run: |
|
||||
echo "Building Go binaries..."
|
||||
go build ./...
|
||||
echo "✓ Build successful"
|
||||
|
||||
- name: Run go vet
|
||||
run: |
|
||||
echo "Running go vet..."
|
||||
go vet ./cmd/...
|
||||
echo "✓ Vet passed"
|
||||
|
||||
- name: Check formatting
|
||||
run: |
|
||||
echo "Checking Go formatting..."
|
||||
if [ -n "$(gofmt -l ./cmd)" ]; then
|
||||
echo "Go code is not formatted:"
|
||||
gofmt -d ./cmd
|
||||
exit 1
|
||||
fi
|
||||
echo "✓ Go code properly formatted"
|
||||
|
||||
integration-tests:
|
||||
name: Integration Tests
|
||||
runs-on: macos-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
|
||||
- name: Install dependencies
|
||||
run: brew install coreutils
|
||||
|
||||
- name: Test module loading
|
||||
run: |
|
||||
echo "Testing module loading..."
|
||||
bash -c 'source lib/core/common.sh && echo "✓ Modules loaded successfully"'
|
||||
|
||||
- name: Test clean --dry-run
|
||||
run: |
|
||||
echo "Testing clean --dry-run..."
|
||||
./bin/clean.sh --dry-run
|
||||
echo "✓ Clean dry-run completed"
|
||||
|
||||
- name: Test installation
|
||||
run: |
|
||||
echo "Testing installation script..."
|
||||
./install.sh --prefix /tmp/mole-test
|
||||
test -f /tmp/mole-test/mole
|
||||
echo "✓ Installation successful"
|
||||
|
||||
compatibility:
|
||||
name: macOS Compatibility
|
||||
strategy:
|
||||
matrix:
|
||||
os: [macos-13, macos-14]
|
||||
runs-on: ${{ matrix.os }}
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
|
||||
- name: Test on ${{ matrix.os }}
|
||||
run: |
|
||||
echo "Testing on ${{ matrix.os }}..."
|
||||
bash -n mole
|
||||
source lib/core/common.sh
|
||||
echo "✓ Successfully loaded on ${{ matrix.os }}"
|
||||
|
||||
security:
|
||||
name: Security Checks
|
||||
runs-on: macos-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
|
||||
- name: Check for unsafe rm usage
|
||||
run: |
|
||||
echo "Checking for unsafe rm patterns..."
|
||||
if grep -r "rm -rf" --include="*.sh" lib/ | grep -v "safe_remove\|validate_path\|# "; then
|
||||
echo "✗ Unsafe rm -rf usage found"
|
||||
exit 1
|
||||
fi
|
||||
echo "✓ No unsafe rm usage found"
|
||||
|
||||
- name: Verify app protection
|
||||
run: |
|
||||
echo "Verifying critical file protection..."
|
||||
bash -c '
|
||||
source lib/core/common.sh
|
||||
if should_protect_from_uninstall "com.apple.Safari"; then
|
||||
echo "✓ Safari is protected"
|
||||
else
|
||||
echo "✗ Safari protection failed"
|
||||
exit 1
|
||||
fi
|
||||
'
|
||||
|
||||
- name: Check for secrets
|
||||
run: |
|
||||
echo "Checking for hardcoded secrets..."
|
||||
if grep -r "password\|secret\|api_key" --include="*.sh" . | grep -v "# \|test"; then
|
||||
echo "✗ Potential secrets found"
|
||||
exit 1
|
||||
fi
|
||||
echo "✓ No secrets found"
|
||||
Reference in New Issue
Block a user