-
Notifications
You must be signed in to change notification settings - Fork 364
131 lines (131 loc) · 4.86 KB
/
Copy pathci.yaml
File metadata and controls
131 lines (131 loc) · 4.86 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
name: ci
on:
push:
branches:
- main
tags: ["v*"]
pull_request:
# Prevent writing to the repository using the CI token.
# Ref: https://docs.github.com/en/actions/reference/workflow-syntax-for-github-actions#permissions
permissions: read-all
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
env:
MAKEFLAGS: "-j 2"
jobs:
lint:
runs-on: ubuntu-latest
steps:
- name: checkout
uses: actions/checkout@v7
- name: setup-go
uses: actions/setup-go@v6
with:
go-version: "1.26.x"
check-latest: true
- name: cache
uses: actions/cache@v6
with:
path: |
~/.cache/buf/${{ runner.os }}/x86_64/bin
~/.cache/buf/${{ runner.os }}/x86_64/go/pkg/mod
~/.cache/buf/${{ runner.os }}/x86_64/gocache
~/.cache/buf/${{ runner.os }}/x86_64/include
~/.cache/buf/${{ runner.os }}/x86_64/versions
key: ${{ runner.os }}-buf-lint-${{ hashFiles('**/go.sum', 'make/**') }}
restore-keys: |
${{ runner.os }}-buf-lint-
- name: golangci-lint-cache
uses: actions/cache@v6
with:
path: ~/.cache/golangci-lint
# https://github.com/golangci/golangci-lint-action#caching-internals includes an interval number in the cache
# key, however we update our go modules at least once weekly so we shouldn't need that.
key: ${{ runner.os }}-buf-golangci-lint-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-buf-golangci-lint-
- name: make-lint
run: make lint
env:
# actions/setup-go@v6 exports GOTOOLCHAIN=local via $GITHUB_ENV; override at the
# step level so go.mod's `go` directive can bootstrap a newer toolchain via the
# module proxy when the runner image lags behind.
GOTOOLCHAIN: auto
BUF_BREAKING_AGAINST_INPUT: "https://github.com/bufbuild/buf.git#branch=main"
BUF_INPUT_HTTPS_USERNAME: ${{ github.actor }}
BUF_INPUT_HTTPS_PASSWORD: ${{ github.token }}
test:
runs-on: ubuntu-latest
steps:
- name: checkout
uses: actions/checkout@v7
- name: setup-go
uses: actions/setup-go@v6
with:
go-version: "1.26.x"
check-latest: true
- name: cache
uses: actions/cache@v6
with:
path: |
~/.cache/buf/${{ runner.os }}/x86_64/bin
~/.cache/buf/${{ runner.os }}/x86_64/go/pkg/mod
~/.cache/buf/${{ runner.os }}/x86_64/gocache
~/.cache/buf/${{ runner.os }}/x86_64/include
~/.cache/buf/${{ runner.os }}/x86_64/versions
key: ${{ runner.os }}-buf-test-${{ hashFiles('**/go.sum', 'make/**') }}
restore-keys: |
${{ runner.os }}-buf-test-
- name: make-test
run: make test
docker:
runs-on: ubuntu-latest
needs:
- lint
- test
# This job only runs when
# 1. The previous lint and test jobs have completed successfully
# 2. The repository is not a fork, i.e. it will only run on the official bufbuild/buf
# 3. The workflow run is trigged by main branch OR a tag with v prefix
# See https://github.com/bufbuild/buf/pull/289/files#r596207623 for the discussion
if: ${{ github.repository == 'bufbuild/buf' && (github.ref == 'refs/heads/main' || contains(github.ref, 'refs/tags/v')) }}
steps:
# qemu is used when executing things like `apk` in the final build
# stage which must execute on the target platform. We currently do
# not have any CGO and care should be taken in the Dockerfile to ensure
# that go cross compilation happens on the build platform.
- name: setup-qemu
uses: docker/setup-qemu-action@v4
id: qemu
with:
# alpine image doesn't support linux/riscv64
platforms: linux/386,linux/amd64,linux/arm64,linux/arm/v7,linux/arm/v6,linux/ppc64le,linux/s390x
- name: setup-docker-buildx
uses: docker/setup-buildx-action@v4
- name: login-docker
uses: docker/login-action@v4
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_TOKEN }}
- name: docker-meta
id: meta
uses: docker/metadata-action@v6
with:
images: |
bufbuild/buf
tags: |
type=edge,branch=main
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
type=semver,pattern={{major}}
flavor: |
latest=auto
- name: docker-build-push
uses: docker/build-push-action@v7
with:
file: Dockerfile.buf
platforms: ${{ steps.qemu.outputs.platforms }}
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}