Skip to content

refactor:integration tests #11

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

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
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
10 changes: 0 additions & 10 deletions .github/workflows/push-buildpackage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,16 +39,6 @@ jobs:
exit 1
fi

- name: Push to GCR
env:
GCR_PUSH_BOT_JSON_KEY: ${{ secrets.GCR_PUSH_BOT_JSON_KEY }}
run: |
echo "${GCR_PUSH_BOT_JSON_KEY}" | sudo skopeo login --username _json_key --password-stdin gcr.io
sudo skopeo copy "oci-archive:${GITHUB_WORKSPACE}/buildpackage.cnb" "docker://gcr.io/${{ github.repository }}:${{ steps.event.outputs.tag_full }}"
sudo skopeo copy "oci-archive:${GITHUB_WORKSPACE}/buildpackage.cnb" "docker://gcr.io/${{ github.repository }}:${{ steps.event.outputs.tag_minor }}"
sudo skopeo copy "oci-archive:${GITHUB_WORKSPACE}/buildpackage.cnb" "docker://gcr.io/${{ github.repository }}:${{ steps.event.outputs.tag_major }}"
sudo skopeo copy "oci-archive:${GITHUB_WORKSPACE}/buildpackage.cnb" "docker://gcr.io/${{ github.repository }}:latest"

- name: Push to DockerHub
id: push
env:
Expand Down
13 changes: 13 additions & 0 deletions .github/workflows/test-pull-request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,19 @@ jobs:
builder: ${{ fromJSON(needs.unit.outputs.builders) }}
fail-fast: false # don't cancel all test jobs when one fails
steps:
- name: Free Disk Space (Ubuntu)
uses: jlumbroso/free-disk-space@main
with:
# This might remove tools that are actually needed,
# if set to "true" but frees about 6 GB
tool-cache: false
# Default settings from documentation
android: true
dotnet: true
haskell: true
large-packages: true
docker-images: true
swap-storage: true
- name: Setup Go
uses: actions/setup-go@v3
with:
Expand Down
2 changes: 1 addition & 1 deletion REUSE.toml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ SPDX-FileCopyrightText = "Copyright (c) 2013-Present CloudFoundry.org Foundation
SPDX-License-Identifier = "Apache-2.0"

[[annotations]]
path = "integration/**/integration.json"
path = "integration.json"
precedence = "override"
SPDX-FileCopyrightText = "Copyright (c) 2013-Present CloudFoundry.org Foundation, Inc. All Rights Reserved."
SPDX-License-Identifier = "Apache-2.0"
12 changes: 12 additions & 0 deletions integration.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"builders":
[
"index.docker.io/paketobuildpacks/builder:buildpackless-base",
"index.docker.io/paketobuildpacks/builder-jammy-buildpackless-base:latest",
"index.docker.io/jericop/amazonlinux-builder:base"
],

"build-plan": "github.com/paketo-community/build-plan",
"cpython": "github.com/paketo-buildpacks/cpython",
"pip": "github.com/paketo-buildpacks/pip"
}
59 changes: 28 additions & 31 deletions integration/helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,37 +5,6 @@

package integration_helpers

import (
"os"
"path/filepath"

"github.com/ForestEckhardt/freezer"
"github.com/ForestEckhardt/freezer/github"
"github.com/paketo-buildpacks/occam"
"github.com/paketo-buildpacks/occam/packagers"
)

func NewBuildpackStore(suffix string) occam.BuildpackStore {
gitToken := os.Getenv("GIT_TOKEN")
cacheManager := freezer.NewCacheManager(filepath.Join(os.Getenv("HOME"), ".freezer-cache", suffix))
releaseService := github.NewReleaseService(github.NewConfig("https://api.github.com", gitToken))
packager := packagers.NewJam()
namer := freezer.NewNameGenerator()

return occam.NewBuildpackStore().WithLocalFetcher(
freezer.NewLocalFetcher(
&cacheManager,
packager,
namer,
)).WithRemoteFetcher(
freezer.NewRemoteFetcher(
&cacheManager,
releaseService, packager,
)).WithCacheManager(
&cacheManager,
)
}

type Buildpack struct {
ID string
Name string
Expand All @@ -55,6 +24,34 @@ type BuildpackInfo struct {
Metadata Metadata
}

type TestSettings struct {
Buildpacks struct {
// Dependency buildpacks
CPython struct {
Online string
Offline string
}
Pip struct {
Online string
Offline string
}
BuildPlan struct {
Online string
}
// This buildpack
PythonInstallers struct {
Online string
Offline string
}
}

Config struct {
CPython string `json:"cpython"`
Pip string `json:"pip"`
BuildPlan string `json:"build-plan"`
}
}

func DependenciesForId(dependencies []Dependency, id string) []Dependency {
output := []Dependency{}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,77 +28,66 @@ var (

buildpackInfo integration_helpers.BuildpackInfo

settings struct {
Buildpacks struct {
CPython struct {
Online string
Offline string
}
Pip struct {
Online string
Offline string
}
BuildPlan struct {
Online string
}
}

Config struct {
CPython string `json:"cpython"`
BuildPlan string `json:"build-plan"`
}
}
settings integration_helpers.TestSettings
)

func TestPipIntegration(t *testing.T) {
func TestIntegration(t *testing.T) {
// Do not truncate Gomega matcher output
// The buildpack output text can be large and we often want to see all of it.
format.MaxLength = 0

Expect := NewWithT(t).Expect

file, err := os.Open("integration.json")
root, err := filepath.Abs("./../../")
Expect(err).NotTo(HaveOccurred())

file, err := os.Open(filepath.Join(root, "/integration.json"))
Expect(err).NotTo(HaveOccurred())

Expect(json.NewDecoder(file).Decode(&settings.Config)).To(Succeed())
err = json.NewDecoder(file).Decode(&settings.Config)
Expect(err).NotTo(HaveOccurred())
Expect(file.Close()).To(Succeed())

file, err = os.Open("./../../../buildpack.toml")
file, err = os.Open(filepath.Join(root, "buildpack.toml"))
Expect(err).NotTo(HaveOccurred())

_, err = toml.NewDecoder(file).Decode(&buildpackInfo)
Expect(err).NotTo(HaveOccurred())
Expect(file.Close()).To(Succeed())

buildpackInfo.Metadata.Dependencies = integration_helpers.DependenciesForId(buildpackInfo.Metadata.Dependencies, "pip")
buildpackStore := occam.NewBuildpackStore()

root, err := filepath.Abs("./../../..")
Expect(err).ToNot(HaveOccurred())
settings.Buildpacks.BuildPlan.Online, err = buildpackStore.Get.
Execute(settings.Config.BuildPlan)
Expect(err).NotTo(HaveOccurred())

settings.Buildpacks.CPython.Online, err = buildpackStore.Get.
Execute(settings.Config.CPython)
Expect(err).NotTo(HaveOccurred())

buildpackStore := integration_helpers.NewBuildpackStore("pip")
settings.Buildpacks.CPython.Offline, err = buildpackStore.Get.
WithOfflineDependencies().
Execute(settings.Config.CPython)
Expect(err).NotTo(HaveOccurred())

settings.Buildpacks.Pip.Online, err = buildpackStore.Get.
WithVersion("1.2.3").
Execute(root)
Execute(settings.Config.Pip)
Expect(err).NotTo(HaveOccurred())

settings.Buildpacks.Pip.Offline, err = buildpackStore.Get.
WithVersion("1.2.3").
WithOfflineDependencies().
Execute(root)
Execute(settings.Config.Pip)
Expect(err).NotTo(HaveOccurred())

settings.Buildpacks.CPython.Online, err = buildpackStore.Get.
Execute(settings.Config.CPython)
settings.Buildpacks.PythonInstallers.Online, err = buildpackStore.Get.
WithVersion("1.2.3").
Execute(root)
Expect(err).NotTo(HaveOccurred())

settings.Buildpacks.CPython.Offline, err = buildpackStore.Get.
settings.Buildpacks.PythonInstallers.Offline, err = buildpackStore.Get.
WithVersion("1.2.3").
WithOfflineDependencies().
Execute(settings.Config.CPython)
Expect(err).NotTo(HaveOccurred())

settings.Buildpacks.BuildPlan.Online, err = buildpackStore.Get.
Execute(settings.Config.BuildPlan)
Execute(root)
Expect(err).NotTo(HaveOccurred())

pack := occam.NewPack().WithVerbose()
Expand All @@ -107,11 +96,30 @@ func TestPipIntegration(t *testing.T) {

SetDefaultEventuallyTimeout(30 * time.Second)

suite := spec.New("Integration", spec.Report(report.Terminal{}))
suite("Default", testDefault, spec.Parallel())
suite("LayerReuse", testLayerReuse, spec.Parallel())
suite := spec.New("Integration", spec.Report(report.Terminal{}), spec.Parallel())

// miniconda
suite("Miniconda Default", minicondaTestDefault)
suite("Miniconda Logging", minicondaTestLogging)
suite("Miniconda LayerReuse", minicondaTestReusingLayerRebuild)
suite("Miniconda TestOffline", minicondaTestOffline)

// pip
suite("Pip Default", pipTestDefault, spec.Parallel())
suite("Pip LayerReuse", pipTestLayerReuse, spec.Parallel())
if strings.Contains(builder.LocalInfo.Stack.ID, "jammy") || strings.Contains(builder.LocalInfo.Stack.ID, "bionic") {
suite("Offline", testOffline, spec.Parallel())
suite("Pip Offline", pipTestOffline, spec.Parallel())
}

// pipenv
suite("Pipenv Default", pipenvTestDefault, spec.Parallel())
suite("Pipenv LayerReuse", pipenvTestLayerReuse, spec.Parallel())
suite("Pipenv Version", pipenvTestVersions, spec.Parallel())

// poetry
suite("Poetry Default", poetryTestDefault, spec.Parallel())
suite("Poetry LayerReuse", poetryTestLayerReuse, spec.Parallel())
suite("Poetry Versions", poetryTestVersions, spec.Parallel())

suite.Run(t)
}
91 changes: 0 additions & 91 deletions integration/installers/miniconda/init_test.go

This file was deleted.

8 changes: 0 additions & 8 deletions integration/installers/miniconda/integration.json

This file was deleted.

Loading
Loading