Skip to content

Commit

Permalink
Upgrade buf yaml config and CI (#14)
Browse files Browse the repository at this point in the history
This PR upgrades the config for buf modules, fixing lint checks, and
updating the CI to push the main module. The config file is upgraded to
v2 (follows this
[guide](https://buf.build/docs/migration-guides/migrate-v2-config-files)).
Ran `buf lint` and corrected the CEL expression on the `Interval` type.
Uses [buf-action](https://github.com/bufbuild/buf-action) config to run
build, checks (lint, format, breaking), and push on each feature branch
and main to the BSR. Please see commit-by-commit for a breakdown of the
steps.

There are a couple of behaviour changes in this PR. This implements the
[default
behaviour](https://github.com/bufbuild/buf-action?tab=readme-ov-file#default-behavior)
as described in the buf-action repo. Every push will now sync with the
BSR. On pull requests checks will be run. On merging to main the deleted
branch will be archived and the latest on main synced.
  • Loading branch information
emcfarlane authored Jul 17, 2024
1 parent c625048 commit 32fab75
Show file tree
Hide file tree
Showing 10 changed files with 87 additions and 86 deletions.
44 changes: 22 additions & 22 deletions .github/workflows/build-and-publish-protos.yaml
Original file line number Diff line number Diff line change
@@ -1,30 +1,30 @@
---
name: build-and-publish-protos
name: build-test-and-publish-protos
on:
push:
paths:
- .github/workflows/build-and-publish-protos.yaml
- 'proto/**'
- buf.yaml
- buf.lock
pull_request:
paths:
- 'proto/**/*.proto'
- .github/workflows/build-and-publish-protos.yaml
- 'proto/**'
- buf.yaml
- buf.lock
types: [opened, synchronize, reopened, labeled, unlabeled]
delete:
permissions:
contents: read
pull-requests: write
jobs:
build-and-publish-protos:
buf:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3

- uses: bufbuild/[email protected]

- name: Verify that protos build.
run: buf build

- id: push-aep-type
uses: bufbuild/buf-push-action@v1
with:
buf_token: ${{ secrets.BUF_TOKEN }}
input: proto/aep-type
draft: ${{ github.ref_name != 'main'}}

- id: push-aep-api
uses: bufbuild/buf-push-action@v1
- uses: actions/checkout@v4
- uses: bufbuild/[email protected]
with:
buf_token: ${{ secrets.BUF_TOKEN }}
input: proto/aep-api
draft: ${{ github.ref_name != 'main'}}
token: ${{ secrets.BUF_TOKEN }}
pr_comment: false
format: false
9 changes: 9 additions & 0 deletions buf.lock
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# Generated by buf. DO NOT EDIT.
version: v2
deps:
- name: buf.build/bufbuild/protovalidate
commit: f05a6f4403ce4327bae4f50f281c3ed0
digest: b5:f1d76430ee97c89cd2044e9ae1c510887b701ee7bca60564ebf82e3919e53cacefc830a0eb803277c2d98c5f313b4167e8914afc9f214332717a50b5e170e6f4
- name: buf.build/googleapis/googleapis
commit: 7a6bc1e3207144b38e9066861e1de0ff
digest: b5:6d05bde5ed4cd22531d7ca6467feb828d2dc45cc9de12ce3345fbddd64ddb1bf0db756558c32ca49e6bc7de4426ada8960d5590e8446854b81f5f36f0916dc48
5 changes: 0 additions & 5 deletions buf.work.yaml

This file was deleted.

55 changes: 55 additions & 0 deletions buf.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
version: v2
modules:
- path: proto/aep-api
name: buf.build/aep/api
lint:
use:
- DEFAULT
except:
- FIELD_NOT_REQUIRED
- PACKAGE_NO_IMPORT_CYCLE
- PACKAGE_VERSION_SUFFIX
disallow_comment_ignores: true
breaking:
use:
- FILE
except:
- EXTENSION_NO_DELETE
- FIELD_SAME_DEFAULT
- path: proto/aep-conformance
name: buf.build/aep/conformance
lint:
use:
- DEFAULT
except:
- ENUM_VALUE_PREFIX
- ENUM_ZERO_VALUE_SUFFIX
- FIELD_NOT_REQUIRED
- PACKAGE_NO_IMPORT_CYCLE
- PACKAGE_VERSION_SUFFIX
disallow_comment_ignores: true
breaking:
use:
- FILE
except:
- EXTENSION_NO_DELETE
- FIELD_SAME_DEFAULT
- path: proto/aep-type
name: buf.build/aep/type
lint:
use:
- DEFAULT
except:
- FIELD_NOT_REQUIRED
- PACKAGE_NO_IMPORT_CYCLE
- PACKAGE_VERSION_SUFFIX
disallow_comment_ignores: true
breaking:
use:
- FILE
except:
- EXTENSION_NO_DELETE
- FIELD_SAME_DEFAULT
deps:
- buf.build/bufbuild/protovalidate
- buf.build/googleapis/googleapis
13 changes: 0 additions & 13 deletions proto/aep-api/buf.lock

This file was deleted.

13 changes: 0 additions & 13 deletions proto/aep-api/buf.yaml

This file was deleted.

12 changes: 0 additions & 12 deletions proto/aep-conformance/buf.yaml

This file was deleted.

2 changes: 1 addition & 1 deletion proto/aep-type/aep/type/interval.proto
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ message Interval {
option (buf.validate.message).cel = {
id: "Interval.non-empty",
message: "start must be <= end",
expression: "this.start <= this.end",
expression: "this.start_time <= this.end_time",
};

// Optional. Inclusive start of the interval.
Expand Down
8 changes: 0 additions & 8 deletions proto/aep-type/buf.lock

This file was deleted.

12 changes: 0 additions & 12 deletions proto/aep-type/buf.yaml

This file was deleted.

0 comments on commit 32fab75

Please sign in to comment.