Skip to content

Add a proper test suite #50

Add a proper test suite

Add a proper test suite #50

name: Build, Test and Snapshot Release
on:
push:
branches:
- main
- master
pull_request:
schedule:
- cron: "0 0 * * 0" # Weekly on Sunday at midnight
workflow_dispatch: # Allows manual triggering
jobs:
lint-and-test-python:
name: Python Test Suite
runs-on: ubuntu-latest
if: github.event_name == 'pull_request' || github.event_name == 'push'
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: "3.11"
- name: Check if Python tests exist
id: check-tests
run: |
if [ -f "test/requirements.txt" ] && [ -f "test/test.sh" ]; then
echo "tests_exist=true" >> $GITHUB_OUTPUT
echo "✅ Python test suite found"
else
echo "tests_exist=false" >> $GITHUB_OUTPUT
echo "⚠️ Python test suite not found - skipping tests"
fi
- name: Setup Python test environment
if: steps.check-tests.outputs.tests_exist == 'true'
run: |
cd test
python -m venv venv
source venv/bin/activate
python -m pip install --upgrade pip
python -m pip install -r requirements.txt
- name: Run Python linting
if: steps.check-tests.outputs.tests_exist == 'true'
run: |
cd test
source venv/bin/activate
../scripts/lint-python.sh ci
# - name: Run Python tests
# if: steps.check-tests.outputs.tests_exist == 'true'
# run: |
# cd testing
# source venv/bin/activate
# echo "🧪 Running Python tests..."
# pytest -v --tb=short
# echo "✅ Python tests completed!"
build:
name: Build and Test Go Plugin
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
go-version: [">=1.23.5"]
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: ${{ matrix.go-version }}
- name: Install dependencies
run: go mod tidy -e || true
- name: Lint Go files
run: |
echo "🔍 Running go fmt..."
go fmt .
echo "🔍 Running go vet..."
go vet .
- name: Build binary
run: |
echo "🔨 Building binary..."
python3 .github/workflows/build.py
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: cf-cli-java-plugin-${{ matrix.os }}
path: dist/
release:
name: Create Snapshot Release
needs: [build, lint-and-test-python]
runs-on: ubuntu-latest
if: (github.event_name == 'push' || github.event_name == 'schedule' || github.event_name == 'workflow_dispatch') && (needs.lint-and-test-python.result == 'success' || needs.lint-and-test-python.result == 'skipped')
steps:
- name: Download all artifacts
uses: actions/download-artifact@v4
with:
path: dist/
- name: Combine all artifacts
run: |
mkdir -p dist
mv dist/*/* dist/ || true
- uses: thomashampson/delete-older-releases@main
with:
keep_latest: 0
delete_tag_regex: snapshot
prerelease_only: true
delete_tags: true
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Create GitHub Release
uses: softprops/action-gh-release@v1
with:
files: dist/*
prerelease: false
release: false
tag_name: snapshot
body: |
This is a snapshot release of the cf-cli-java-plugin.
It includes the latest changes and is not intended for production use.
Please test it and provide feedback.
## Build Status
- ✅ Go Plugin: Built and tested on Linux, macOS, and Windows
- ✅ Python Tests: Linting and test suite validation completed
## Changes
This snapshot includes the latest commits from the repository.
name: Snapshot Release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}