refactor: drop utls, simplify to 2-tier strategy (HTTP + Chrome) #9
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: | |
| push: | |
| branches: ["**"] | |
| pull_request: | |
| branches: ["**"] | |
| permissions: | |
| contents: write | |
| jobs: | |
| test: | |
| name: Test & Build | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| - name: Setup Go | |
| uses: actions/setup-go@v5 | |
| with: | |
| go-version: "1.24" | |
| - name: Run tests | |
| id: tests | |
| run: | | |
| TEST_OUTPUT=$(go test -v -race -count=1 ./... 2>&1) | |
| echo "$TEST_OUTPUT" | |
| TEST_COUNT=$(echo "$TEST_OUTPUT" | grep -c '^--- PASS:' || true) | |
| echo "test_count=$TEST_COUNT" >> "$GITHUB_OUTPUT" | |
| - name: Build binary | |
| id: build | |
| run: | | |
| go build -o rawdoc . | |
| BINARY_SIZE=$(du -sh rawdoc | cut -f1) | |
| echo "binary_size=$BINARY_SIZE" >> "$GITHUB_OUTPUT" | |
| - name: Smoke test | |
| run: | | |
| ./rawdoc https://example.com -q | |
| echo "Smoke test passed" | |
| - name: Auto patch tag | |
| if: github.ref == 'refs/heads/main' && github.event_name == 'push' | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| run: | | |
| git config user.name "github-actions[bot]" | |
| git config user.email "github-actions[bot]@users.noreply.github.com" | |
| LATEST_TAG=$(git describe --tags --abbrev=0 2>/dev/null || echo "v0.0.0") | |
| VERSION=${LATEST_TAG#v} | |
| IFS='.' read -r MAJOR MINOR PATCH <<< "$VERSION" | |
| PATCH=$((PATCH + 1)) | |
| NEW_TAG="v${MAJOR}.${MINOR}.${PATCH}" | |
| # Skip if this commit is already tagged (e.g. from release workflow) | |
| if git describe --exact-match HEAD 2>/dev/null; then | |
| echo "Commit already tagged, skipping" | |
| exit 0 | |
| fi | |
| git tag -a "$NEW_TAG" -m "Auto patch $NEW_TAG | |
| Install: go install github.com/RandomCodeSpace/rawdoc@$NEW_TAG" | |
| git push origin "$NEW_TAG" | |
| echo "Tagged $NEW_TAG" | |
| echo "new_tag=$NEW_TAG" >> "$GITHUB_OUTPUT" | |
| - name: Generate job summary | |
| if: always() | |
| env: | |
| TEST_COUNT: ${{ steps.tests.outputs.test_count }} | |
| BINARY_SIZE: ${{ steps.build.outputs.binary_size }} | |
| COMMIT_SHA: ${{ github.sha }} | |
| BUILD_NUMBER: ${{ github.run_number }} | |
| TESTS_OUTCOME: ${{ steps.tests.outcome }} | |
| BUILD_OUTCOME: ${{ steps.build.outcome }} | |
| run: | | |
| SHORT_SHA="${COMMIT_SHA:0:7}" | |
| BUILD_DATE=$(date -u +"%Y-%m-%d %H:%M UTC") | |
| if [ "$TESTS_OUTCOME" = "success" ]; then | |
| TEST_STATUS="✅ Passed (${TEST_COUNT} tests)" | |
| else | |
| TEST_STATUS="❌ Failed" | |
| fi | |
| if [ "$BUILD_OUTCOME" = "success" ]; then | |
| BUILD_STATUS="✅ Success" | |
| else | |
| BUILD_STATUS="❌ Failed" | |
| fi | |
| SMOKE_STATUS="✅ example.com fetched" | |
| cat >> "$GITHUB_STEP_SUMMARY" <<EOF | |
| ## rawdoc CI Results | |
| | Check | Status | | |
| |-------|--------| | |
| | Unit Tests | ${TEST_STATUS} | | |
| | Build | ${BUILD_STATUS} | | |
| | Smoke Test | ${SMOKE_STATUS} | | |
| | Binary Size | ${BINARY_SIZE} | | |
| **Build:** #${BUILD_NUMBER} | **Commit:** ${SHORT_SHA} | **Date:** ${BUILD_DATE} | |
| EOF |