fix(json): add YAMLToJSONCompatibleGoType, tests, and fix YAML merge … #116
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: [main] | |
pull_request: | |
branches: [main] | |
jobs: | |
lint: | |
name: Lint and Format Check | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v5 | |
with: | |
submodules: recursive | |
- name: Install mise | |
uses: jdx/mise-action@v3 | |
- name: Setup Go with caching | |
uses: actions/setup-go@v6 | |
with: | |
go-version-file: "go.mod" | |
cache: true | |
- 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: | |
name: Test | |
strategy: | |
matrix: | |
os: [ubuntu-latest, windows-latest] | |
runs-on: ${{ matrix.os }} | |
needs: [lint] | |
steps: | |
- uses: actions/checkout@v5 | |
with: | |
submodules: recursive | |
- name: Install mise | |
uses: jdx/mise-action@v3 | |
- name: Setup Go with caching | |
uses: actions/setup-go@v6 | |
with: | |
go-version-file: "go.mod" | |
cache: true | |
# Verify Docker is available for testcontainers (Ubuntu only) | |
- name: Verify Docker availability | |
if: matrix.os == 'ubuntu-latest' | |
run: | | |
docker --version | |
docker info | |
echo "Docker is available for testcontainers" | |
- name: Get current date | |
id: date | |
run: echo "date=$(date +'%Y-%m-%d')" >> $GITHUB_OUTPUT | |
- name: Cache downloaded test files | |
uses: actions/cache@v4 | |
with: | |
path: ${{ runner.temp }}/speakeasy-api_arazzo | |
key: arazzo-test-files-${{ steps.date.outputs.date }} | |
restore-keys: | | |
arazzo-test-files- | |
- name: Run tests (Ubuntu) | |
if: matrix.os == 'ubuntu-latest' | |
env: | |
ARAZZO_CACHE_DIR: ${{ runner.temp }} | |
run: mise test | |
- name: Run tests (Windows) | |
if: matrix.os == 'windows-latest' | |
env: | |
ARAZZO_CACHE_DIR: ${{ runner.temp }} | |
run: gotestsum --format testname -- -race $(go list ./... | grep -v 'jsonschema/oas3/tests') | |
coverage: | |
name: Coverage Report | |
runs-on: ubuntu-latest | |
needs: [lint] | |
permissions: | |
contents: read | |
pull-requests: write | |
steps: | |
- uses: actions/checkout@v5 | |
with: | |
submodules: recursive | |
- name: Install mise | |
uses: jdx/mise-action@v3 | |
- name: Setup Go with caching | |
uses: actions/setup-go@v6 | |
with: | |
go-version-file: "go.mod" | |
cache: true | |
# Verify Docker is available for testcontainers | |
- name: Verify Docker availability | |
run: | | |
docker --version | |
docker info | |
echo "Docker is available for testcontainers" | |
- name: Get current date | |
id: date | |
run: echo "date=$(date +'%Y-%m-%d')" >> $GITHUB_OUTPUT | |
- name: Cache downloaded test files | |
uses: actions/cache@v4 | |
with: | |
path: ${{ runner.temp }}/speakeasy-api_arazzo | |
key: arazzo-test-files-${{ steps.date.outputs.date }} | |
restore-keys: | | |
arazzo-test-files- | |
- name: Run tests with coverage | |
env: | |
ARAZZO_CACHE_DIR: ${{ runner.temp }} | |
run: mise test-coverage | |
- name: Calculate coverage | |
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' | |
id: main-coverage | |
run: | | |
# Store current working directory | |
CURRENT_DIR=$(pwd) | |
# Fetch main branch with shallow clone for speed | |
git fetch --depth=1 origin main:main | |
# Checkout main branch in a temporary directory | |
git worktree add /tmp/main-branch main | |
# Initialize submodules in the main branch worktree | |
cd /tmp/main-branch | |
git submodule update --init --recursive || echo "Submodule initialization failed, continuing without submodules" | |
cd "$CURRENT_DIR" | |
# Run tests on main branch to get coverage (with timeout) | |
cd /tmp/main-branch | |
timeout 300 go test -coverprofile=main-coverage.out -covermode=atomic ./... > /dev/null 2>&1 || echo "Main branch tests failed or timed out" | |
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 | |
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: Upload coverage artifact | |
uses: actions/upload-artifact@v4 | |
with: | |
name: coverage-report | |
path: | | |
coverage.out | |
coverage.html | |
coverage-summary.md | |
# Build jobs (run in parallel) | |
build-ubuntu: | |
name: Build (Ubuntu) | |
runs-on: ubuntu-latest | |
needs: [lint] | |
steps: | |
- uses: actions/checkout@v5 | |
with: | |
submodules: recursive | |
- name: Install mise | |
uses: jdx/mise-action@v3 | |
- name: Setup Go with caching | |
uses: actions/setup-go@v6 | |
with: | |
go-version-file: "go.mod" | |
cache: true | |
- name: Build project | |
run: mise run build | |
build-windows: | |
name: Build (Windows) | |
runs-on: windows-latest | |
needs: [lint] | |
steps: | |
- uses: actions/checkout@v5 | |
with: | |
submodules: recursive | |
- name: Install mise | |
uses: jdx/mise-action@v3 | |
- name: Setup Go with caching | |
uses: actions/setup-go@v6 | |
with: | |
go-version-file: "go.mod" | |
cache: true | |
- name: Build project | |
run: go build -v ./... | |
# CLI integration tests (Linux only, run in parallel) | |
cli-tests: | |
name: CLI Integration Tests | |
runs-on: ubuntu-latest | |
needs: [lint] | |
steps: | |
- uses: actions/checkout@v5 | |
with: | |
submodules: recursive | |
- name: Install mise | |
uses: jdx/mise-action@v3 | |
- name: Setup Go with caching | |
uses: actions/setup-go@v6 | |
with: | |
go-version-file: "go.mod" | |
cache: true | |
- name: Run CLI integration tests | |
run: mise run test-cli | |
# Summary job that depends on all jobs | |
# This provides a single status check for branch protection | |
test-summary: | |
name: Test Summary | |
needs: [lint, test, coverage, cli-tests, build-ubuntu, build-windows] | |
runs-on: ubuntu-latest | |
if: always() | |
steps: | |
- name: Check test results | |
run: | | |
if [ "${{ needs.lint.result }}" != "success" ] || \ | |
[ "${{ needs.test.result }}" != "success" ] || \ | |
[ "${{ needs.coverage.result }}" != "success" ] || \ | |
[ "${{ needs.cli-tests.result }}" != "success" ] || \ | |
[ "${{ needs.build-ubuntu.result }}" != "success" ] || \ | |
[ "${{ needs.build-windows.result }}" != "success" ]; then | |
echo "One or more jobs failed or were cancelled" | |
exit 1 | |
fi | |
echo "All checks passed successfully" | |
# Add this temporary job to satisfy the phantom check TODO remove once GitHub stops expecting it | |
test-and-build: | |
name: test-and-build # Exact name match | |
runs-on: ubuntu-latest | |
if: always() # Always run | |
steps: | |
- name: Satisfy phantom check | |
run: echo "This job exists only to satisfy the phantom test-and-build status check. It will be removed once GitHub stops expecting it." |