From 167542f57f2cec529d2363bd006ef76f8c42f01c Mon Sep 17 00:00:00 2001 From: Ralf Pannemans Date: Fri, 25 Oct 2024 14:27:15 +0200 Subject: [PATCH] Only use cache layer if yarn.lock AND package.json match --- install_process.go | 2 +- install_process_test.go | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/install_process.go b/install_process.go index 89ae741e..558a8344 100644 --- a/install_process.go +++ b/install_process.go @@ -78,7 +78,7 @@ func (ip YarnInstallProcess) ShouldRun(workingDir string, metadata map[string]in return true, "", fmt.Errorf("failed to write temp file for %s: %w", file.Name(), err) } - sum, err := ip.summer.Sum(filepath.Join(workingDir, "yarn.lock"), file.Name()) + sum, err := ip.summer.Sum(filepath.Join(workingDir, "yarn.lock"), filepath.Join(workingDir, "package.json"), file.Name()) if err != nil { return true, "", fmt.Errorf("unable to sum config files: %w", err) } diff --git a/install_process_test.go b/install_process_test.go index ab0e92b4..4d68b7e6 100644 --- a/install_process_test.go +++ b/install_process_test.go @@ -79,7 +79,8 @@ func testInstallProcess(t *testing.T, context spec.G, it spec.S) { "cache_sha": "some-sha", }) Expect(summer.SumCall.Receives.Paths[0]).To(Equal(filepath.Join(workingDir, "yarn.lock"))) - Expect(summer.SumCall.Receives.Paths[1]).To(ContainSubstring("config-file")) + Expect(summer.SumCall.Receives.Paths[1]).To(Equal(filepath.Join(workingDir, "package.json"))) + Expect(summer.SumCall.Receives.Paths[2]).To(ContainSubstring("config-file")) Expect(run).To(BeTrue()) Expect(sha).To(Equal("some-other-sha")) Expect(err).NotTo(HaveOccurred())