mirror of
https://github.com/absmach/magistrala.git
synced 2026-06-23 04:10:28 +00:00
aaa718bdf6
Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
129 lines
4.0 KiB
YAML
129 lines
4.0 KiB
YAML
# Copyright (c) Abstract Machines
|
|
# SPDX-License-Identifier: Apache-2.0
|
|
|
|
name: Check the consistency of generated files
|
|
|
|
on:
|
|
pull_request:
|
|
branches:
|
|
- main
|
|
|
|
jobs:
|
|
check-generated-files:
|
|
runs-on: ubuntu-latest
|
|
env:
|
|
PROTOC_VERSION: "33.0"
|
|
PROTOC_GEN_GO_VERSION: "v1.36.11"
|
|
PROTOC_GEN_GO_GRPC_VERSION: "v1.6.0"
|
|
steps:
|
|
- name: Checkout code
|
|
uses: actions/checkout@v7
|
|
|
|
- name: Install Go
|
|
uses: actions/setup-go@v6
|
|
with:
|
|
go-version-file: go.mod
|
|
cache-dependency-path: "go.sum"
|
|
|
|
- name: Set GOBIN
|
|
run: echo "GOBIN=$HOME/.local/bin" >> $GITHUB_ENV
|
|
|
|
- name: Add GOBIN to PATH
|
|
run: echo "$HOME/.local/bin" >> $GITHUB_PATH
|
|
|
|
- name: Check for changes in go.mod
|
|
run: |
|
|
go mod tidy
|
|
git diff --exit-code
|
|
|
|
- name: Check for changes in specific paths
|
|
uses: dorny/paths-filter@v4
|
|
id: changes
|
|
with:
|
|
base: main
|
|
filters: |
|
|
proto:
|
|
- ".github/workflows/check-generated-files.yaml"
|
|
- "auth.proto"
|
|
- "auth/*.pb.go"
|
|
- "pkg/messaging/message.proto"
|
|
- "pkg/messaging/*.pb.go"
|
|
|
|
mocks:
|
|
- ".github/workflows/check-generated-files.yaml"
|
|
- "pkg/sdk/sdk.go"
|
|
- "users/postgres/clients.go"
|
|
- "users/clients.go"
|
|
- "pkg/clients/clients.go"
|
|
- "pkg/messaging/pubsub.go"
|
|
- "clients/postgres/clients.go"
|
|
- "clients/clients.go"
|
|
- "pkg/authz.go"
|
|
- "pkg/authn.go"
|
|
- "auth/domains.go"
|
|
- "auth/keys.go"
|
|
- "auth/service.go"
|
|
- "pkg/events/events.go"
|
|
- "pkg/groups/groups.go"
|
|
- "users/emailer.go"
|
|
- "users/hasher.go"
|
|
- "journal/journal.go"
|
|
- "consumers/notifier.go"
|
|
|
|
- name: Install Protoc
|
|
if: steps.changes.outputs.proto == 'true'
|
|
uses: arduino/setup-protoc@v3
|
|
with:
|
|
version: ${{ env.PROTOC_VERSION }}
|
|
repo-token: ${{ secrets.GITHUB_TOKEN }}
|
|
|
|
- name: Install Go Protobuf Plugins
|
|
if: steps.changes.outputs.proto == 'true'
|
|
run: |
|
|
go install google.golang.org/protobuf/cmd/protoc-gen-go@$PROTOC_GEN_GO_VERSION
|
|
go install google.golang.org/grpc/cmd/protoc-gen-go-grpc@$PROTOC_GEN_GO_GRPC_VERSION
|
|
|
|
- name: Check Protobuf is up to Date
|
|
if: steps.changes.outputs.proto == 'true'
|
|
run: |
|
|
for p in $(find . -name "*.pb.go"); do
|
|
mv $p $p.tmp
|
|
done
|
|
|
|
make proto
|
|
|
|
for p in $(find . -name "*.pb.go"); do
|
|
if ! cmp -s $p $p.tmp; then
|
|
echo "Error: Proto file and generated Go file $p are out of sync!"
|
|
echo "Here is the difference:"
|
|
diff $p $p.tmp || true
|
|
echo "Please run 'make proto' with protoc version $PROTOC_VERSION, protoc-gen-go version $PROTOC_GEN_GO_VERSION and protoc-gen-go-grpc version $PROTOC_GEN_GO_GRPC_VERSION and commit the changes."
|
|
exit 1
|
|
fi
|
|
done
|
|
|
|
- name: Check Mocks are up to Date
|
|
if: steps.changes.outputs.mocks == 'true'
|
|
run: |
|
|
for f in $(find . -type f -path '*/mocks/*.go' ! -name 'doc.go'); do
|
|
mv $f $f.tmp
|
|
done
|
|
|
|
make mocks
|
|
|
|
check_mock_changes() {
|
|
local file_path=$1
|
|
local tmp_file_path=$1.tmp
|
|
local entity_name=$2
|
|
|
|
if ! cmp -s "$file_path" "$tmp_file_path"; then
|
|
echo "Error: Generated mocks for $entity_name are out of sync!"
|
|
echo "Please run 'make mocks' with mockery version $MOCKERY_VERSION and commit the changes."
|
|
exit 1
|
|
fi
|
|
}
|
|
|
|
for f in $(find . -type f -path '*/mocks/*.go' ! -name 'doc.go'); do
|
|
check_mock_changes $f "$f"
|
|
done
|