fix: remove unsupported -nostdlib flag from cosmocc build #3
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 Build and Test | |
| on: | |
| push: | |
| branches: [ main, develop, github-actions-ci-build-test ] | |
| pull_request: | |
| branches: [ main, develop ] | |
| workflow_dispatch: | |
| env: | |
| TARGET_NAME: webdav_server | |
| COSMO_VERSION: v1.1 | |
| jobs: | |
| # Code quality checks | |
| lint: | |
| name: Code Quality | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Install dependencies | |
| run: | | |
| sudo apt-get update | |
| sudo apt-get install -y clang-tools | |
| - name: Check C syntax | |
| run: | | |
| make check || exit 1 | |
| - name: Verify all targets exist | |
| run: | | |
| make help | grep -E "make|cosmo|test|debug" | |
| # Standard Linux build | |
| build-linux: | |
| name: Build on Linux | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Install build dependencies | |
| run: | | |
| sudo apt-get update | |
| sudo apt-get install -y build-essential | |
| - name: Build | |
| run: | | |
| make | |
| - name: Verify binary | |
| run: | | |
| ls -lh $(which make | xargs dirname)/../${{ env.TARGET_NAME }} || ls -lh ./${{ env.TARGET_NAME }} | |
| file ./${{ env.TARGET_NAME }} | |
| ./${{ env.TARGET_NAME }} --help || true | |
| - name: Upload standard binary | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: webdav-server-linux | |
| path: ${{ env.TARGET_NAME }} | |
| retention-days: 7 | |
| # Cosmopolitan APE build | |
| build-cosmo: | |
| name: Build Cosmopolitan APE | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Install build dependencies | |
| run: | | |
| sudo apt-get update | |
| sudo apt-get install -y wget unzip build-essential | |
| - name: Cache Cosmopolitan toolchain | |
| id: cache-cosmo | |
| uses: actions/cache@v4 | |
| with: | |
| path: /opt/cosmo | |
| key: cosmo-toolchain-${{ env.COSMO_VERSION }} | |
| - name: Install Cosmopolitan toolchain | |
| if: steps.cache-cosmo.outputs.cache-hit != 'true' | |
| run: | | |
| sudo mkdir -p /opt/cosmo | |
| cd /opt/cosmo | |
| sudo wget -q https://cosmo.zip/pub/cosmocc/cosmocc.zip | |
| sudo unzip -q cosmocc.zip | |
| sudo rm cosmocc.zip | |
| sudo chmod +x bin/cosmocc bin/cosmoar | |
| echo "Cosmopolitan toolchain installed" | |
| - name: Verify Cosmopolitan installation | |
| run: | | |
| ls -lh /opt/cosmo/bin/ | |
| /opt/cosmo/bin/cosmocc --version || echo "Cosmocc installed" | |
| echo "PATH=/opt/cosmo/bin:$PATH" >> $GITHUB_ENV | |
| - name: Build with Cosmopolitan | |
| run: | | |
| export PATH=/opt/cosmo/bin:$PATH | |
| make cosmo | |
| - name: Verify APE build artifact | |
| run: | | |
| ls -lh webdav_server.com | |
| file webdav_server.com | |
| chmod +x webdav_server.com | |
| - name: Upload Cosmopolitan APE artifact | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: webdav-server-cosmopolitan | |
| path: webdav_server.com | |
| retention-days: 30 | |
| # Unit tests | |
| test-unit: | |
| name: Unit Tests | |
| runs-on: ubuntu-latest | |
| needs: build-linux | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Install build dependencies | |
| run: | | |
| sudo apt-get update | |
| sudo apt-get install -y build-essential | |
| - name: Build | |
| run: make | |
| - name: Run built-in tests | |
| run: | | |
| make test | |
| - name: Run quick tests | |
| run: | | |
| make test-quick | |
| # Memory leak check | |
| test-valgrind: | |
| name: Memory Leak Check | |
| runs-on: ubuntu-latest | |
| needs: build-linux | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Install dependencies | |
| run: | | |
| sudo apt-get update | |
| sudo apt-get install -y build-essential valgrind | |
| - name: Build | |
| run: make | |
| - name: Run valgrind check | |
| run: | | |
| make valgrind | |
| # Integration test | |
| test-integration: | |
| name: Integration Test | |
| runs-on: ubuntu-latest | |
| needs: build-linux | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Install dependencies | |
| run: | | |
| sudo apt-get update | |
| sudo apt-get install -y build-essential curl | |
| - name: Build | |
| run: make | |
| - name: Start server and test | |
| run: | | |
| # Start server in background with memory DB | |
| ./webdav_server -p 8088 --db :mem: & | |
| SERVER_PID=$! | |
| echo "SERVER_PID=$SERVER_PID" >> $GITHUB_ENV | |
| # Wait for server to start | |
| sleep 3 | |
| # Test OPTIONS | |
| echo "Testing OPTIONS..." | |
| curl -s -X OPTIONS http://localhost:8088/ | grep -q "DAV: 1" && echo "✓ OPTIONS OK" || (echo "✗ OPTIONS FAILED" && exit 1) | |
| # Test MKCOL | |
| echo "Testing MKCOL..." | |
| curl -s -X MKCOL http://localhost:8088/testdir && echo "✓ MKCOL OK" || echo "MKCOL returned non-zero (may be OK)" | |
| # Test PUT | |
| echo "Testing PUT..." | |
| echo "test content" | curl -s -X PUT --data-binary @- http://localhost:8088/test.txt && echo "✓ PUT OK" || (echo "✗ PUT FAILED" && exit 1) | |
| # Test GET | |
| echo "Testing GET..." | |
| curl -s http://localhost:8088/test.txt | grep -q "test content" && echo "✓ GET OK" || (echo "✗ GET FAILED" && exit 1) | |
| # Test PROPFIND | |
| echo "Testing PROPFIND..." | |
| curl -s -X PROPFIND http://localhost:8088/ | grep -q "multistatus" && echo "✓ PROPFIND OK" || echo "PROPFIND may have returned (checking response)" | |
| # Test DELETE | |
| echo "Testing DELETE..." | |
| curl -s -X DELETE http://localhost:8088/test.txt && echo "✓ DELETE OK" || echo "DELETE returned (may be OK)" | |
| # Cleanup | |
| kill $SERVER_PID 2>/dev/null || true | |
| pkill -f './webdav_server' || true | |
| echo "All integration tests completed!" | |
| - name: Upload test logs | |
| if: always() | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: integration-test-logs | |
| path: | | |
| *.log | |
| /tmp/*.log | |
| retention-days: 7 | |
| # Docker build test | |
| test-docker: | |
| name: Docker Build Test | |
| runs-on: ubuntu-latest | |
| needs: build-linux | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Set up Docker Buildx | |
| uses: docker/setup-buildx-action@v3 | |
| - name: Build Docker image | |
| run: | | |
| docker build -t webdav-server:test . | |
| - name: Test Docker container | |
| run: | | |
| docker run -d --name webdav-test -p 8089:8080 webdav-server:test | |
| sleep 5 | |
| # Test if container is responding | |
| curl -f http://localhost:8089/ && echo "✓ Docker container responding" || (echo "✗ Docker container not responding" && docker logs webdav-test && exit 1) | |
| # Cleanup | |
| docker stop webdav-test || true | |
| docker rm webdav-test || true | |
| # Cosmopolitan execution test (if supported on runner) | |
| test-cosmo-exec: | |
| name: Cosmopolitan Execution Test | |
| runs-on: ubuntu-latest | |
| needs: build-cosmo | |
| steps: | |
| - name: Download Cosmopolitan artifact | |
| uses: actions/download-artifact@v4 | |
| with: | |
| name: webdav-server-cosmopolitan | |
| - name: Make executable and test | |
| run: | | |
| chmod +x webdav_server.com | |
| file webdav_server.com | |
| # Test if it runs (may not work on all systems, but file check is important) | |
| ./webdav_server.com --help || echo "Cosmopolitan binary created (may need specific environment to run)" | |
| # Release artifacts (only on main branch or tags) | |
| release: | |
| name: Create Release Artifacts | |
| runs-on: ubuntu-latest | |
| needs: | |
| - build-linux | |
| - build-cosmo | |
| - test-unit | |
| - test-integration | |
| if: github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/') | |
| permissions: | |
| contents: write | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Download Linux binary | |
| uses: actions/download-artifact@v4 | |
| with: | |
| name: webdav-server-linux | |
| - name: Download Cosmopolitan binary | |
| uses: actions/download-artifact@v4 | |
| with: | |
| name: webdav-server-cosmopolitan | |
| - name: Prepare release artifacts | |
| run: | | |
| mkdir -p release | |
| mv webdav_server release/webdav_server-linux-x64 | |
| mv webdav_server.com release/webdav_server-cosmopolitan.com | |
| chmod +x release/* | |
| # Create version info | |
| echo "WebDAV Server Release" > release/README.md | |
| echo "=====================" >> release/README.md | |
| echo "" >> release/README.md | |
| echo "## Files" >> release/README.md | |
| echo "- \`webdav_server-linux-x64\` - Standard Linux binary" >> release/README.md | |
| echo "- \`webdav_server-cosmopolitan.com\` - Cross-platform APE binary" >> release/README.md | |
| echo "" >> release/README.md | |
| echo "## Usage" >> release/README.md | |
| echo "\`\`\`bash" >> release/README.md | |
| echo "# Linux" >> release/README.md | |
| echo "./webdav_server-linux-x64 -p 8080 --db webdav.db" >> release/README.md | |
| echo "" >> release/README.md | |
| echo "# Cross-platform (Cosmopolitan APE)" >> release/README.md | |
| echo "./webdav_server-cosmopolitan.com -p 8080 --db webdav.db" >> release/README.md | |
| echo "\`\`\`" >> release/README.md | |
| - name: Create checksums | |
| run: | | |
| cd release | |
| sha256sum * > SHA256SUMS | |
| cat SHA256SUMS | |
| - name: Upload release bundle | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: release-artifacts | |
| path: release/ | |
| retention-days: 90 | |
| - name: Create GitHub Release | |
| if: startsWith(github.ref, 'refs/tags/') | |
| uses: softprops/action-gh-release@v2 | |
| with: | |
| files: | | |
| release/webdav_server-linux-x64 | |
| release/webdav_server-cosmopolitan.com | |
| release/SHA256SUMS | |
| release/README.md | |
| draft: false | |
| prerelease: false | |
| body: | | |
| WebDAV Server Release | |
| ## Changes | |
| - Built from ${{ github.sha }} | |
| ## Artifacts | |
| - Linux x64 binary | |
| - Cosmopolitan APE binary (cross-platform) | |
| ## Usage | |
| See README.md for detailed usage instructions. | |