From 935d72fb00f6f3867373d03d2f7087b32ad2692c Mon Sep 17 00:00:00 2001 From: Chmouel Boudjnah Date: Wed, 24 Apr 2024 17:43:51 +0200 Subject: [PATCH] Publish images to arm64 as well and auto format yaml --- .github/workflows/latest.yaml | 143 ++++++++++++++++++---------------- 1 file changed, 74 insertions(+), 69 deletions(-) diff --git a/.github/workflows/latest.yaml b/.github/workflows/latest.yaml index 7e6918bf3..5f41cf60c 100644 --- a/.github/workflows/latest.yaml +++ b/.github/workflows/latest.yaml @@ -1,10 +1,10 @@ on: pull_request: - branches: [ main ] + branches: [main] push: - branches: [ main ] + branches: [main] schedule: - - cron: '0 0 * * *' + - cron: "0 0 * * *" name: build-test-publish @@ -12,62 +12,67 @@ jobs: build: runs-on: ubuntu-latest steps: - - uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 - - name: Set up Go - uses: actions/setup-go@0c52d547c9bc32b1aa3301fd7a9cb496313a4491 # v5.0.0 - with: - go-version: "1.21" - - run: go env - - name: go build - run: go build -v ./... - - name: go unit test - run: go test -v ./... + - uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 + - name: Set up Go + uses: actions/setup-go@0c52d547c9bc32b1aa3301fd7a9cb496313a4491 # v5.0.0 + with: + go-version: "1.21" + - run: go env + - name: go build + run: go build -v ./... + - name: go unit test + run: go test -v ./... e2e: name: e2e tests runs-on: ubuntu-latest - needs: [ build ] - + needs: [build] + steps: - - uses: ko-build/setup-ko@v0.6 - - uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 - - uses: azure/setup-helm@v4 - # instantiate a KinD (Kubernetes in Docker) cluster, installs `kubectl` and configures the - # `kubeconfig` to reach the local cluster - - uses: helm/kind-action@v1.9.0 - with: - cluster_name: kind - wait: 120s - - uses: actions/setup-go@0c52d547c9bc32b1aa3301fd7a9cb496313a4491 # v5.0.0 - with: - go-version: "1.21.x" - - uses: openshift-pipelines/setup-tektoncd@v1 - with: - pipeline_version: v0.56.1 - feature_flags: '{"enable-step-actions": "true"}' - - name: tests - run: | - kubectl -n registry get deployment - kubectl -n registry port-forward deployment/registry 5000:5000 & - REGISTRY=registry.registry.svc.cluster.local:32222 - KO_DOCKER_REPO=ghcr.io/openshift-pipelines/tekton-caches - IMAGE_REF="${KO_DOCKER_REPO}/cache:$(git rev-parse HEAD | tr -d '\n')" - - ko publish --base-import-paths --tags=$(git rev-parse HEAD) ./cmd/cache - sed "s%image:.*%image: ${IMAGE_REF}%g" tekton/cache-fetch.yaml | tee | kubectl apply -f - - sed "s%image:.*%image: ${IMAGE_REF}%g" tekton/cache-upload.yaml | tee | kubectl apply -f - - kubectl apply -f tests/ - tkn task start cache-fetch-go -p gitURL=https://github.com/vdemeester/go-helloworld-app -p gitRevision=main -p cachePatterns="**.go,**go.sum" -p cacheURIBase=oci://${REGISTRY}/cache/go -w name=source,emptyDir= -w name=gocache,emptyDir= -w name=gomodcache,emptyDir= --showlog - tkn task start cache-upload-go -p gitURL=https://github.com/vdemeester/go-helloworld-app -p gitRevision=main -p cachePatterns="**.go,**go.sum" -p cacheURIBase=oci://${REGISTRY}/cache/go -w name=source,emptyDir= -w name=gocache,emptyDir= -w name=gomodcache,emptyDir= --showlog - tkn task start cache-fetch-go -p gitURL=https://github.com/vdemeester/go-helloworld-app -p gitRevision=main -p cachePatterns="**.go,**go.sum" -p cacheURIBase=oci://${REGISTRY}/cache/go -w name=source,emptyDir= -w name=gocache,emptyDir= -w name=gomodcache,emptyDir= --showlog - tkn taskrun list - kubectl get taskrun -o yaml - # FIXME: fail if something failed - + - uses: ko-build/setup-ko@v0.6 + - uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 + - uses: azure/setup-helm@v4 + # instantiate a KinD (Kubernetes in Docker) cluster, installs `kubectl` and configures the + # `kubeconfig` to reach the local cluster + - uses: helm/kind-action@v1.9.0 + with: + cluster_name: kind + wait: 120s + - uses: actions/setup-go@0c52d547c9bc32b1aa3301fd7a9cb496313a4491 # v5.0.0 + with: + go-version: "1.21.x" + - uses: openshift-pipelines/setup-tektoncd@v1 + with: + pipeline_version: v0.56.1 + feature_flags: '{"enable-step-actions": "true"}' + - name: tests + run: | + kubectl -n registry get deployment + kubectl -n registry port-forward deployment/registry 5000:5000 & + REGISTRY=registry.registry.svc.cluster.local:32222 + KO_DOCKER_REPO=ghcr.io/openshift-pipelines/tekton-caches + IMAGE_REF="${KO_DOCKER_REPO}/cache:$(git rev-parse HEAD | tr -d '\n')" + + ko publish --base-import-paths --tags=$(git rev-parse HEAD) ./cmd/cache + sed "s%image:.*%image: ${IMAGE_REF}%g" tekton/cache-fetch.yaml | tee | kubectl apply -f - + sed "s%image:.*%image: ${IMAGE_REF}%g" tekton/cache-upload.yaml | tee | kubectl apply -f - + kubectl apply -f tests/ + tkn task start cache-fetch-go -p gitURL=https://github.com/vdemeester/go-helloworld-app \ + -p gitRevision=main \ + -p cachePatterns="**.go,**go.sum" \ + -p cacheURIBase=oci://${REGISTRY}/cache/go \ + -w name=source,emptyDir= -w name=gocache,emptyDir= \ + -w name=gomodcache,emptyDir= --showlog + tkn task start cache-upload-go -p gitURL=https://github.com/vdemeester/go-helloworld-app -p gitRevision=main -p cachePatterns="**.go,**go.sum" -p cacheURIBase=oci://${REGISTRY}/cache/go -w name=source,emptyDir= -w name=gocache,emptyDir= -w name=gomodcache,emptyDir= --showlog + tkn task start cache-fetch-go -p gitURL=https://github.com/vdemeester/go-helloworld-app -p gitRevision=main -p cachePatterns="**.go,**go.sum" -p cacheURIBase=oci://${REGISTRY}/cache/go -w name=source,emptyDir= -w name=gocache,emptyDir= -w name=gomodcache,emptyDir= --showlog + tkn taskrun list + kubectl get taskrun -o yaml + # FIXME: fail if something failed + publish: name: publish latest runs-on: ubuntu-latest - needs: [ build ] + needs: [build] # https://docs.github.com/en/actions/reference/authentication-in-a-workflow permissions: @@ -76,21 +81,21 @@ jobs: contents: read steps: - - uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 - - uses: actions/setup-go@0c52d547c9bc32b1aa3301fd7a9cb496313a4491 # v5.0.0 - with: - go-version: "1.21" - - id: meta - uses: docker/metadata-action@8e5442c4ef9f78752691e2d8f8d19755c6f78e81 # 5.5.1 - with: - images: ghcr.io/${{ github.repository }}/cache - flavor: | - latest=${{ github.event_name != 'pull_request' }} - - uses: docker/login-action@e92390c5fb421da1463c202d546fed0ec5c39f20 # 3.1.0 - with: - registry: ghcr.io - username: ${{ github.actor }} - password: ${{ secrets.GITHUB_TOKEN }} - - uses: ko-build/setup-ko@v0.6 - - run: | - ko publish --push=${{ github.event_name != 'pull_request' }} --base-import-paths ./cmd/cache + - uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 + - uses: actions/setup-go@0c52d547c9bc32b1aa3301fd7a9cb496313a4491 # v5.0.0 + with: + go-version: "1.21" + - id: meta + uses: docker/metadata-action@8e5442c4ef9f78752691e2d8f8d19755c6f78e81 # 5.5.1 + with: + images: ghcr.io/${{ github.repository }}/cache + flavor: | + latest=${{ github.event_name != 'pull_request' }} + - uses: docker/login-action@e92390c5fb421da1463c202d546fed0ec5c39f20 # 3.1.0 + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + - uses: ko-build/setup-ko@v0.6 + - run: | + ko publish --push=${{ github.event_name != 'pull_request' }} --base-import-paths ./cmd/cache --platform linux/arm64,linux/amd64