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

Collapse integration test workflows into one config #1855

Merged
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
29 changes: 0 additions & 29 deletions .github/workflows/integration-k8s-tests.yaml

This file was deleted.

28 changes: 0 additions & 28 deletions .github/workflows/integration-layers-tests.yaml

This file was deleted.

37 changes: 0 additions & 37 deletions .github/workflows/integration-misc.yaml

This file was deleted.

28 changes: 0 additions & 28 deletions .github/workflows/integration-run-tests.yaml

This file was deleted.

36 changes: 36 additions & 0 deletions .github/workflows/integration-tests.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
name: Integration tests

on:
push:
branches: ['master']
pull_request:
branches: ['master']

concurrency:
group: integration-test-${{ github.head_ref }}
cancel-in-progress: true

jobs:
tests:
runs-on: ubuntu-latest
env:
IMAGE_REPO: 'localhost:5000'
REGISTRY: 'localhost:5000'
strategy:
fail-fast: false
matrix:
make-target:
- integration-test-layers
- integration-test-misc
- integration-test-run
- k8s-executor-build-push integration-test-k8s

steps:
- uses: actions/setup-go@v2
with:
go-version: 1.17
- uses: actions/checkout@v2
- uses: docker/setup-buildx-action@v1

- run: make install-container-diff minikube-setup
- run: make ${{ matrix.make-target }}
2 changes: 2 additions & 0 deletions .github/workflows/unit-tests.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
name: Unit tests

on:
push:
branches: ['master']
pull_request:
branches: ['master']

Expand Down
4 changes: 1 addition & 3 deletions DEVELOPMENT.md
Original file line number Diff line number Diff line change
Expand Up @@ -158,9 +158,7 @@ You can also run tests with `go test`, for example to run tests individually:
go test ./integration -v --repo localhost:5000 -run TestLayers/test_layer_Dockerfile_test_copy_bucket
```

These tests will be kicked off by [reviewers](#reviews) for submitted PRs by the travis task.


These tests will be kicked off by [reviewers](#reviews) for submitted PRs using GitHub Actions.

### Benchmarking

Expand Down
7 changes: 4 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,10 @@ out/executor: $(GO_FILES)
out/warmer: $(GO_FILES)
GOARCH=$(GOARCH) GOOS=linux CGO_ENABLED=0 go build -ldflags $(GO_LDFLAGS) -o $@ $(WARMER_PACKAGE)

.PHONY: travis-setup
travis-setup:
@ ./scripts/travis-setup.sh
.PHONY: install-container-diff
install-container-diff:
@ curl -LO https://github.com/GoogleContainerTools/container-diff/releases/download/v0.17.0/container-diff-linux-amd64 && \
chmod +x container-diff-linux-amd64 && sudo mv container-diff-linux-amd64 /usr/local/bin/container-diff

.PHONY: minikube-setup
minikube-setup:
Expand Down
7 changes: 5 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
# kaniko - Build Images In Kubernetes

`NOTE: kaniko is not an officially supported Google product`
## 🚨NOTE: kaniko is not an officially supported Google product🚨

[![Build Status](https://travis-ci.com/GoogleContainerTools/kaniko.svg?branch=master)](https://travis-ci.com/GoogleContainerTools/kaniko) [![Go Report Card](https://goreportcard.com/badge/github.com/GoogleContainerTools/kaniko)](https://goreportcard.com/report/github.com/GoogleContainerTools/kaniko)
[![Unit tests](https://github.com/GoogleContainerTools/kaniko/actions/workflows/unit-tests.yaml/badge.svg)](https://github.com/GoogleContainerTools/kaniko/actions/workflows/unit-tests.yaml)
[![Integration tests](https://github.com/GoogleContainerTools/kaniko/actions/workflows/integration-tests.yaml/badge.svg)](https://github.com/GoogleContainerTools/kaniko/actions/workflows/integration-tests.yaml)
[![Build images](https://github.com/GoogleContainerTools/kaniko/actions/workflows/images.yaml/badge.svg)](https://github.com/GoogleContainerTools/kaniko/actions/workflows/images.yaml)
[![Go Report Card](https://goreportcard.com/badge/github.com/GoogleContainerTools/kaniko)](https://goreportcard.com/report/github.com/GoogleContainerTools/kaniko)

![kaniko logo](logo/Kaniko-Logo.png)

Expand Down
78 changes: 26 additions & 52 deletions integration/integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,6 @@ import (
"testing"
"time"

"github.com/go-git/go-git/v5"
gitConfig "github.com/go-git/go-git/v5/config"
"github.com/go-git/go-git/v5/plumbing"
"github.com/go-git/go-git/v5/storage/memory"
"github.com/google/go-containerregistry/pkg/name"
"github.com/google/go-containerregistry/pkg/v1/daemon"
"github.com/pkg/errors"
Expand Down Expand Up @@ -203,53 +199,31 @@ func TestRun(t *testing.T) {
}
}

func findSHA(ref plumbing.ReferenceName, refs []*plumbing.Reference) (string, error) {
for _, ref2 := range refs {
if ref.String() == ref2.Name().String() {
return ref2.Hash().String(), nil
}
}
return "", errors.New("no ref found")
}

// getBranchSHA get a SHA commit hash for the given repo url and branch ref name.
func getBranchSHA(t *testing.T, url, branch string) string {
repo := "https://" + url
c := &gitConfig.RemoteConfig{URLs: []string{repo}}
remote := git.NewRemote(memory.NewStorage(), c)
refs, err := remote.List(&git.ListOptions{})
if err != nil {
t.Fatalf("list remote %s#%s: %s", repo, branch, err)
}
commit, err := findSHA(plumbing.NewBranchReferenceName(branch), refs)
if err != nil {
t.Fatalf("findSHA %s#%s: %s", repo, branch, err)
}
return commit
}

func getBranchAndURL() (branch, url string) {
var repoSlug string
if _, ok := os.LookupEnv("TRAVIS_PULL_REQUEST"); ok {
func getBranchCommitAndURL() (branch, commit, url string) {
repo := os.Getenv("GITHUB_REPOSITORY")
commit = os.Getenv("GITHUB_SHA")
if _, isPR := os.LookupEnv("GITHUB_HEAD_REF"); isPR {
branch = "master"
repoSlug = os.Getenv("TRAVIS_REPO_SLUG")
log.Printf("Travis CI Pull request source repo: %s branch: %s\n", repoSlug, branch)
} else if _, ok := os.LookupEnv("TRAVIS_BRANCH"); ok {
branch = os.Getenv("TRAVIS_BRANCH")
repoSlug = os.Getenv("TRAVIS_REPO_SLUG")
log.Printf("Travis CI repo: %s branch: %s\n", repoSlug, branch)
} else {
branch = os.Getenv("GITHUB_REF")
log.Printf("GITHUB_HEAD_REF is unset (not a PR); using GITHUB_REF=%q", branch)
branch = strings.TrimPrefix(branch, "refs/heads/")
}
if repo == "" {
repo = "GoogleContainerTools/kaniko"
}
if branch == "" {
branch = "master"
repoSlug = "GoogleContainerTools/kaniko"
}
url = "github.com/" + repoSlug
log.Printf("repo=%q / commit=%q / branch=%q", repo, commit, branch)
url = "github.com/" + repo
return
}

func getGitRepo(t *testing.T, explicit bool) string {
branch, url := getBranchAndURL()
if explicit {
return url + "#" + getBranchSHA(t, url, branch)
func getGitRepo(explicit bool) string {
branch, commit, url := getBranchCommitAndURL()
if explicit && commit != "" {
return url + "#" + commit
}
return url + "#refs/heads/" + branch
}
Expand Down Expand Up @@ -296,28 +270,28 @@ func testGitBuildcontextHelper(t *testing.T, repo string) {
// Example:
// git://github.com/myuser/repo#refs/heads/master
func TestGitBuildcontext(t *testing.T) {
repo := getGitRepo(t, false)
repo := getGitRepo(false)
testGitBuildcontextHelper(t, repo)
}

// TestGitBuildcontextNoRef builds without any commit / branch reference
// Example:
// git://github.com/myuser/repo
func TestGitBuildcontextNoRef(t *testing.T) {
_, repo := getBranchAndURL()
testGitBuildcontextHelper(t, repo)
_, _, url := getBranchCommitAndURL()
testGitBuildcontextHelper(t, url)
}

// TestGitBuildcontextExplicitCommit uses an explicit commit hash instead of named reference
// Example:
// git://github.com/myuser/repo#b873088c4a7b60bb7e216289c58da945d0d771b6
func TestGitBuildcontextExplicitCommit(t *testing.T) {
repo := getGitRepo(t, true)
repo := getGitRepo(true)
testGitBuildcontextHelper(t, repo)
}

func TestGitBuildcontextSubPath(t *testing.T) {
repo := getGitRepo(t, false)
repo := getGitRepo(false)
dockerfile := "Dockerfile_test_run_2"

// Build with docker
Expand Down Expand Up @@ -361,7 +335,7 @@ func TestGitBuildcontextSubPath(t *testing.T) {
}

func TestBuildViaRegistryMirrors(t *testing.T) {
repo := getGitRepo(t, false)
repo := getGitRepo(false)
dockerfile := fmt.Sprintf("%s/%s/Dockerfile_registry_mirror", integrationPath, dockerfilesPath)

// Build with docker
Expand Down Expand Up @@ -401,7 +375,7 @@ func TestBuildViaRegistryMirrors(t *testing.T) {
}

func TestBuildWithLabels(t *testing.T) {
repo := getGitRepo(t, false)
repo := getGitRepo(false)
dockerfile := fmt.Sprintf("%s/%s/Dockerfile_test_label", integrationPath, dockerfilesPath)

testLabel := "mylabel=myvalue"
Expand Down Expand Up @@ -444,7 +418,7 @@ func TestBuildWithLabels(t *testing.T) {
}

func TestBuildWithHTTPError(t *testing.T) {
repo := getGitRepo(t, false)
repo := getGitRepo(false)
dockerfile := fmt.Sprintf("%s/%s/Dockerfile_test_add_404", integrationPath, dockerfilesPath)

// Build with docker
Expand Down
25 changes: 0 additions & 25 deletions scripts/travis-setup.sh

This file was deleted.