Skip to content

Protobufs

Protobufs #394

Workflow file for this run

name: Protobufs
on:
push:
branches: [ main ]
pull_request:
schedule:
- cron: "0 0 * * *"
jobs:
validate_protobufs:
name: Validate Protobufs
runs-on: ubuntu-latest
steps:
- name: Install go
uses: actions/setup-go@v2
with:
go-version: '1.21'
- name: Checkout code
uses: actions/checkout@v3
- name: Cache
uses: actions/cache@v3
with:
path: |
~/go/pkg/mod
~/.cache/go-build
key: ${{ github.job }}-${{ runner.os }}-go-build-${{ hashFiles('**/go.sum') }}
- name: Install protobuf
uses: arduino/setup-protoc@v1
with:
version: '3.x'
repo-token: ${{ secrets.GITHUB_TOKEN }}
- name: Lint protobufs
run: |
go install github.com/googleapis/api-linter/cmd/api-linter@latest
make protoimports
cd protobuf-import
find github.com/openconfig/featureprofiles/ -name \*.proto -exec api-linter --disable-rule all --enable-rule core {} \+
- name: Validate textprotos
run: |
go install github.com/bstoll/textproto-validator@latest
make protoimports
for i in `find . -name \*.textproto`; do
textproto-validator -I ./protobuf-import $i
done
validate_oc_paths:
name: Validate OpenConfig Paths
runs-on: ubuntu-latest
steps:
- name: Install go
uses: actions/setup-go@v2
with:
go-version: '1.21'
- name: Checkout code
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Cache
uses: actions/cache@v3
with:
path: |
~/go/pkg/mod
~/.cache/go-build
key: ${{ github.job }}-${{ runner.os }}-go-build-${{ hashFiles('**/go.sum') }}
- name: Fetch Openconfig Models
run: make openconfig_public
- name: Validate Paths
run: |
# https://docs.github.com/en/actions/learn-github-actions/variables#default-environment-variables
if [ ! -z "${GITHUB_BASE_REF}" ]; then
readonly HEAD=${{ github.event.pull_request.head.sha }}
readonly BASE="$(git merge-base origin/main "${HEAD}")"
if ! git diff --diff-filter=D --name-only "${BASE}" | grep -E 'feature.textproto$'; then
# If it is a pull request AND if no feature.textproto files were
# deleted, then we can skip checking all but the added/modified
# feature.textproto files.
export FEATURE_FILES=changed-feature-textprotos.githubactions.txt
# grep: don't error out on no match.
git diff --diff-filter=d --name-only "${BASE}" | { grep -E 'feature.textproto$' || true; } > "${FEATURE_FILES}"
fi
fi
make validate_paths