Skip to content

feat!: introduce comprehensive OpenAPI 3.0.x/3.1.x parser with validation, walking, and upgrading #67

feat!: introduce comprehensive OpenAPI 3.0.x/3.1.x parser with validation, walking, and upgrading

feat!: introduce comprehensive OpenAPI 3.0.x/3.1.x parser with validation, walking, and upgrading #67

Workflow file for this run

name: Test
on:
push:
branches: [main]
pull_request:
branches: [main]
jobs:
lint:
name: Lint and Format Check
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install mise
uses: jdx/mise-action@v2
- name: Get Go cache paths
id: go-cache-paths
shell: bash
run: |
echo "go-build=$(go env GOCACHE)" >> $GITHUB_OUTPUT
echo "go-mod=$(go env GOMODCACHE)" >> $GITHUB_OUTPUT
- name: Cache Go Build Cache
uses: actions/cache@v4
with:
path: ${{ steps.go-cache-paths.outputs.go-build }}
key: ${{ runner.os }}-go-build-${{ hashFiles('**/go.sum') }}
- name: Cache Go Mod Cache
uses: actions/cache@v4
with:
path: ${{ steps.go-cache-paths.outputs.go-mod }}
key: ${{ runner.os }}-go-mod-${{ hashFiles('**/go.sum') }}
- name: Check code formatting
run: mise run fmt-check
- name: Check module dependencies
run: mise run mod-check
- name: Run lint task
run: mise run lint
- name: Check examples are up to date
run: mise run examples-check
test-and-build:
name: Test and Build
needs: lint
strategy:
matrix:
os: [ubuntu-latest, windows-latest]
runs-on: ${{ matrix.os }}
permissions:
contents: read
pull-requests: write
steps:
- uses: actions/checkout@v4
- name: Install mise
uses: jdx/mise-action@v2
- name: Get Go cache paths
id: go-cache-paths
shell: bash
run: |
echo "go-build=$(go env GOCACHE)" >> $GITHUB_OUTPUT
echo "go-mod=$(go env GOMODCACHE)" >> $GITHUB_OUTPUT
- name: Cache Go Build Cache
uses: actions/cache@v4
with:
path: ${{ steps.go-cache-paths.outputs.go-build }}
key: ${{ runner.os }}-go-build-${{ hashFiles('**/go.sum') }}
- name: Cache Go Mod Cache
uses: actions/cache@v4
with:
path: ${{ steps.go-cache-paths.outputs.go-mod }}
key: ${{ runner.os }}-go-mod-${{ hashFiles('**/go.sum') }}
- name: Cache downloaded test files
uses: actions/cache@v4
with:
path: |
~/tmp/speakeasy-api_arazzo
${{ runner.temp }}/speakeasy-api_arazzo
key: arazzo-test-files-${{ hashFiles('arazzo/arazzo_test.go') }}
restore-keys: |
arazzo-test-files-
- name: Run tests with coverage
if: matrix.os == 'ubuntu-latest'
run: mise run test-coverage
- name: Run tests (Windows)
if: matrix.os == 'windows-latest'
run: gotestsum --format testname -- -race ./...
- name: Calculate coverage
if: matrix.os == 'ubuntu-latest'
id: coverage
run: |
COVERAGE=$(go tool cover -func=coverage.out | grep total | awk '{print $3}')
echo "coverage=$COVERAGE" >> $GITHUB_OUTPUT
echo "Coverage: $COVERAGE"
- name: Get main branch coverage
if: github.event_name == 'pull_request' && matrix.os == 'ubuntu-latest'
id: main-coverage
run: |
# Store current working directory
CURRENT_DIR=$(pwd)
# Fetch main branch
git fetch origin main:main
# Checkout main branch in a temporary directory
git worktree add /tmp/main-branch main
# Run tests on main branch to get coverage
cd /tmp/main-branch
go test -coverprofile=main-coverage.out -covermode=atomic ./... > /dev/null 2>&1 || echo "Main branch tests failed"
if [ -f main-coverage.out ]; then
MAIN_COVERAGE=$(go tool cover -func=main-coverage.out | grep total | awk '{print $3}' || echo "0.0%")
echo "main-coverage=$MAIN_COVERAGE" >> $GITHUB_OUTPUT
echo "Main branch coverage: $MAIN_COVERAGE"
# Copy main coverage file back to current directory
cp main-coverage.out "$CURRENT_DIR/main-coverage.out"
else
echo "main-coverage=0.0%" >> $GITHUB_OUTPUT
echo "Could not get main branch coverage"
fi
# Return to original directory
cd "$CURRENT_DIR"
# Clean up worktree (force removal to handle modified files)
git worktree remove --force /tmp/main-branch || rm -rf /tmp/main-branch
- name: Generate coverage summary
if: matrix.os == 'ubuntu-latest'
id: coverage-summary
run: |
echo "## 📊 Test Coverage Report" > coverage-summary.md
echo "" >> coverage-summary.md
# Current coverage
CURRENT_COV="${{ steps.coverage.outputs.coverage }}"
echo "**Current Coverage:** \`$CURRENT_COV\`" >> coverage-summary.md
# Compare with main if this is a PR
if [ "${{ github.event_name }}" = "pull_request" ] && [ "${{ steps.main-coverage.outputs.main-coverage }}" != "" ]; then
MAIN_COV="${{ steps.main-coverage.outputs.main-coverage }}"
echo "**Main Branch Coverage:** \`$MAIN_COV\`" >> coverage-summary.md
echo "" >> coverage-summary.md
# Calculate difference
CURRENT_NUM=$(echo $CURRENT_COV | sed 's/%//')
MAIN_NUM=$(echo $MAIN_COV | sed 's/%//')
if [ "$CURRENT_NUM" != "" ] && [ "$MAIN_NUM" != "" ]; then
DIFF=$(echo "$CURRENT_NUM - $MAIN_NUM" | bc -l 2>/dev/null || echo "0")
if [ "$(echo "$DIFF > 0" | bc -l 2>/dev/null)" = "1" ]; then
echo "**Coverage Change:** 📈 +${DIFF}% (improved)" >> coverage-summary.md
elif [ "$(echo "$DIFF < 0" | bc -l 2>/dev/null)" = "1" ]; then
DIFF_ABS=$(echo "$DIFF * -1" | bc -l 2>/dev/null || echo "${DIFF#-}")
echo "**Coverage Change:** 📉 -${DIFF_ABS}% (decreased)" >> coverage-summary.md
else
echo "**Coverage Change:** ✅ No change" >> coverage-summary.md
fi
fi
fi
echo "" >> coverage-summary.md
echo "### Coverage by Package" >> coverage-summary.md
echo "\`\`\`" >> coverage-summary.md
go tool cover -func=coverage.out >> coverage-summary.md
echo "\`\`\`" >> coverage-summary.md
echo "" >> coverage-summary.md
echo "- 🧪 All tests passed" >> coverage-summary.md
echo "- 📈 Full coverage report available in workflow artifacts" >> coverage-summary.md
echo "" >> coverage-summary.md
echo "_Generated by GitHub Actions_" >> coverage-summary.md
- name: Comment PR with coverage
if: github.event_name == 'pull_request' && matrix.os == 'ubuntu-latest'
uses: actions/github-script@v7
with:
script: |
const fs = require('fs');
const coverageSummary = fs.readFileSync('coverage-summary.md', 'utf8');
// Look for existing coverage comment
const comments = await github.rest.issues.listComments({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
});
const botComment = comments.data.find(comment =>
comment.user.type === 'Bot' &&
comment.body.includes('📊 Test Coverage Report')
);
if (botComment) {
// Update existing comment
await github.rest.issues.updateComment({
comment_id: botComment.id,
owner: context.repo.owner,
repo: context.repo.repo,
body: coverageSummary
});
} else {
// Create new comment
await github.rest.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: coverageSummary
});
}
- name: Upload coverage artifact
if: matrix.os == 'ubuntu-latest'
uses: actions/upload-artifact@v4
with:
name: coverage-report
path: |
coverage.out
coverage.html
- name: Build (Ubuntu)
if: matrix.os == 'ubuntu-latest'
run: mise run build
- name: Build (Windows)
if: matrix.os == 'windows-latest'
run: go build -v ./...
# Summary job that depends on all matrix jobs
# This provides a single status check for branch protection
test-summary:
name: Test Summary
needs: [lint, test-and-build]
runs-on: ubuntu-latest
if: always()
steps:
- name: Check test results
run: |
if [ "${{ needs.test-and-build.result }}" != "success" ]; then
echo "Tests failed or were cancelled"
exit 1
fi
echo "All tests passed successfully"