Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updates github-config #743

Merged
merged 6 commits into from
Sep 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .github/workflows/test-pull-request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ jobs:
uses: actions/checkout@v3

- name: Run Unit Tests
env:
GO_TEST_PARAMS: -count=5
run: ./scripts/unit.sh

- name: Get builders from integration.json
Expand Down
4 changes: 3 additions & 1 deletion build.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,9 @@ func Build(buildProcess BuildProcess, logs scribe.Emitter, clock chronos.Clock,
}

if exists {
layers = append(layers, modCacheLayer)
if !fs.IsEmptyDir(modCacheLayer.Path) {
layers = append(layers, modCacheLayer)
}
}

return packit.BuildResult{
Expand Down
23 changes: 23 additions & 0 deletions build_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,8 @@ func testBuild(t *testing.T, context spec.G, it spec.S) {
err = os.MkdirAll(filepath.Join(layersDir, "mod-cache"), os.ModePerm)
Expect(err).NotTo(HaveOccurred())

Expect(os.WriteFile(filepath.Join(filepath.Join(layersDir, "mod-cache"), "cache"), nil, os.ModePerm))

now := time.Now()
clock = chronos.NewClock(func() time.Time {
return now
Expand Down Expand Up @@ -174,6 +176,27 @@ func testBuild(t *testing.T, context spec.G, it spec.S) {
})
})

context("when the mod cache layer is empty", func() {
it.Before(func() {
err := os.RemoveAll(filepath.Join(layersDir, "mod-cache", "cache"))
Expect(err).NotTo(HaveOccurred())
})

it("does not include the module cache layer in the build result", func() {
result, err := build(packit.BuildContext{
Layers: packit.Layers{Path: layersDir},
WorkingDir: workingDir,
BuildpackInfo: packit.BuildpackInfo{
Name: "Some Buildpack",
Version: "some-version",
},
})
Expect(err).NotTo(HaveOccurred())

Expect(result.Layers).To(BeEmpty())
})
})

context("failure cases", func() {
context("build process fails to check if it should run", func() {
it.Before(func() {
Expand Down
76 changes: 0 additions & 76 deletions integration/empty_cache_test.go

This file was deleted.

1 change: 0 additions & 1 deletion integration/init_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,6 @@ func TestIntegration(t *testing.T) {

suite := spec.New("Integration", spec.Report(report.Terminal{}), spec.Parallel())
suite("Default", testDefault)
suite("EmptyCache", testEmptyCache)
suite("Vendored", testVendored)
suite.Run(t)
}
2 changes: 1 addition & 1 deletion integration/testdata/default/go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module default

go 1.14
go 1.23

require (
github.com/BurntSushi/toml v0.3.1
Expand Down
2 changes: 2 additions & 0 deletions integration/testdata/default/main.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package main

import (
_ "embed"
"fmt"
"log"
"net/http"
Expand All @@ -14,6 +15,7 @@ type Config struct {
Age int
}

//go:embed .occam-key
func main() {
var conf Config
if _, err := toml.Decode("whatever", &conf); err != nil {
Expand Down
3 changes: 0 additions & 3 deletions integration/testdata/no_modules/go.mod

This file was deleted.

7 changes: 0 additions & 7 deletions integration/testdata/no_modules/main.go

This file was deleted.

2 changes: 1 addition & 1 deletion integration/testdata/vendored/go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module default

go 1.14
go 1.23

require (
github.com/BurntSushi/toml v0.3.1
Expand Down
6 changes: 3 additions & 3 deletions scripts/.util/tools.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"createpackage": "v1.70.0",
"jam": "v2.8.0",
"pack": "v0.34.2"
"createpackage": "v1.71.0",
"jam": "v2.9.0",
"pack": "v0.35.1"
}
4 changes: 3 additions & 1 deletion scripts/unit.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ set -o pipefail
readonly PROGDIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
readonly BUILDPACKDIR="$(cd "${PROGDIR}/.." && pwd)"

GO_TEST_PARAMS="${GO_TEST_PARAMS:-}"

# shellcheck source=SCRIPTDIR/.util/tools.sh
source "${PROGDIR}/.util/tools.sh"

Expand Down Expand Up @@ -50,7 +52,7 @@ function unit::run() {

testout=$(mktemp)
pushd "${BUILDPACKDIR}" > /dev/null
if go test ./... -v -run Unit | tee "${testout}"; then
if go test ./... -v ${GO_TEST_PARAMS} -run Unit | tee "${testout}"; then
util::tools::tests::checkfocus "${testout}"
util::print::success "** GO Test Succeeded **"
else
Expand Down
Loading