Skip to content

Commit 4ea381a

Browse files
fix: fixed in-lining shared schemas and improvements to sequenced maps (#24)
1 parent 0048330 commit 4ea381a

File tree

14 files changed

+62196
-198
lines changed

14 files changed

+62196
-198
lines changed
Lines changed: 37 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Test
1+
name: CI
22

33
on:
44
push:
@@ -16,24 +16,11 @@ jobs:
1616
- name: Install mise
1717
uses: jdx/mise-action@v2
1818

19-
- name: Get Go cache paths
20-
id: go-cache-paths
21-
shell: bash
22-
run: |
23-
echo "go-build=$(go env GOCACHE)" >> $GITHUB_OUTPUT
24-
echo "go-mod=$(go env GOMODCACHE)" >> $GITHUB_OUTPUT
25-
26-
- name: Cache Go Build Cache
27-
uses: actions/cache@v4
19+
- name: Setup Go with caching
20+
uses: actions/setup-go@v5
2821
with:
29-
path: ${{ steps.go-cache-paths.outputs.go-build }}
30-
key: ${{ runner.os }}-go-build-${{ hashFiles('**/go.sum') }}
31-
32-
- name: Cache Go Mod Cache
33-
uses: actions/cache@v4
34-
with:
35-
path: ${{ steps.go-cache-paths.outputs.go-mod }}
36-
key: ${{ runner.os }}-go-mod-${{ hashFiles('**/go.sum') }}
22+
go-version-file: "go.mod"
23+
cache: true
3724

3825
- name: Check code formatting
3926
run: mise run fmt-check
@@ -47,9 +34,8 @@ jobs:
4734
- name: Check examples are up to date
4835
run: mise run examples-check
4936

50-
test-and-build:
51-
name: Test and Build
52-
needs: lint
37+
test:
38+
name: Test
5339
strategy:
5440
matrix:
5541
os: [ubuntu-latest, windows-latest]
@@ -64,41 +50,34 @@ jobs:
6450
- name: Install mise
6551
uses: jdx/mise-action@v2
6652

67-
- name: Get Go cache paths
68-
id: go-cache-paths
69-
shell: bash
70-
run: |
71-
echo "go-build=$(go env GOCACHE)" >> $GITHUB_OUTPUT
72-
echo "go-mod=$(go env GOMODCACHE)" >> $GITHUB_OUTPUT
73-
74-
- name: Cache Go Build Cache
75-
uses: actions/cache@v4
53+
- name: Setup Go with caching
54+
uses: actions/setup-go@v5
7655
with:
77-
path: ${{ steps.go-cache-paths.outputs.go-build }}
78-
key: ${{ runner.os }}-go-build-${{ hashFiles('**/go.sum') }}
56+
go-version-file: "go.mod"
57+
cache: true
7958

80-
- name: Cache Go Mod Cache
81-
uses: actions/cache@v4
82-
with:
83-
path: ${{ steps.go-cache-paths.outputs.go-mod }}
84-
key: ${{ runner.os }}-go-mod-${{ hashFiles('**/go.sum') }}
59+
- name: Get current date
60+
id: date
61+
run: echo "date=$(date +'%Y-%m-%d')" >> $GITHUB_OUTPUT
8562

8663
- name: Cache downloaded test files
8764
uses: actions/cache@v4
8865
with:
89-
path: |
90-
~/tmp/speakeasy-api_arazzo
91-
${{ runner.temp }}/speakeasy-api_arazzo
92-
key: arazzo-test-files-${{ hashFiles('arazzo/arazzo_test.go') }}
66+
path: ${{ runner.temp }}/speakeasy-api_arazzo
67+
key: arazzo-test-files-${{ steps.date.outputs.date }}
9368
restore-keys: |
9469
arazzo-test-files-
9570
9671
- name: Run tests with coverage
9772
if: matrix.os == 'ubuntu-latest'
73+
env:
74+
ARAZZO_CACHE_DIR: ${{ runner.temp }}
9875
run: mise run test-coverage
9976

10077
- name: Run tests (Windows)
10178
if: matrix.os == 'windows-latest'
79+
env:
80+
ARAZZO_CACHE_DIR: ${{ runner.temp }}
10281
run: gotestsum --format testname -- -race ./...
10382

10483
- name: Calculate coverage
@@ -116,15 +95,15 @@ jobs:
11695
# Store current working directory
11796
CURRENT_DIR=$(pwd)
11897
119-
# Fetch main branch
120-
git fetch origin main:main
98+
# Fetch main branch with shallow clone for speed
99+
git fetch --depth=1 origin main:main
121100
122101
# Checkout main branch in a temporary directory
123102
git worktree add /tmp/main-branch main
124103
125-
# Run tests on main branch to get coverage
104+
# Run tests on main branch to get coverage (with timeout)
126105
cd /tmp/main-branch
127-
go test -coverprofile=main-coverage.out -covermode=atomic ./... > /dev/null 2>&1 || echo "Main branch tests failed"
106+
timeout 300 go test -coverprofile=main-coverage.out -covermode=atomic ./... > /dev/null 2>&1 || echo "Main branch tests failed or timed out"
128107
129108
if [ -f main-coverage.out ]; then
130109
MAIN_COVERAGE=$(go tool cover -func=main-coverage.out | grep total | awk '{print $3}' || echo "0.0%")
@@ -249,14 +228,23 @@ jobs:
249228
# This provides a single status check for branch protection
250229
test-summary:
251230
name: Test Summary
252-
needs: [lint, test-and-build]
231+
needs: [lint, test]
253232
runs-on: ubuntu-latest
254233
if: always()
255234
steps:
256235
- name: Check test results
257236
run: |
258-
if [ "${{ needs.test-and-build.result }}" != "success" ]; then
259-
echo "Tests failed or were cancelled"
237+
if [ "${{ needs.lint.result }}" != "success" ] || [ "${{ needs.test.result }}" != "success" ]; then
238+
echo "Lint or tests failed or were cancelled"
260239
exit 1
261240
fi
262-
echo "All tests passed successfully"
241+
echo "All checks passed successfully"
242+
243+
# Add this temporary job to satisfy the phantom check TODO remove once GitHub stops expecting it
244+
test-and-build:
245+
name: test-and-build # Exact name match
246+
runs-on: ubuntu-latest
247+
if: always() # Always run
248+
steps:
249+
- name: Satisfy phantom check
250+
run: echo "This job exists only to satisfy the phantom test-and-build status check. It will be removed once GitHub stops expecting it."

.github/workflows/commits.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ jobs:
1313
name: Conventional Commits
1414
runs-on: ubuntu-latest
1515
steps:
16-
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
17-
- uses: webiny/action-conventional-commits@8bc41ff4e7d423d56fa4905f6ff79209a78776c7 # v1.3.0
18-
- uses: amannn/action-semantic-pull-request@0723387faaf9b38adef4775cd42cfd5155ed6017 # v5.5.3
16+
- uses: actions/checkout@v4
17+
- uses: webiny/[email protected]
18+
- uses: amannn/[email protected]
1919
env:
2020
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

arazzo/arazzo_test.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -788,7 +788,12 @@ func TestArazzo_StressTests_RoundTrip(t *testing.T) {
788788
}
789789

790790
func downloadFile(url string) (io.ReadCloser, error) {
791-
tempDir := filepath.Join(os.TempDir(), "speakeasy-api_arazzo")
791+
// Use environment variable for cache directory, fallback to system temp dir
792+
cacheDir := os.Getenv("ARAZZO_CACHE_DIR")
793+
if cacheDir == "" {
794+
cacheDir = os.TempDir()
795+
}
796+
tempDir := filepath.Join(cacheDir, "speakeasy-api_arazzo")
792797

793798
if err := os.MkdirAll(tempDir, os.ModePerm); err != nil {
794799
return nil, err

0 commit comments

Comments
 (0)