-
Notifications
You must be signed in to change notification settings - Fork 277
118 lines (118 loc) · 4.46 KB
/
ci.yaml
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
name: ci
on: push
# 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
env:
MAKEFLAGS: '-j 2'
jobs:
lint:
runs-on: ubuntu-latest
steps:
- name: checkout
uses: actions/checkout@v4
- name: setup-go
uses: actions/setup-go@v5
with:
go-version: '1.22.x'
- name: cache
uses: actions/cache@v4
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@v4
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:
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@v4
- name: setup-go
uses: actions/setup-go@v5
with:
go-version: '1.22.x'
- name: cache
uses: actions/cache@v4
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@v3
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@v3
- name: login-docker
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_TOKEN }}
- name: docker-meta
id: meta
uses: docker/metadata-action@v5
with:
images: |
bufbuild/buf
tags: |
type=edge,branch=main
type=semver,pattern={{major}}
type=semver,pattern={{major}}.{{minor}}
type=semver,pattern={{major}}.{{minor}}.{{patch}}
type=semver,pattern={{version}}
flavor: |
latest=auto
- name: docker-build-push
uses: docker/build-push-action@v5
with:
file: Dockerfile.buf
platforms: ${{ steps.qemu.outputs.platforms }}
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}