Never regenerate mf.pb.go during checks; fail when it is stale (closes #71)
check / check (push) Failing after 1s
check / check (push) Failing after 1s
The test and format scripts regenerated mfer/mf.pb.go whenever mfer/mf.proto looked newer by mtime, which a fresh checkout often causes, so make check could rewrite a committed file and needed protoc. Nothing regenerates it any more except make generate (script/generate), which refuses to run unless protoc 33.4 and protoc-gen-go v1.36.11, the versions that wrote the committed file, are on PATH, and records the hash of mf.proto in mfer/mf.proto.sha256. A Go test compares that hash with mf.proto and fails, naming make generate, when they differ. The mtime rule, the unused protoc-gen-go v1.28.1 install rule, make clean's deletion of mf.pb.go and the Dockerfile's touch workarounds are removed. Model: opus-5-5
This commit was merged in pull request #138.
This commit is contained in:
@@ -0,0 +1 @@
|
||||
103901c42b94396aa7ae128fd503ef693a4b7a03b2169481f25fda3d2c254e00 mf.proto
|
||||
@@ -0,0 +1,29 @@
|
||||
package mfer_test
|
||||
|
||||
import (
|
||||
"crypto/sha256"
|
||||
"encoding/hex"
|
||||
"os"
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/require"
|
||||
)
|
||||
|
||||
// mf.pb.go is generated from mf.proto and committed. `make generate`
|
||||
// records the hash of the mf.proto it generated from in mf.proto.sha256.
|
||||
func TestGeneratedCodeMatchesProto(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
proto, err := os.ReadFile("mf.proto")
|
||||
require.NoError(t, err)
|
||||
|
||||
recorded, err := os.ReadFile("mf.proto.sha256")
|
||||
require.NoError(t, err)
|
||||
|
||||
recordedHash, _, _ := strings.Cut(string(recorded), " ")
|
||||
sum := sha256.Sum256(proto)
|
||||
require.Equal(t, recordedHash, hex.EncodeToString(sum[:]),
|
||||
"mfer/mf.proto has changed since mfer/mf.pb.go was generated "+
|
||||
"from it: run `make generate` and commit the result")
|
||||
}
|
||||
Reference in New Issue
Block a user