Skip to content

Commit 2992f10

Browse files
committed
Migrate tasks from v1beta1 to v1
Signed-off-by: Vincent Demeester <[email protected]>
1 parent a9331fa commit 2992f10

File tree

6 files changed

+124
-94
lines changed

6 files changed

+124
-94
lines changed

.github/workflows/images.yaml

Lines changed: 0 additions & 70 deletions
This file was deleted.

.github/workflows/test-tasks.yaml

Lines changed: 98 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
name: ci
2+
13
on:
24
pull_request:
35
branches: [ main ]
@@ -6,26 +8,100 @@ on:
68
schedule:
79
- cron: '0 0 * * *'
810

9-
name: test-tasks
11+
concurrency:
12+
group: ${{ github.workflow }}-${{ github.ref }}
13+
cancel-in-progress: true
1014

1115
jobs:
16+
17+
list-images:
18+
runs-on: ubuntu-latest
19+
outputs:
20+
images: ${{ steps.output-images.outputs.images }}
21+
steps:
22+
- uses: actions/checkout@v4
23+
- name: list images
24+
id: output-images
25+
run: |
26+
echo "images=$(ls images | jq -R -s -c 'split("\n")[:-1]')" >> $GITHUB_OUTPUT
27+
28+
build-images:
29+
runs-on: ubuntu-latest
30+
permissions:
31+
contents: read
32+
packages: write
33+
needs: list-images
34+
strategy:
35+
matrix:
36+
image: ${{fromJSON(needs.list-images.outputs.images)}}
37+
steps:
38+
- uses: actions/checkout@v4
39+
with:
40+
fetch-depth: 2
41+
- name: Get changed files
42+
id: changed-files
43+
uses: tj-actions/changed-files@v41
44+
with:
45+
files: |
46+
images/${{ matrix.image }}/**
47+
- name: changed files
48+
if: steps.changed-files.outputs.any_changed == 'true'
49+
run: |
50+
echo ${{ steps.changed-files.outputs.any_changed }}
51+
echo "List all the files that have changed: ${{ steps.changed-files-specific.outputs.all_changed_files }}"
52+
- name: Log in to the Container registry
53+
if: steps.changed-files.outputs.any_changed == 'true' || github.event_name != 'pull_request'
54+
uses: docker/login-action@343f7c4344506bcbf9b4de18042ae17996df046d
55+
with:
56+
registry: ghcr.io
57+
username: ${{ github.actor }}
58+
password: ${{ secrets.GITHUB_TOKEN }}
59+
- name: Extract metadata (tags, labels) for Docker
60+
if: steps.changed-files.outputs.any_changed == 'true' || github.event_name != 'pull_request'
61+
id: meta
62+
uses: docker/metadata-action@dbef88086f6cef02e264edb7dbf63250c17cef6c
63+
with:
64+
images: ghcr.io/${{ github.repository }}/${{ matrix.image }}
65+
- name: Build and push Docker image
66+
if: steps.changed-files.outputs.any_changed == 'true' || github.event_name != 'pull_request'
67+
uses: docker/build-push-action@4a13e500e55cf31b7a5d59a38ab2040ab0f42f56
68+
with:
69+
context: images/${{ matrix.image }}
70+
push: ${{ github.event_name != 'pull_request' }}
71+
tags: ${{ steps.meta.outputs.tags }}
72+
labels: ${{ steps.meta.outputs.labels }}
73+
1274
test:
75+
strategy:
76+
fail-fast: false # Keep running if one leg fails.
77+
matrix:
78+
pipeline-version:
79+
- v0.50.5
80+
- v0.53.3
81+
- latest
1382
runs-on: ubuntu-latest
83+
needs: build-images
1484
permissions:
1585
contents: read
1686
packages: write
1787
steps:
1888
- uses: actions/checkout@v4
19-
- uses: chainguard-dev/actions/setup-kind@main
89+
# instantiate a KinD (Kubernetes in Docker) cluster, installs `kubectl` and configures the
90+
# `kubeconfig` to reach the local cluster
91+
- uses: helm/[email protected]
2092
with:
21-
k8s-version: v1.23.x
22-
- uses: vdemeester/setup-tektoncd@main
93+
cluster_name: kind
94+
wait: 120s
95+
# installs Tekton Pipelines and `tkn` command line, including a local Container-Registry with
96+
# settings to reach it during testing
97+
- uses: openshift-pipelines/setup-tektoncd@v1
2398
with:
24-
pipeline: v0.41.x
25-
pipeline-feature-flags: '{"enable-api-fields": "alpha"}'
99+
pipeline_version: ${{ matrix.pipeline-version }}
100+
26101
- name: run-tests
27-
run: |
28-
kubectl apply -f https://raw.githubusercontent.com/tektoncd/catalog/main/task/git-clone/0.7/git-clone.yaml
102+
run: |
103+
set -Eeuo pipefail
104+
exitCode=0
29105
# go-crane-image
30106
kubectl create -f ./go-crane-image/go-crane-image.yaml
31107
kubectl create -f ./go-crane-image/tests/run.yaml
@@ -34,11 +110,12 @@ jobs:
34110
tkn pipelinerun describe go-crane-image-test-run
35111
36112
kubectl get pipelinerun go-crane-image-test-run
37-
#status=$(kubectl get pipelinerun go-crane-image-test-run -o json | jq -r '.items[] | .status.conditions[] | select(.type == "Succeeded") | .status')
38-
#if [[ "${status}" != "True" ]]; then
39-
# echo "go-crane-image test failed"
40-
# kubectl get pipelinerun/go-crane-image-test-run -o yaml
41-
#fi
113+
status=$(kubectl get pipelinerun go-crane-image-test-run -o json | jq -r '.status.conditions[] | select(.type == "Succeeded") | .status')
114+
if [[ "${status}" != "True" ]]; then
115+
echo "go-crane-image test failed"
116+
kubectl get pipelinerun/go-crane-image-test-run -o yaml
117+
exitCode=1
118+
fi
42119
43120
# go-ko-image
44121
kubectl create -f ./go-ko-image/go-ko-image.yaml
@@ -48,3 +125,11 @@ jobs:
48125
tkn pipelinerun describe go-ko-image-test-run
49126
50127
kubectl get pipelinerun go-ko-image-test-run
128+
status=$(kubectl get pipelinerun go-ko-image-test-run -o json | jq -r '.status.conditions[] | select(.type == "Succeeded") | .status')
129+
if [[ "${status}" != "True" ]]; then
130+
echo "go-ko-image test failed"
131+
kubectl get pipelinerun/go-ko-image-test-run -o yaml
132+
exitCode=1
133+
fi
134+
135+
exit $exitCode

go-crane-image/go-crane-image.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ metadata:
55
labels:
66
app.kubernetes.io/version: "0.4.0"
77
annotations:
8-
tekton.dev/pipelines.minVersion: "0.40.0"
8+
tekton.dev/pipelines.minVersion: "0.50.0"
99
tekton.dev/categories: language
1010
tekton.dev/tags: go
1111
tekton.dev/displayName: "go crane image"

go-crane-image/tests/run.yaml

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ spec:
1010
requests:
1111
storage: 500Mi
1212
---
13-
apiVersion: tekton.dev/v1beta1
13+
apiVersion: tekton.dev/v1
1414
kind: Pipeline
1515
metadata:
1616
name: go-crane-image-pipeline
@@ -20,7 +20,14 @@ spec:
2020
tasks:
2121
- name: fetch-repository
2222
taskRef:
23-
name: git-clone
23+
resolver: git
24+
params:
25+
- name: url
26+
value: https://github.com/tektoncd/catalog
27+
- name: revision
28+
value: main
29+
- name: pathInRepo
30+
value: task/git-clone/0.9/git-clone.yaml
2431
workspaces:
2532
- name: output
2633
workspace: shared-workspace
@@ -48,11 +55,11 @@ spec:
4855
- name: image
4956
value:
5057
base: docker.io/library/alpine
51-
prefix: registry.local:5000/go-rest-api-test
58+
prefix: registry.registry.svc.cluster.local:32222/go-rest-api-test
5259
labels: foo=bar;bar=baz
5360
envs: FOO=bar;BAR=baz
5461
---
55-
apiVersion: tekton.dev/v1beta1
62+
apiVersion: tekton.dev/v1
5663
kind: PipelineRun
5764
metadata:
5865
name: go-crane-image-test-run

go-ko-image/go-ko-image.yaml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
apiVersion: tekton.dev/v1beta1
1+
apiVersion: tekton.dev/v1
22
kind: Task
33
metadata:
44
name: go-ko-image
55
labels:
66
app.kubernetes.io/version: "0.4.0"
77
annotations:
8-
tekton.dev/pipelines.minVersion: "0.40.0"
8+
tekton.dev/pipelines.minVersion: "0.50.0"
99
tekton.dev/categories: language
1010
tekton.dev/tags: go
1111
tekton.dev/displayName: "go ko image"
@@ -78,6 +78,7 @@ spec:
7878
#!/usr/bin/env bash
7979
set -e
8080
81+
git config --global --add safe.directory $(workspaces.source.path)
8182
if [[ "$(workspaces.dockerconfig.bound)" == "true" ]]; then
8283
# if config.json exists at workspace root, we use that
8384
if test -f "$(workspaces.dockerconfig.path)/config.json"; then

go-ko-image/tests/run.yaml

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ spec:
1010
requests:
1111
storage: 500Mi
1212
---
13-
apiVersion: tekton.dev/v1beta1
13+
apiVersion: tekton.dev/v1
1414
kind: Pipeline
1515
metadata:
1616
name: go-ko-image-pipeline
@@ -20,7 +20,14 @@ spec:
2020
tasks:
2121
- name: fetch-repository
2222
taskRef:
23-
name: git-clone
23+
resolver: git
24+
params:
25+
- name: url
26+
value: https://github.com/tektoncd/catalog
27+
- name: revision
28+
value: main
29+
- name: pathInRepo
30+
value: task/git-clone/0.9/git-clone.yaml
2431
workspaces:
2532
- name: output
2633
workspace: shared-workspace
@@ -48,11 +55,11 @@ spec:
4855
- name: image
4956
value:
5057
base: docker.io/library/alpine
51-
prefix: registry.local:5000/go-rest-api-test
58+
prefix: registry.registry.svc.cluster.local:32222/go-rest-api-test
5259
labels: foo=bar;bar=baz
5360
envs: FOO=bar;BAR=baz
5461
---
55-
apiVersion: tekton.dev/v1beta1
62+
apiVersion: tekton.dev/v1
5663
kind: PipelineRun
5764
metadata:
5865
name: go-ko-image-test-run

0 commit comments

Comments
 (0)