-
Notifications
You must be signed in to change notification settings - Fork 179
134 lines (117 loc) · 3.57 KB
/
Copy pathci.yml
File metadata and controls
134 lines (117 loc) · 3.57 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
name: CI
on:
push:
branches:
- main
pull_request:
workflow_dispatch:
jobs:
test:
runs-on: ${{ matrix.runner }}
strategy:
fail-fast: false
matrix:
flags: [""]
arch:
- amd64
runner:
- ubuntu-latest
- macos-latest
- windows-latest
include:
- arch: 386
runner: ubuntu-latest
- arch: amd64
runner: ubuntu-latest
flags: "-race"
steps:
- name: Checkout code
uses: actions/checkout@v7
- name: Install Go
uses: actions/setup-go@v7
with:
go-version: "oldstable"
cache: false
- name: Get Go environment
id: go-env
shell: bash
run: |
echo "cache=$(go env GOCACHE)" >> $GITHUB_ENV
echo "modcache=$(go env GOMODCACHE)" >> $GITHUB_ENV
# Build cache key prefix, using runner OS and arch.
- name: Compute cache prefix
id: cache-prefix
shell: bash
env:
RUNNER_PREFIX: ${{ runner.os }}-${{ runner.arch }}-go
ARCH_PREFIX: ${{ matrix.arch != 'amd64' && format('-{0}', matrix.arch) || '' }}
RACE_PREFIX: ${{ contains(matrix.flags, '-race') && '-race' || '' }}
run: echo "cache_prefix=$RUNNER_PREFIX$ARCH_PREFIX$RACE_PREFIX" >> $GITHUB_ENV
- name: Set up cache
uses: actions/cache@v6
with:
path: |
${{ env.cache }}
${{ env.modcache }}
key: ${{ env.cache_prefix }}-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ env.cache_prefix }}-
- name: Run tests
env:
GOARCH: ${{ matrix.arch }}
GOFLAGS: ${{ matrix.flags }}
run: go test --timeout 15m ./...
# Keep benchmark up to date.
- name: Run benchmarks
if: ${{ !contains(matrix.flags, '-race') }}
env:
GOARCH: ${{ matrix.arch }}
GOFLAGS: ${{ matrix.flags }}
run: go test --timeout 15m --benchtime 3x --benchmem --bench "Benchmark" --run=$^. ./...
test-examples:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v7
- name: Install Go
uses: actions/setup-go@v7
with:
go-version: "oldstable"
cache: false
- name: Get Go environment
id: go-env
run: |
echo "cache=$(go env GOCACHE)" >> $GITHUB_ENV
echo "modcache=$(go env GOMODCACHE)" >> $GITHUB_ENV
- name: Set up cache
uses: actions/cache@v6
with:
path: |
${{ env.cache }}
${{ env.modcache }}
key: test-examples-${{ runner.os }}-${{ runner.arch }}-go-${{ hashFiles('**/go.sum') }}
restore-keys: |
test-examples-${{ runner.os }}-${{ runner.arch }}-go-
- name: Run tests
run: cd examples && go test ./...
ensure-docker:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v7
- name: Build image
run: |
docker build . \
--tag ghcr.io/$GITHUB_REPOSITORY:$GITHUB_SHA
- name: Check image
run: |
docker run \
-v ./_testdata/examples/petstore.yml:/petstore.yml \
--rm \
ghcr.io/$GITHUB_REPOSITORY:$GITHUB_SHA /petstore.yml
- name: Check image certs
run: |
docker run \
--rm \
ghcr.io/$GITHUB_REPOSITORY:$GITHUB_SHA \
https://raw.githubusercontent.com/ogen-go/ogen/refs/heads/main/_testdata/examples/petstore.yml