Update main.yml #4
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 | |
| # 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 | |
| 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. | |