From 5f0ec94497715fa293def1bf2cf81b3e7a65102a Mon Sep 17 00:00:00 2001 From: Tom Kennedy Date: Mon, 2 Oct 2023 11:24:43 -0400 Subject: [PATCH 1/4] Pull in ci and codeowners from main Signed-off-by: Tom Kennedy --- .github/actions/pack-build/action.yml | 10 ++-- .github/actions/run-tests/Dockerfile | 10 ---- .github/actions/run-tests/action.yml | 12 ---- .github/workflows/add-to-project.yml | 21 ------- .github/workflows/ci.yaml | 85 +++++++++++++++------------ .github/workflows/unit-test.yaml | 7 +-- CODEOWNERS | 2 +- 7 files changed, 54 insertions(+), 93 deletions(-) delete mode 100644 .github/actions/run-tests/Dockerfile delete mode 100644 .github/actions/run-tests/action.yml delete mode 100644 .github/workflows/add-to-project.yml diff --git a/.github/actions/pack-build/action.yml b/.github/actions/pack-build/action.yml index 584f21a2f..f998ce1f1 100644 --- a/.github/actions/pack-build/action.yml +++ b/.github/actions/pack-build/action.yml @@ -41,12 +41,12 @@ runs: if: ${{ runner.os == 'linux' }} shell: bash run: | - [[ $GITHUB_REF =~ ^refs\/heads\/release\/(.*)$ ]] && version=${BASH_REMATCH[1]} || version=0.0.0 + [[ $GITHUB_REF =~ ^refs\/tags\/v(.*)$ ]] && version=${BASH_REMATCH[1]} || version=0.0.0 KPACK_VERSION=$version KPACK_COMMIT=$GITHUB_SHA mkdir report - + export PATH="$PATH:$(pwd)" pack build ${{ inputs.tag }} \ --builder ${{ inputs.builder }} \ @@ -55,7 +55,7 @@ runs: --report-output-dir . \ --cache-image ${{ inputs.tag }}-cache \ --publish ${{ inputs.additional_pack_args }} - + mkdir images digest=$(go run .github/actions/pack-build/report.go -path ./report.toml) name=$(basename ${{ inputs.tag }}) @@ -65,7 +65,7 @@ runs: if: ${{ runner.os == 'windows' }} shell: bash run: | - [[ $GITHUB_REF =~ ^refs\/heads\/release\/(.*)$ ]] && version=${BASH_REMATCH[1]} || version=0.0.0 + [[ $GITHUB_REF =~ ^refs\/tags\/v(.*)$ ]] && version=${BASH_REMATCH[1]} || version=0.0.0 KPACK_VERSION=$version KPACK_COMMIT=$GITHUB_SHA @@ -88,4 +88,4 @@ runs: uses: actions/upload-artifact@v3 with: name: images - path: images/ + path: images/ \ No newline at end of file diff --git a/.github/actions/run-tests/Dockerfile b/.github/actions/run-tests/Dockerfile deleted file mode 100644 index 9d6b27942..000000000 --- a/.github/actions/run-tests/Dockerfile +++ /dev/null @@ -1,10 +0,0 @@ -FROM golang:1.18-alpine3.15 - -RUN apk add gcc pkgconfig libc-dev make -RUN apk add --no-cache libgit2-dev~=1.3 - -# Use the GitHub Actions uid:gid combination for proper fs permissions -RUN addgroup -g 116 -S test && adduser -u 1001 -S -g test test -USER test - -ENTRYPOINT ["/bin/sh", "-c"] diff --git a/.github/actions/run-tests/action.yml b/.github/actions/run-tests/action.yml deleted file mode 100644 index 7decc1b45..000000000 --- a/.github/actions/run-tests/action.yml +++ /dev/null @@ -1,12 +0,0 @@ -name: 'Run tests' -description: 'Run kpack tests' -inputs: - command: - description: 'Command to run inside the container' - required: true - default: 'make unit-ci' -runs: - using: 'docker' - image: 'Dockerfile' - args: - - ${{ inputs.command }} \ No newline at end of file diff --git a/.github/workflows/add-to-project.yml b/.github/workflows/add-to-project.yml deleted file mode 100644 index d55cbe6f5..000000000 --- a/.github/workflows/add-to-project.yml +++ /dev/null @@ -1,21 +0,0 @@ -name: Add issues to project - -on: - issues: - types: - - opened - pull_request_target: - types: - - opened - -jobs: - add-to-project: - if: ${{ github.actor != 'dependabot[bot]' }} - name: Add To GitHub Projects Beta - runs-on: ubuntu-latest - steps: - - name: Add To GitHub Projects Beta - uses: actions/add-to-project@v0.5.0 - with: - project-url: https://github.com/orgs/pivotal/projects/18 - github-token: ${{ secrets.KPACK_BOT_PAT }} diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 41fb691b3..6d42a5b7f 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -5,9 +5,8 @@ on: branches: - main - release/** - pull_request: - branches: - - release/** + tags: + - v[0-9]+.[0-9]+.[0-9]+-?** defaults: run: @@ -23,7 +22,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Checkout - uses: actions/checkout@v3 + uses: actions/checkout@v4 with: fetch-depth: 0 @@ -42,9 +41,9 @@ jobs: runs-on: ubuntu-latest steps: - name: Checkout - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: Docker Login - uses: docker/login-action@v2.2.0 + uses: docker/login-action@v3.0.0 with: registry: ${{ secrets.REGISTRY_HOST }} username: ${{ secrets.REGISTRY_USER }} @@ -60,9 +59,9 @@ jobs: runs-on: ubuntu-latest steps: - name: Checkout - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: Docker Login - uses: docker/login-action@v2.2.0 + uses: docker/login-action@v3.0.0 with: registry: ${{ secrets.REGISTRY_HOST }} username: ${{ secrets.REGISTRY_USER }} @@ -78,9 +77,9 @@ jobs: runs-on: ubuntu-latest steps: - name: Checkout - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: Docker Login - uses: docker/login-action@v2.2.0 + uses: docker/login-action@v3.0.0 with: registry: ${{ secrets.REGISTRY_HOST }} username: ${{ secrets.REGISTRY_USER }} @@ -96,9 +95,9 @@ jobs: runs-on: ubuntu-latest steps: - name: Checkout - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: Docker Login - uses: docker/login-action@v2.2.0 + uses: docker/login-action@v3.0.0 with: registry: ${{ secrets.REGISTRY_HOST }} username: ${{ secrets.REGISTRY_USER }} @@ -114,9 +113,9 @@ jobs: runs-on: ubuntu-latest steps: - name: Checkout - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: Docker Login - uses: docker/login-action@v2.2.0 + uses: docker/login-action@v3.0.0 with: registry: ${{ secrets.REGISTRY_HOST }} username: ${{ secrets.REGISTRY_USER }} @@ -132,9 +131,9 @@ jobs: runs-on: ubuntu-latest steps: - name: Checkout - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: Docker Login - uses: docker/login-action@v2.2.0 + uses: docker/login-action@v3.0.0 with: registry: ${{ secrets.REGISTRY_HOST }} username: ${{ secrets.REGISTRY_USER }} @@ -150,9 +149,9 @@ jobs: runs-on: windows-2019 steps: - name: Checkout - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: Docker Login - uses: docker/login-action@v2.2.0 + uses: docker/login-action@v3.0.0 with: registry: ${{ secrets.REGISTRY_HOST }} username: ${{ secrets.REGISTRY_USER }} @@ -170,9 +169,9 @@ jobs: runs-on: windows-2019 steps: - name: Checkout - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: Docker Login - uses: docker/login-action@v2.2.0 + uses: docker/login-action@v3.0.0 with: registry: ${{ secrets.REGISTRY_HOST }} username: ${{ secrets.REGISTRY_USER }} @@ -190,13 +189,21 @@ jobs: runs-on: ubuntu-latest steps: - name: Checkout - uses: actions/checkout@v3 + uses: actions/checkout@v4 + - name: Docker Login + uses: docker/login-action@v3.0.0 + with: + registry: ${{ secrets.REGISTRY_HOST }} + username: ${{ secrets.REGISTRY_USER }} + password: ${{ secrets.REGISTRY_PASSWORD }} - name: Set up Go uses: actions/setup-go@v4 with: go-version-file: 'go.mod' - name: Build run: | + trap 'echo -e "$output"' EXIT + output=$(go run ./hack/lifecycle/main.go --tag=${{ env.PUBLIC_IMAGE_DEV_REPO }}/lifecycle 2>&1) image=$(echo "$output" | grep "saved lifecycle" | awk -F "saved lifecycle image: " '{print $2}') mkdir images @@ -221,7 +228,7 @@ jobs: - completion-windows-image steps: - name: Checkout - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: Set up Go uses: actions/setup-go@v4 @@ -229,7 +236,7 @@ jobs: go-version-file: 'go.mod' - name: Setup carvel - uses: carvel-dev/setup-action@v1 + uses: carvel-dev/setup-action@v2 with: token: ${{ secrets.RELEASE_TOKEN }} only: ytt, kapp @@ -240,7 +247,7 @@ jobs: name: images - name: Build release yaml - run: | + run: | ytt -f config/ \ -v controller_image=$(cat controller) \ -v webhook_image=$(cat webhook) \ @@ -275,7 +282,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Checkout - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: Set up Go uses: actions/setup-go@v4 @@ -286,7 +293,7 @@ jobs: uses: imjasonh/setup-crane@v0.3 - name: Setup carvel - uses: carvel-dev/setup-action@v1 + uses: carvel-dev/setup-action@v2 with: token: ${{ secrets.RELEASE_TOKEN }} only: ytt, kapp @@ -343,13 +350,13 @@ jobs: EOF - name: Create Kind Cluster - uses: helm/kind-action@v1.7.0 + uses: helm/kind-action@v1.8.0 with: cluster_name: e2e config: kind.yaml - name: Docker Login - uses: docker/login-action@v2.2.0 + uses: docker/login-action@v3.0.0 with: registry: ${{ env.REGISTRY_URL }} username: ${{ env.REGISTRY_USER }} @@ -428,11 +435,11 @@ jobs: - build-init-windows-image - completion-windows-image - lifecycle-image - if: ${{ startsWith(github.ref, 'refs/heads/release/') }} + if: ${{ startsWith(github.ref, 'refs/tags/v') }} runs-on: ubuntu-latest steps: - name: Checkout - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: Set up Go uses: actions/setup-go@v4 @@ -443,7 +450,7 @@ jobs: uses: imjasonh/setup-crane@v0.3 - name: Setup carvel - uses: carvel-dev/setup-action@v1 + uses: carvel-dev/setup-action@v2 with: token: ${{ secrets.RELEASE_TOKEN }} only: ytt @@ -452,16 +459,16 @@ jobs: uses: actions/download-artifact@v3 - name: Docker Login - uses: docker/login-action@v2.2.0 + uses: docker/login-action@v3.0.0 with: registry: ${{ secrets.REGISTRY_HOST }} username: ${{ secrets.REGISTRY_USER }} password: ${{ secrets.REGISTRY_PASSWORD }} - - name: Parse branch name + - name: Parse tag name run: | echo "GITHUB_REF=${GITHUB_REF}" - [[ $GITHUB_REF =~ ^refs\/heads\/release\/(.*)$ ]] && version=${BASH_REMATCH[1]} + [[ $GITHUB_REF =~ ^refs\/tags\/v(.*)$ ]] && version=${BASH_REMATCH[1]} if [[ -z "${version}" ]]; then echo "ERROR: kpack version not detected." exit 1 @@ -474,12 +481,12 @@ jobs: for image in images/*; do dev_image=$(cat $image) digest=$(echo $dev_image| cut -d "@" -f 2) - + name=$(basename $image) - final_repo="${{ env.PUBLIC_IMAGE_REPO }}/${name}" - + final_repo="${{ env.PUBLIC_IMAGE_REPO }}/${name}" + crane copy "$dev_image" "$final_repo" - + echo "${final_repo}@${digest}" > final-image-refs/$name done @@ -503,7 +510,7 @@ jobs: -v completion_image=$(cat final-image-refs/completion) \ -v completion_windows_image=$(cat final-image-refs/completion-windows) \ -v lifecycle_image=$(cat final-image-refs/lifecycle) \ - -v version=${{ env.KPACK_VERSION }} > $file + -v kpack_version=${{ env.KPACK_VERSION }} > $file echo "sha=$(shasum -a 256 $file)" >> $GITHUB_OUTPUT - name: Upload Release diff --git a/.github/workflows/unit-test.yaml b/.github/workflows/unit-test.yaml index 1690b99ff..a62cfbb08 100644 --- a/.github/workflows/unit-test.yaml +++ b/.github/workflows/unit-test.yaml @@ -2,18 +2,15 @@ name: Test on: pull_request: - branches: - - main jobs: - test: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 with: fetch-depth: 0 - name: Run tests - uses: ./.github/actions/run-tests + run: make unit-ci - name: Report coverage uses: codecov/codecov-action@v3.1.4 \ No newline at end of file diff --git a/CODEOWNERS b/CODEOWNERS index e415a36cc..4aa94494c 100644 --- a/CODEOWNERS +++ b/CODEOWNERS @@ -1 +1 @@ -* @matthewmcnew @tomkennedy513 @chenbh @pviraj59 +* @buildpacks-community/kpack-maintainers From 4c6a9c118de0514f2dfe2902ed46e0bcab3d86a8 Mon Sep 17 00:00:00 2001 From: Tom Kennedy Date: Mon, 2 Oct 2023 11:11:44 -0400 Subject: [PATCH 2/4] Fix cloning with Azure DevOps Git - remove multi_ack and multi_ack_detailed from unsupported capabilities - see https://github.com/go-git/go-git/blob/52c2972976737a00fce91d7deb1278a6a460cae6/_examples/azure_devops/main.go\#L21-L36 for more info - we should be able to remove this once go-git implements full support for v2 git with multi_ack Signed-off-by: Tom Kennedy --- pkg/git/fetch.go | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/pkg/git/fetch.go b/pkg/git/fetch.go index 999ca6568..8725045d3 100644 --- a/pkg/git/fetch.go +++ b/pkg/git/fetch.go @@ -9,6 +9,7 @@ import ( gogit "github.com/go-git/go-git/v5" "github.com/go-git/go-git/v5/config" "github.com/go-git/go-git/v5/plumbing" + "github.com/go-git/go-git/v5/plumbing/protocol/packp/capability" "github.com/go-git/go-git/v5/plumbing/transport" "github.com/pkg/errors" ) @@ -18,6 +19,13 @@ type Fetcher struct { Keychain GitKeychain } +func init() { + //remove multi_ack and multi_ack_detailed from unsupported capabilities to enable Azure DevOps git support + transport.UnsupportedCapabilities = []capability.Capability{ + capability.ThinPack, + } +} + func (f Fetcher) Fetch(dir, gitURL, gitRevision, metadataDir string) error { f.Logger.Printf("Cloning %q @ %q...", gitURL, gitRevision) auth, err := f.Keychain.Resolve(gitURL) From 360b2544250434c75122c2c5f4b81720abb0d669 Mon Sep 17 00:00:00 2001 From: Tom Kennedy Date: Wed, 4 Oct 2023 15:16:40 -0400 Subject: [PATCH 3/4] Change name of executable in test - Also pinning to a commit so this doesn't happen in the future Signed-off-by: Tom Kennedy --- pkg/git/fetch_test.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pkg/git/fetch_test.go b/pkg/git/fetch_test.go index 6695372b5..7d32ddd07 100644 --- a/pkg/git/fetch_test.go +++ b/pkg/git/fetch_test.go @@ -90,10 +90,10 @@ func testGitCheckout(t *testing.T, when spec.G, it spec.S) { }) it("preserves executable permission", func() { - err := fetcher.Fetch(testDir, "https://github.com/pivotal/kpack", "main", metadataDir) + err := fetcher.Fetch(testDir, "https://github.com/pivotal/kpack", "b8c0d491135595cc00ab78f6214bef8a7a20afd8", metadataDir) require.NoError(t, err) - fileInfo, err := os.Lstat(path.Join(testDir, "hack", "apply.sh")) + fileInfo, err := os.Lstat(path.Join(testDir, "hack", "local.sh")) require.NoError(t, err) require.True(t, isExecutableByAll(fileInfo.Mode())) From 295f11187e6440e2207fbef73f29110a48bcc7c5 Mon Sep 17 00:00:00 2001 From: Tom Kennedy <10608054+tomkennedy513@users.noreply.github.com> Date: Mon, 9 Oct 2023 11:54:06 -0400 Subject: [PATCH 4/4] Run ci on PRs to release branches Signed-off-by: Tom Kennedy <10608054+tomkennedy513@users.noreply.github.com> --- .github/workflows/ci.yaml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 6d42a5b7f..de09513fa 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -7,6 +7,9 @@ on: - release/** tags: - v[0-9]+.[0-9]+.[0-9]+-?** + pull_request: + branches: + - release/** defaults: run: