-
Notifications
You must be signed in to change notification settings - Fork 23
90 lines (86 loc) · 2.83 KB
/
pr.yml
File metadata and controls
90 lines (86 loc) · 2.83 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
name: pr
on:
pull_request:
branches: [ "main" ]
workflow_dispatch:
inputs:
plugins:
description: "Plugins to build and publish (i.e. connect-go:latest, connect-go, grpc/java:v1.53.0)"
default: ''
type: string
# 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.ref }}
cancel-in-progress: true
defaults:
run:
shell: bash
jobs:
pr:
env:
BUILDKIT_PROGRESS: plain
DOCKERHUB_USERNAME: ${{ secrets.DOCKERHUB_USERNAME }}
runs-on: ubuntu-latest-4-cores
steps:
- name: set PLUGINS from workflow inputs
if: ${{ inputs.plugins }}
run: echo "PLUGINS=${{ inputs.plugins }}" >> $GITHUB_ENV
- uses: actions/checkout@v6
with:
fetch-depth: 0
- name: Install Go
uses: actions/setup-go@v6
with:
go-version-file: 'go.mod'
check-latest: true
- name: Calculate changed plugins and set PLUGINS env var from base branch
if: ${{ inputs.plugins == '' }}
run: |
val=`go run ./internal/cmd/changed-plugins --base-ref 'origin/${{ github.base_ref }}' --include-testdata`
if [[ -n "${val}" && -z "${PLUGINS}" ]]; then
echo "PLUGINS=${val}" >> $GITHUB_ENV
fi
- name: Get buf version
shell: bash
run: |
echo BUF_VERSION=$(go list -m -f '{{.Version}}' github.com/bufbuild/buf | cut -c2-) >> $GITHUB_ENV
- uses: bufbuild/buf-action@v1
with:
setup_only: true
- uses: astral-sh/setup-uv@08807647e7069bb48b6ef5acd8ec9567f424441b # v8.1.0
- name: Login to Docker Hub
if: ${{ env.DOCKERHUB_USERNAME != '' }}
uses: docker/login-action@4907a6ddec9925e35a0a9e82d7399ccc52663121 # v4.1.0
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Set up Docker Buildx
id: buildx
uses: docker/setup-buildx-action@4d04d5d9486b7bd6fa91e7baf45bbb4f8b9deedd # v4.0.0
- name: Login to GitHub Container Registry
uses: docker/login-action@4907a6ddec9925e35a0a9e82d7399ccc52663121 # v4.1.0
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Cache golangci-lint
uses: actions/cache@v5
with:
path: |
.tmp/golangci-lint
.tmp/golangci-lint-*
key: golangci-lint-${{ runner.os }}-${{ hashFiles('Makefile') }}
- name: Lint
run: make lint
- name: Test
run: make test
- name: Archive plugin generated code
uses: actions/upload-artifact@v7
if: ${{ failure() }}
with:
name: plugin-generated-code
path: |
tests/testdata/**/gen/**
retention-days: 3