1
+ name : ci
2
+
1
3
on :
2
4
pull_request :
3
5
branches : [ main ]
6
8
schedule :
7
9
- cron : ' 0 0 * * *'
8
10
9
- name : test-tasks
11
+ concurrency :
12
+ group : ${{ github.workflow }}-${{ github.ref }}
13
+ cancel-in-progress : true
10
14
11
15
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
+
12
74
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
13
82
runs-on : ubuntu-latest
83
+ needs : build-images
14
84
permissions :
15
85
contents : read
16
86
packages : write
17
87
steps :
18
88
- 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
+
20
92
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
23
98
with :
24
- pipeline : v0.41.x
25
- pipeline-feature-flags : ' {"enable-api-fields": "alpha"} '
99
+ pipeline_version : ${{ matrix.pipeline-version }}
100
+
26
101
- 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
29
105
# go-crane-image
30
106
kubectl create -f ./go-crane-image/go-crane-image.yaml
31
107
kubectl create -f ./go-crane-image/tests/run.yaml
@@ -34,11 +110,12 @@ jobs:
34
110
tkn pipelinerun describe go-crane-image-test-run
35
111
36
112
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
42
119
43
120
# go-ko-image
44
121
kubectl create -f ./go-ko-image/go-ko-image.yaml
@@ -48,3 +125,11 @@ jobs:
48
125
tkn pipelinerun describe go-ko-image-test-run
49
126
50
127
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
0 commit comments