Collapse integration test workflows into one config (#1855)
* Collapse integration test workflows into one config Remove last traces of Travis, including env vars and `make travis-setup` and badges in README * fix lint * make integration tests pass on PRs
This commit is contained in:
parent
b1b6962726
commit
59c2d2d08f
|
|
@ -1,29 +0,0 @@
|
||||||
name: Integration tests (K8s)
|
|
||||||
|
|
||||||
on:
|
|
||||||
pull_request:
|
|
||||||
branches: ['master']
|
|
||||||
|
|
||||||
concurrency:
|
|
||||||
group: int-test-k8s-${{ github.head_ref }}
|
|
||||||
cancel-in-progress: true
|
|
||||||
|
|
||||||
jobs:
|
|
||||||
tests:
|
|
||||||
env:
|
|
||||||
IMAGE_REPO: 'localhost:5000'
|
|
||||||
REGISTRY: 'localhost:5000'
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
steps:
|
|
||||||
- uses: actions/setup-go@v2
|
|
||||||
with:
|
|
||||||
go-version: 1.17
|
|
||||||
- uses: actions/checkout@v2
|
|
||||||
- uses: docker/setup-buildx-action@v1
|
|
||||||
|
|
||||||
- name: Run build-image-and-k8s-integration-test
|
|
||||||
run: |
|
|
||||||
make travis-setup
|
|
||||||
make minikube-setup
|
|
||||||
make k8s-executor-build-push
|
|
||||||
make integration-test-k8s
|
|
||||||
|
|
@ -1,28 +0,0 @@
|
||||||
name: Integration tests (Layers)
|
|
||||||
|
|
||||||
on:
|
|
||||||
pull_request:
|
|
||||||
branches: ['master']
|
|
||||||
|
|
||||||
concurrency:
|
|
||||||
group: int-test-layers-${{ github.head_ref }}
|
|
||||||
cancel-in-progress: true
|
|
||||||
|
|
||||||
jobs:
|
|
||||||
tests:
|
|
||||||
env:
|
|
||||||
IMAGE_REPO: 'localhost:5000'
|
|
||||||
REGISTRY: 'localhost:5000'
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
steps:
|
|
||||||
- uses: actions/setup-go@v2
|
|
||||||
with:
|
|
||||||
go-version: 1.17
|
|
||||||
- uses: actions/checkout@v2
|
|
||||||
- uses: docker/setup-buildx-action@v1
|
|
||||||
|
|
||||||
- name: Run integration-test-layers
|
|
||||||
run: |
|
|
||||||
make travis-setup
|
|
||||||
make minikube-setup
|
|
||||||
make integration-test-layers
|
|
||||||
|
|
@ -1,37 +0,0 @@
|
||||||
name: Integration Tests Misc
|
|
||||||
|
|
||||||
on:
|
|
||||||
pull_request:
|
|
||||||
branches: ['master']
|
|
||||||
|
|
||||||
concurrency:
|
|
||||||
group: int-test-mis-${{ github.head_ref }}
|
|
||||||
cancel-in-progress: true
|
|
||||||
|
|
||||||
jobs:
|
|
||||||
tests:
|
|
||||||
env:
|
|
||||||
IMAGE_REPO: 'localhost:5000'
|
|
||||||
REGISTRY: 'localhost:5000'
|
|
||||||
TRAVIS_REPO_SLUG: ${{ github.repository }}
|
|
||||||
TRAVIS_BRANCH: ${{ github.head_ref }}
|
|
||||||
TRAVIS_PULL_REQUEST: ${{ github.event.number }}
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
steps:
|
|
||||||
- uses: actions/setup-go@v2
|
|
||||||
with:
|
|
||||||
go-version: 1.17
|
|
||||||
- uses: actions/checkout@v2
|
|
||||||
- uses: docker/setup-buildx-action@v1
|
|
||||||
|
|
||||||
- name: Print Travis ENV vars
|
|
||||||
run: |
|
|
||||||
echo "TRAVIS_BRANCH: ${TRAVIS_BRANCH}"
|
|
||||||
echo "TRAVIS_PULL_REQUEST: ${TRAVIS_PULL_REQUEST}"
|
|
||||||
echo "TRAVIS_REPO_SLUG: ${TRAVIS_REPO_SLUG}"
|
|
||||||
|
|
||||||
- name: Run integration-test-misc
|
|
||||||
run : |
|
|
||||||
make travis-setup
|
|
||||||
make minikube-setup
|
|
||||||
make integration-test-misc
|
|
||||||
|
|
@ -1,28 +0,0 @@
|
||||||
name: Integration tests (Run)
|
|
||||||
|
|
||||||
on:
|
|
||||||
pull_request:
|
|
||||||
branches: ['master']
|
|
||||||
|
|
||||||
concurrency:
|
|
||||||
group: int-test-run-${{ github.head_ref }}
|
|
||||||
cancel-in-progress: true
|
|
||||||
|
|
||||||
jobs:
|
|
||||||
tests:
|
|
||||||
env:
|
|
||||||
IMAGE_REPO: 'localhost:5000'
|
|
||||||
REGISTRY: 'localhost:5000'
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
steps:
|
|
||||||
- uses: actions/setup-go@v2
|
|
||||||
with:
|
|
||||||
go-version: 1.17
|
|
||||||
- uses: actions/checkout@v2
|
|
||||||
- uses: docker/setup-buildx-action@v1
|
|
||||||
|
|
||||||
- name: Run integration-test-run
|
|
||||||
run: |
|
|
||||||
make travis-setup
|
|
||||||
make minikube-setup
|
|
||||||
make integration-test-run
|
|
||||||
|
|
@ -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 }}
|
||||||
|
|
@ -1,6 +1,8 @@
|
||||||
name: Unit tests
|
name: Unit tests
|
||||||
|
|
||||||
on:
|
on:
|
||||||
|
push:
|
||||||
|
branches: ['master']
|
||||||
pull_request:
|
pull_request:
|
||||||
branches: ['master']
|
branches: ['master']
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -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
|
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
|
### Benchmarking
|
||||||
|
|
||||||
|
|
|
||||||
7
Makefile
7
Makefile
|
|
@ -53,9 +53,10 @@ out/executor: $(GO_FILES)
|
||||||
out/warmer: $(GO_FILES)
|
out/warmer: $(GO_FILES)
|
||||||
GOARCH=$(GOARCH) GOOS=linux CGO_ENABLED=0 go build -ldflags $(GO_LDFLAGS) -o $@ $(WARMER_PACKAGE)
|
GOARCH=$(GOARCH) GOOS=linux CGO_ENABLED=0 go build -ldflags $(GO_LDFLAGS) -o $@ $(WARMER_PACKAGE)
|
||||||
|
|
||||||
.PHONY: travis-setup
|
.PHONY: install-container-diff
|
||||||
travis-setup:
|
install-container-diff:
|
||||||
@ ./scripts/travis-setup.sh
|
@ 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
|
.PHONY: minikube-setup
|
||||||
minikube-setup:
|
minikube-setup:
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,11 @@
|
||||||
# kaniko - Build Images In Kubernetes
|
# kaniko - Build Images In Kubernetes
|
||||||
|
|
||||||
`NOTE: kaniko is not an officially supported Google product`
|
## 🚨NOTE: kaniko is not an officially supported Google product🚨
|
||||||
|
|
||||||
[](https://travis-ci.com/GoogleContainerTools/kaniko) [](https://goreportcard.com/report/github.com/GoogleContainerTools/kaniko)
|
[](https://github.com/GoogleContainerTools/kaniko/actions/workflows/unit-tests.yaml)
|
||||||
|
[](https://github.com/GoogleContainerTools/kaniko/actions/workflows/integration-tests.yaml)
|
||||||
|
[](https://github.com/GoogleContainerTools/kaniko/actions/workflows/images.yaml)
|
||||||
|
[](https://goreportcard.com/report/github.com/GoogleContainerTools/kaniko)
|
||||||
|
|
||||||

|

|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -30,10 +30,6 @@ import (
|
||||||
"testing"
|
"testing"
|
||||||
"time"
|
"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/name"
|
||||||
"github.com/google/go-containerregistry/pkg/v1/daemon"
|
"github.com/google/go-containerregistry/pkg/v1/daemon"
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
|
|
@ -203,53 +199,31 @@ func TestRun(t *testing.T) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func findSHA(ref plumbing.ReferenceName, refs []*plumbing.Reference) (string, error) {
|
func getBranchCommitAndURL() (branch, commit, url string) {
|
||||||
for _, ref2 := range refs {
|
repo := os.Getenv("GITHUB_REPOSITORY")
|
||||||
if ref.String() == ref2.Name().String() {
|
commit = os.Getenv("GITHUB_SHA")
|
||||||
return ref2.Hash().String(), nil
|
if _, isPR := os.LookupEnv("GITHUB_HEAD_REF"); isPR {
|
||||||
}
|
|
||||||
}
|
|
||||||
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 {
|
|
||||||
branch = "master"
|
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 {
|
} else {
|
||||||
branch = "master"
|
branch = os.Getenv("GITHUB_REF")
|
||||||
repoSlug = "GoogleContainerTools/kaniko"
|
log.Printf("GITHUB_HEAD_REF is unset (not a PR); using GITHUB_REF=%q", branch)
|
||||||
|
branch = strings.TrimPrefix(branch, "refs/heads/")
|
||||||
}
|
}
|
||||||
url = "github.com/" + repoSlug
|
if repo == "" {
|
||||||
|
repo = "GoogleContainerTools/kaniko"
|
||||||
|
}
|
||||||
|
if branch == "" {
|
||||||
|
branch = "master"
|
||||||
|
}
|
||||||
|
log.Printf("repo=%q / commit=%q / branch=%q", repo, commit, branch)
|
||||||
|
url = "github.com/" + repo
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
func getGitRepo(t *testing.T, explicit bool) string {
|
func getGitRepo(explicit bool) string {
|
||||||
branch, url := getBranchAndURL()
|
branch, commit, url := getBranchCommitAndURL()
|
||||||
if explicit {
|
if explicit && commit != "" {
|
||||||
return url + "#" + getBranchSHA(t, url, branch)
|
return url + "#" + commit
|
||||||
}
|
}
|
||||||
return url + "#refs/heads/" + branch
|
return url + "#refs/heads/" + branch
|
||||||
}
|
}
|
||||||
|
|
@ -296,7 +270,7 @@ func testGitBuildcontextHelper(t *testing.T, repo string) {
|
||||||
// Example:
|
// Example:
|
||||||
// git://github.com/myuser/repo#refs/heads/master
|
// git://github.com/myuser/repo#refs/heads/master
|
||||||
func TestGitBuildcontext(t *testing.T) {
|
func TestGitBuildcontext(t *testing.T) {
|
||||||
repo := getGitRepo(t, false)
|
repo := getGitRepo(false)
|
||||||
testGitBuildcontextHelper(t, repo)
|
testGitBuildcontextHelper(t, repo)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -304,20 +278,20 @@ func TestGitBuildcontext(t *testing.T) {
|
||||||
// Example:
|
// Example:
|
||||||
// git://github.com/myuser/repo
|
// git://github.com/myuser/repo
|
||||||
func TestGitBuildcontextNoRef(t *testing.T) {
|
func TestGitBuildcontextNoRef(t *testing.T) {
|
||||||
_, repo := getBranchAndURL()
|
_, _, url := getBranchCommitAndURL()
|
||||||
testGitBuildcontextHelper(t, repo)
|
testGitBuildcontextHelper(t, url)
|
||||||
}
|
}
|
||||||
|
|
||||||
// TestGitBuildcontextExplicitCommit uses an explicit commit hash instead of named reference
|
// TestGitBuildcontextExplicitCommit uses an explicit commit hash instead of named reference
|
||||||
// Example:
|
// Example:
|
||||||
// git://github.com/myuser/repo#b873088c4a7b60bb7e216289c58da945d0d771b6
|
// git://github.com/myuser/repo#b873088c4a7b60bb7e216289c58da945d0d771b6
|
||||||
func TestGitBuildcontextExplicitCommit(t *testing.T) {
|
func TestGitBuildcontextExplicitCommit(t *testing.T) {
|
||||||
repo := getGitRepo(t, true)
|
repo := getGitRepo(true)
|
||||||
testGitBuildcontextHelper(t, repo)
|
testGitBuildcontextHelper(t, repo)
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestGitBuildcontextSubPath(t *testing.T) {
|
func TestGitBuildcontextSubPath(t *testing.T) {
|
||||||
repo := getGitRepo(t, false)
|
repo := getGitRepo(false)
|
||||||
dockerfile := "Dockerfile_test_run_2"
|
dockerfile := "Dockerfile_test_run_2"
|
||||||
|
|
||||||
// Build with docker
|
// Build with docker
|
||||||
|
|
@ -361,7 +335,7 @@ func TestGitBuildcontextSubPath(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestBuildViaRegistryMirrors(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)
|
dockerfile := fmt.Sprintf("%s/%s/Dockerfile_registry_mirror", integrationPath, dockerfilesPath)
|
||||||
|
|
||||||
// Build with docker
|
// Build with docker
|
||||||
|
|
@ -401,7 +375,7 @@ func TestBuildViaRegistryMirrors(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestBuildWithLabels(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)
|
dockerfile := fmt.Sprintf("%s/%s/Dockerfile_test_label", integrationPath, dockerfilesPath)
|
||||||
|
|
||||||
testLabel := "mylabel=myvalue"
|
testLabel := "mylabel=myvalue"
|
||||||
|
|
@ -444,7 +418,7 @@ func TestBuildWithLabels(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestBuildWithHTTPError(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)
|
dockerfile := fmt.Sprintf("%s/%s/Dockerfile_test_add_404", integrationPath, dockerfilesPath)
|
||||||
|
|
||||||
// Build with docker
|
// Build with docker
|
||||||
|
|
|
||||||
|
|
@ -1,25 +0,0 @@
|
||||||
#!/bin/bash
|
|
||||||
# Copyright 2020 Google LLC
|
|
||||||
#
|
|
||||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
# you may not use this file except in compliance with the License.
|
|
||||||
# You may obtain a copy of the License at
|
|
||||||
#
|
|
||||||
# http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
#
|
|
||||||
# Unless required by applicable law or agreed to in writing, software
|
|
||||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
# See the License for the specific language governing permissions and
|
|
||||||
# limitations under the License.
|
|
||||||
|
|
||||||
set -ex
|
|
||||||
|
|
||||||
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
|
|
||||||
sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"
|
|
||||||
sudo apt-get update
|
|
||||||
sudo apt-get -y -o Dpkg::Options::="--force-confnew" install docker-ce
|
|
||||||
curl -LO https://storage.googleapis.com/container-diff/latest/container-diff-linux-amd64 && chmod +x container-diff-linux-amd64 && sudo mv container-diff-linux-amd64 /usr/local/bin/container-diff
|
|
||||||
|
|
||||||
mkdir -p $HOME/.docker/
|
|
||||||
echo '{}' > $HOME/.docker/config.json
|
|
||||||
Loading…
Reference in New Issue