|
| 1 | +name: Test |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: [main] |
| 6 | + pull_request: |
| 7 | + |
| 8 | +permissions: |
| 9 | + contents: read |
| 10 | + |
| 11 | +jobs: |
| 12 | + test: |
| 13 | + runs-on: ubuntu-latest |
| 14 | + steps: |
| 15 | + - uses: actions/checkout@v4 |
| 16 | + |
| 17 | + - uses: actions/setup-go@v5 |
| 18 | + with: |
| 19 | + go-version-file: go.mod |
| 20 | + |
| 21 | + - name: Run tests with coverage |
| 22 | + run: go test ./... -v -count=1 -coverprofile=coverage.out |
| 23 | + |
| 24 | + - name: Coverage summary |
| 25 | + run: | |
| 26 | + total=$(go tool cover -func=coverage.out | tail -1 | awk '{print $NF}') |
| 27 | + echo "## Test Coverage" >> "$GITHUB_STEP_SUMMARY" |
| 28 | + echo "" >> "$GITHUB_STEP_SUMMARY" |
| 29 | + echo "**Total: ${total}**" >> "$GITHUB_STEP_SUMMARY" |
| 30 | + echo "" >> "$GITHUB_STEP_SUMMARY" |
| 31 | + echo "| Package | Coverage |" >> "$GITHUB_STEP_SUMMARY" |
| 32 | + echo "|---------|----------|" >> "$GITHUB_STEP_SUMMARY" |
| 33 | + go tool cover -func=coverage.out | grep -v "total:" | awk -F'\t+' '{print $1, $NF}' | sort -u -t' ' -k1,1 | while read -r pkg cov; do |
| 34 | + echo "| \`${pkg}\` | ${cov} |" >> "$GITHUB_STEP_SUMMARY" |
| 35 | + done |
| 36 | +
|
| 37 | + e2e: |
| 38 | + runs-on: ubuntu-latest |
| 39 | + steps: |
| 40 | + - uses: actions/checkout@v4 |
| 41 | + |
| 42 | + - uses: actions/setup-go@v5 |
| 43 | + with: |
| 44 | + go-version-file: go.mod |
| 45 | + |
| 46 | + - name: Run e2e tests |
| 47 | + run: go test ./e2e/ -v -count=1 -timeout=120s |
| 48 | + |
| 49 | + integration: |
| 50 | + runs-on: macos-latest |
| 51 | + steps: |
| 52 | + - uses: actions/checkout@v4 |
| 53 | + |
| 54 | + - uses: actions/setup-go@v5 |
| 55 | + with: |
| 56 | + go-version-file: go.mod |
| 57 | + |
| 58 | + - name: Install ios-webkit-debug-proxy |
| 59 | + run: brew install ios-webkit-debug-proxy |
| 60 | + |
| 61 | + - name: Run all tests with integration tag and coverage |
| 62 | + run: go test -tags=integration ./... -v -count=1 -timeout=120s -coverprofile=coverage-integration.out |
| 63 | + |
| 64 | + - name: Integration coverage summary |
| 65 | + run: | |
| 66 | + total=$(go tool cover -func=coverage-integration.out | tail -1 | awk '{print $NF}') |
| 67 | + echo "## Integration Test Coverage (includes all tests)" >> "$GITHUB_STEP_SUMMARY" |
| 68 | + echo "" >> "$GITHUB_STEP_SUMMARY" |
| 69 | + echo "**Total: ${total}**" >> "$GITHUB_STEP_SUMMARY" |
| 70 | + echo "" >> "$GITHUB_STEP_SUMMARY" |
| 71 | + echo "| Package | Coverage |" >> "$GITHUB_STEP_SUMMARY" |
| 72 | + echo "|---------|----------|" >> "$GITHUB_STEP_SUMMARY" |
| 73 | + go tool cover -func=coverage-integration.out | grep -v "total:" | awk -F'\t+' '{print $1, $NF}' | sort -u -t' ' -k1,1 | while read -r pkg cov; do |
| 74 | + echo "| \`${pkg}\` | ${cov} |" >> "$GITHUB_STEP_SUMMARY" |
| 75 | + done |
| 76 | +
|
| 77 | + simulator: |
| 78 | + runs-on: macos-latest |
| 79 | + steps: |
| 80 | + - uses: actions/checkout@v4 |
| 81 | + |
| 82 | + - uses: actions/setup-go@v5 |
| 83 | + with: |
| 84 | + go-version-file: go.mod |
| 85 | + |
| 86 | + - name: Install ios-webkit-debug-proxy |
| 87 | + run: brew install ios-webkit-debug-proxy |
| 88 | + |
| 89 | + - name: Boot iOS Simulator and start iwdp |
| 90 | + run: | |
| 91 | + eval "$(./scripts/sim-setup.sh)" |
| 92 | + echo "IWDP_SIM_WS_URL=$IWDP_SIM_WS_URL" >> "$GITHUB_ENV" |
| 93 | +
|
| 94 | + - name: Run simulator tests with coverage |
| 95 | + run: go test -tags=simulator ./... -v -count=1 -timeout=300s -coverprofile=coverage-simulator.out |
| 96 | + |
| 97 | + - name: Simulator coverage summary |
| 98 | + if: always() |
| 99 | + run: | |
| 100 | + if [ -f coverage-simulator.out ]; then |
| 101 | + total=$(go tool cover -func=coverage-simulator.out | tail -1 | awk '{print $NF}') |
| 102 | + echo "## Simulator Test Coverage" >> "$GITHUB_STEP_SUMMARY" |
| 103 | + echo "" >> "$GITHUB_STEP_SUMMARY" |
| 104 | + echo "**Total: ${total}**" >> "$GITHUB_STEP_SUMMARY" |
| 105 | + echo "" >> "$GITHUB_STEP_SUMMARY" |
| 106 | + echo "| Package | Coverage |" >> "$GITHUB_STEP_SUMMARY" |
| 107 | + echo "|---------|----------|" >> "$GITHUB_STEP_SUMMARY" |
| 108 | + go tool cover -func=coverage-simulator.out | grep -v "total:" | awk -F'\t+' '{print $1, $NF}' | sort -u -t' ' -k1,1 | while read -r pkg cov; do |
| 109 | + echo "| \`${pkg}\` | ${cov} |" >> "$GITHUB_STEP_SUMMARY" |
| 110 | + done |
| 111 | + fi |
| 112 | +
|
| 113 | + - name: Teardown simulator |
| 114 | + if: always() |
| 115 | + run: ./scripts/sim-setup.sh --teardown |
0 commit comments