Enhances Error Handling and Output In Web Playground #27
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: CI | |
| on: | |
| pull_request: | |
| branches: [main] | |
| jobs: | |
| test-and-build: | |
| name: Test, Format, Build & Validate | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Setup Osprey Compiler | |
| uses: ./.github/actions/setup-osprey-compiler | |
| - name: Debug workspace structure | |
| working-directory: "./compiler" | |
| run: | | |
| echo "🔍 Debugging workspace structure..." | |
| echo "Current working directory: $(pwd)" | |
| echo "Contents of current directory:" | |
| ls -la | |
| echo "Contents of cmd directory:" | |
| ls -la cmd/ || echo "cmd directory not found" | |
| echo "Contents of cmd/osprey directory:" | |
| ls -la cmd/osprey/ || echo "cmd/osprey directory not found" | |
| echo "Checking if main.go exists:" | |
| if [ -f "cmd/osprey/main.go" ]; then | |
| echo "✅ main.go found" | |
| head -5 cmd/osprey/main.go | |
| else | |
| echo "❌ main.go not found" | |
| fi | |
| - name: Check Go formatting | |
| working-directory: "./compiler" | |
| run: | | |
| echo "🔍 Checking Go code formatting..." | |
| unformatted=$(gofmt -l .) | |
| if [ -n "$unformatted" ]; then | |
| echo "❌ The following files are not properly formatted:" | |
| echo "$unformatted" | |
| echo "Run 'gofmt -w .' to fix formatting issues" | |
| exit 1 | |
| fi | |
| echo "✅ All Go files are properly formatted" | |
| - name: Check Go modules are tidy | |
| working-directory: "./compiler" | |
| run: | | |
| echo "🔍 Checking if go.mod and go.sum are tidy..." | |
| go mod tidy | |
| if ! git diff --exit-code go.mod go.sum; then | |
| echo "❌ go.mod or go.sum are not tidy. Run 'go mod tidy' and commit the changes." | |
| exit 1 | |
| fi | |
| echo "✅ go.mod and go.sum are tidy" | |
| - name: Run linter | |
| working-directory: "./compiler" | |
| run: | | |
| echo "🔧 Running linter..." | |
| echo "Verifying cmd/osprey directory exists..." | |
| if [ ! -d "cmd/osprey" ]; then | |
| echo "❌ cmd/osprey directory not found!" | |
| echo "Current directory structure:" | |
| find . -name "*.go" -type f | head -10 | |
| exit 1 | |
| fi | |
| if [ ! -f "cmd/osprey/main.go" ]; then | |
| echo "❌ cmd/osprey/main.go not found!" | |
| exit 1 | |
| fi | |
| echo "✅ Directory structure verified" | |
| - name: Run tests & enforce coverage threshold | |
| working-directory: "./compiler" | |
| env: | |
| GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| run: | | |
| sudo apt-get update -qq && sudo apt-get install -y -qq bc | |
| echo "🚀 Executing full test-suite with coverage…" | |
| ./coverage_report.sh | |
| # Extract the total percentage (numeric, no % sign) | |
| CURRENT_COVERAGE=$(go tool cover -func=coverage.out | awk '/^total:/ {print $3}' | tr -d '%') | |
| MINIMUM_COVERAGE="${{ vars.TEST_COVERAGE_COMPILER }}" | |
| echo "Current coverage : ${CURRENT_COVERAGE}%" | |
| if [ -z "$MINIMUM_COVERAGE" ]; then | |
| echo "🌱 No TEST_COVERAGE_COMPILER variable set – bootstrapping with ${CURRENT_COVERAGE}%" | |
| gh variable set TEST_COVERAGE_COMPILER --body "$CURRENT_COVERAGE" | |
| exit 0 | |
| fi | |
| echo "Required minimum : ${MINIMUM_COVERAGE}%" | |
| # Fail if coverage dropped | |
| if [ "$(echo "$CURRENT_COVERAGE < $MINIMUM_COVERAGE" | bc -l)" -eq 1 ]; then | |
| echo "❌ Coverage dropped below threshold!" | |
| exit 1 | |
| fi | |
| echo "✅ Coverage check passed" | |
| - name: Test example compilation and execution | |
| working-directory: "./compiler" | |
| run: | | |
| echo "🎯 Testing example compilation and execution..." | |
| # Test arithmetic interpolation example | |
| echo "Testing interpolation_math.osp..." | |
| ./bin/osprey examples/tested/basics/math/interpolation_math.osp --run | |
| # Test comprehensive example | |
| echo "Testing comprehensive.osp..." | |
| ./bin/osprey examples/tested/basics/comprehensive.osp --run | |
| # Test basic hello world | |
| echo "Testing hello.osp..." | |
| ./bin/osprey examples/tested/basics/hello.osp --run | |
| echo "✅ All example compilations and executions successful!" | |
| - name: Verify binary works | |
| working-directory: "./compiler" | |
| run: | | |
| echo "🔍 Verifying osprey binary functionality..." | |
| ./bin/osprey --help | |
| echo "✅ Binary verification successful!" | |
| - name: Upload build artifacts | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: osprey-binary | |
| path: "compiler/bin/osprey" | |
| retention-days: 30 | |
| - name: Test Web Compiler | |
| run: | | |
| cd webcompiler | |
| docker compose up --build -d | |
| sleep 10 | |
| chmod +x test.sh | |
| ./test.sh | |
| docker compose down |