Skip to content

Commit

Permalink
Merge branch 'main' into jkutner/fix-proj-build-env
Browse files Browse the repository at this point in the history
  • Loading branch information
jkutner committed Aug 12, 2022
2 parents da8d25b + 6575218 commit 71021c7
Show file tree
Hide file tree
Showing 25 changed files with 1,619 additions and 149 deletions.
34 changes: 32 additions & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ jobs:
pack_bin: pack.exe
- config: windows-wcow
os: windows
runner: [self-hosted, windows, wcow]
runner: [windows-2019]
no_docker: "false"
pack_bin: pack.exe
runs-on: ${{ matrix.runner }}
Expand Down Expand Up @@ -89,6 +89,36 @@ jobs:
shell: powershell
- name: Verify
run: make verify
- name: Register runner IP
if: matrix.config == 'windows-wcow'
shell: powershell
run: |
# Get IP from default gateway interface
$IPAddress=(Get-NetIPAddress -InterfaceAlias ((Get-NetRoute "0.0.0.0/0").InterfaceAlias) -AddressFamily IPv4)[0].IPAddress
# Allow container-to-host registry traffic (from public interface, to the same interface)
New-NetfirewallRule -DisplayName test-registry -LocalAddress $IPAddress -RemoteAddress $IPAddress
# create or update daemon config to allow host as insecure-registry
$config=@{}
if (Test-Path C:\ProgramData\docker\config\daemon.json) {
$config=(Get-Content C:\ProgramData\docker\config\daemon.json | ConvertFrom-json)
}
$config."insecure-registries" = @("$IPAddress/32")
ConvertTo-json $config | Out-File -Encoding ASCII C:\ProgramData\docker\config\daemon.json
Restart-Service docker
# dump docker info for auditing
docker version
docker info
# Modify etc\hosts to include runner IP
$IPAddress=(Get-NetIPAddress -InterfaceAlias ((Get-NetRoute "0.0.0.0/0").InterfaceAlias) -AddressFamily IPv4)[0].IPAddress
"# Modified by CNB: https://github.com/buildpacks/ci/tree/main/gh-runners/windows
${IPAddress} host.docker.internal
${IPAddress} gateway.docker.internal
" | Out-File -Filepath C:\Windows\System32\drivers\etc\hosts -Encoding utf8
- name: Test
env:
TEST_COVERAGE: 1
Expand Down Expand Up @@ -124,7 +154,7 @@ jobs:
PACK_BUILD: ${{ github.run_number }}
shell: powershell
- uses: actions/upload-artifact@v3
if: matrix.config != 'windows-wcow'
if: matrix.config != 'windows-lcow'
with:
name: pack-${{ matrix.os }}
path: out/${{ env.PACK_BIN }}
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
[![GoDoc](https://godoc.org/github.com/buildpacks/pack?status.svg)](https://godoc.org/github.com/buildpacks/pack)
[![GitHub license](https://img.shields.io/github/license/buildpacks/pack)](https://github.com/buildpacks/pack/blob/main/LICENSE)
[![CII Best Practices](https://bestpractices.coreinfrastructure.org/projects/4748/badge)](https://bestpractices.coreinfrastructure.org/projects/4748)
[![Slack](https://img.shields.io/badge/slack-join-ff69b4.svg?logo=slack)](https://slack.buildpacks.io/)
[![Slack](https://img.shields.io/badge/slack-join-ff69b4.svg?logo=slack)](https://slack.cncf.io/)
[![Gitpod ready-to-code](https://img.shields.io/badge/Gitpod-ready--to--code-blue?logo=gitpod)](https://gitpod.io/#https://github.com/buildpacks/pack)

`pack` makes it easy for...
Expand Down
49 changes: 45 additions & 4 deletions acceptance/acceptance_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -780,8 +780,8 @@ func testAcceptance(
ref, err := name.ParseReference(repoName, name.WeakValidation)
assert.Nil(err)
cacheImage := cache.NewImageCache(ref, dockerCli)
buildCacheVolume := cache.NewVolumeCache(ref, "build", dockerCli)
launchCacheVolume := cache.NewVolumeCache(ref, "launch", dockerCli)
buildCacheVolume := cache.NewVolumeCache(ref, cache.CacheInfo{}, "build", dockerCli)
launchCacheVolume := cache.NewVolumeCache(ref, cache.CacheInfo{}, "launch", dockerCli)
cacheImage.Clear(context.TODO())
buildCacheVolume.Clear(context.TODO())
launchCacheVolume.Clear(context.TODO())
Expand Down Expand Up @@ -1756,6 +1756,47 @@ func testAcceptance(
})
})

when("--cache with options for build cache as image", func() {
var cacheImageName, cacheFlags string
it.Before(func() {
h.SkipIf(t, !pack.SupportsFeature(invoke.Cache), "")
cacheImageName = fmt.Sprintf("%s-cache", repoName)
cacheFlags = fmt.Sprintf("type=build;format=image;name=%s", cacheImageName)
})

it("creates image and cache image on the registry", func() {
buildArgs := []string{
repoName,
"-p", filepath.Join("testdata", "mock_app"),
"--publish",
"--cache",
cacheFlags,
}
if imageManager.HostOS() != "windows" {
buildArgs = append(buildArgs, "--network", "host")
}

output := pack.RunSuccessfully("build", buildArgs...)
assertions.NewOutputAssertionManager(t, output).ReportsSuccessfulImageBuild(repoName)

cacheImageRef, err := name.ParseReference(cacheImageName, name.WeakValidation)
assert.Nil(err)

t.Log("checking that registry has contents")
assertImage.CanBePulledFromRegistry(repoName)
if imageManager.HostOS() == "windows" {
// Cache images are automatically Linux container images, and therefore can't be pulled
// and inspected correctly on WCOW systems
// https://github.com/buildpacks/lifecycle/issues/529
imageManager.PullImage(cacheImageRef.Name(), registryConfig.RegistryAuth())
} else {
assertImage.CanBePulledFromRegistry(cacheImageRef.Name())
}

defer imageManager.CleanupImages(cacheImageRef.Name())
})
})

when("ctrl+c", func() {
it("stops the execution", func() {
var buf = new(bytes.Buffer)
Expand Down Expand Up @@ -2382,8 +2423,8 @@ include = [ "*.jar", "media/mountain.jpg", "/media/person.png", ]
imageManager.CleanupImages(origID, repoName, runBefore)
ref, err := name.ParseReference(repoName, name.WeakValidation)
assert.Nil(err)
buildCacheVolume := cache.NewVolumeCache(ref, "build", dockerCli)
launchCacheVolume := cache.NewVolumeCache(ref, "launch", dockerCli)
buildCacheVolume := cache.NewVolumeCache(ref, cache.CacheInfo{}, "build", dockerCli)
launchCacheVolume := cache.NewVolumeCache(ref, cache.CacheInfo{}, "launch", dockerCli)
assert.Succeeds(buildCacheVolume.Clear(context.TODO()))
assert.Succeeds(launchCacheVolume.Clear(context.TODO()))
})
Expand Down
12 changes: 10 additions & 2 deletions acceptance/invoke/pack.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ package invoke

import (
"bytes"
"fmt"
"io/ioutil"
"os"
"os/exec"
Expand Down Expand Up @@ -210,20 +211,27 @@ func (i *PackInvoker) Supports(command string) bool {
search = command
}

re := regexp.MustCompile(fmt.Sprint(`\b%s\b`, search))
output, err := i.baseCmd(cmdParts...).CombinedOutput()
i.assert.Nil(err)

return strings.Contains(string(output), search) && !strings.Contains(string(output), "Unknown help topic")
return re.MatchString(string(output)) && !strings.Contains(string(output), "Unknown help topic")
}

type Feature int

const CreationTime = iota
const (
CreationTime = iota
Cache
)

var featureTests = map[Feature]func(i *PackInvoker) bool{
CreationTime: func(i *PackInvoker) bool {
return i.Supports("build --creation-time")
},
Cache: func(i *PackInvoker) bool {
return i.Supports("build --cache")
},
}

func (i *PackInvoker) SupportsFeature(f Feature) bool {
Expand Down
31 changes: 17 additions & 14 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
module github.com/buildpacks/pack

require (
github.com/BurntSushi/toml v1.1.0
github.com/BurntSushi/toml v1.2.0
github.com/Masterminds/semver v1.5.0
github.com/apex/log v1.9.0
github.com/buildpacks/imgutil v0.0.0-20220527150729-7a271a852e31
Expand All @@ -10,16 +10,17 @@ require (
github.com/docker/docker v20.10.17+incompatible
github.com/docker/go-connections v0.4.0
github.com/dustin/go-humanize v1.0.0
github.com/gdamore/tcell/v2 v2.5.1
github.com/gdamore/tcell/v2 v2.5.2
github.com/ghodss/yaml v1.0.0
github.com/go-git/go-git/v5 v5.4.2
github.com/golang/mock v1.6.0
github.com/google/go-cmp v0.5.8
github.com/google/go-containerregistry v0.10.0
github.com/google/go-containerregistry v0.11.0
github.com/google/go-github/v30 v30.1.0
github.com/hectane/go-acl v0.0.0-20190604041725-da78bae5fc95
github.com/heroku/color v0.0.6
github.com/mitchellh/ioprogress v0.0.0-20180201004757-6a23b12fa88e
github.com/onsi/gomega v1.19.0
github.com/onsi/gomega v1.20.0
github.com/opencontainers/image-spec v1.0.3-0.20220114050600-8b9d41f48198
github.com/pelletier/go-toml v1.9.5
github.com/pkg/errors v0.9.1
Expand All @@ -29,10 +30,9 @@ require (
github.com/spf13/cobra v1.5.0
golang.org/x/crypto v0.0.0-20220525230936-793ad666bf5e
golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4
golang.org/x/oauth2 v0.0.0-20220524215830-622c5d57e401
golang.org/x/oauth2 v0.0.0-20220718184931-c8730f7fcb92
golang.org/x/term v0.0.0-20220411215600-e5f449aeb171
gopkg.in/natefinch/npipe.v2 v2.0.0-20160621034901-c1b8fa8bdcce
gopkg.in/src-d/go-git.v4 v4.13.1
gopkg.in/yaml.v3 v3.0.1
)

Expand All @@ -49,6 +49,8 @@ require (
github.com/Azure/go-autorest/tracing v0.6.0 // indirect
github.com/Microsoft/go-winio v0.5.2 // indirect
github.com/Microsoft/hcsshim v0.9.2 // indirect
github.com/ProtonMail/go-crypto v0.0.0-20210428141323-04723f9f07d7 // indirect
github.com/acomagu/bufpipe v1.0.3 // indirect
github.com/aws/aws-sdk-go-v2 v1.16.4 // indirect
github.com/aws/aws-sdk-go-v2/config v1.15.9 // indirect
github.com/aws/aws-sdk-go-v2/credentials v1.12.4 // indirect
Expand All @@ -66,23 +68,26 @@ require (
github.com/chrismellard/docker-credential-acr-env v0.0.0-20220327082430-c57b701bfc08 // indirect
github.com/containerd/cgroups v1.0.3 // indirect
github.com/containerd/containerd v1.6.3 // indirect
github.com/containerd/stargz-snapshotter/estargz v0.11.4 // indirect
github.com/containerd/stargz-snapshotter/estargz v0.12.0 // indirect
github.com/dimchansky/utfbom v1.1.1 // indirect
github.com/docker/distribution v2.8.1+incompatible // indirect
github.com/docker/docker-credential-helpers v0.6.4 // indirect
github.com/docker/go-units v0.4.0 // indirect
github.com/emirpasic/gods v1.18.1 // indirect
github.com/gdamore/encoding v1.0.0 // indirect
github.com/go-git/gcfg v1.5.0 // indirect
github.com/go-git/go-billy/v5 v5.3.1 // indirect
github.com/gogo/protobuf v1.3.2 // indirect
github.com/golang-jwt/jwt/v4 v4.4.1 // indirect
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect
github.com/golang/protobuf v1.5.2 // indirect
github.com/google/go-querystring v1.0.0 // indirect
github.com/imdario/mergo v0.3.12 // indirect
github.com/inconshreveable/mousetrap v1.0.0 // indirect
github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99 // indirect
github.com/jmespath/go-jmespath v0.4.0 // indirect
github.com/kevinburke/ssh_config v1.2.0 // indirect
github.com/klauspost/compress v1.15.5 // indirect
github.com/klauspost/compress v1.15.8 // indirect
github.com/lucasb-eyer/go-colorful v1.2.0 // indirect
github.com/mattn/go-colorable v0.1.12 // indirect
github.com/mattn/go-isatty v0.0.14 // indirect
Expand All @@ -97,19 +102,17 @@ require (
github.com/opencontainers/selinux v1.10.1 // indirect
github.com/rivo/uniseg v0.2.0 // indirect
github.com/sergi/go-diff v1.2.0 // indirect
github.com/sirupsen/logrus v1.8.1 // indirect
github.com/sirupsen/logrus v1.9.0 // indirect
github.com/spf13/pflag v1.0.5 // indirect
github.com/src-d/gcfg v1.4.0 // indirect
github.com/vbatts/tar-split v0.11.2 // indirect
github.com/xanzy/ssh-agent v0.3.1 // indirect
go.opencensus.io v0.23.0 // indirect
golang.org/x/net v0.0.0-20220526153639-5463443f8c37 // indirect
golang.org/x/sync v0.0.0-20220513210516-0976fa681c29 // indirect
golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a // indirect
golang.org/x/net v0.0.0-20220708220712-1185a9018129 // indirect
golang.org/x/sync v0.0.0-20220601150217-0de741cfad7f // indirect
golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8 // indirect
golang.org/x/text v0.3.7 // indirect
google.golang.org/appengine v1.6.7 // indirect
google.golang.org/protobuf v1.28.0 // indirect
gopkg.in/src-d/go-billy.v4 v4.3.2 // indirect
gopkg.in/warnings.v0 v0.1.2 // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect
)
Expand Down
Loading

0 comments on commit 71021c7

Please sign in to comment.