-
Notifications
You must be signed in to change notification settings - Fork 141
113 lines (99 loc) · 3.64 KB
/
run-task-tests.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
name: Run Task Tests
"on":
pull_request:
types:
- opened
- synchronize
- reopened
jobs:
run-task-tests:
runs-on: ubuntu-24.04
steps:
- name: Get all changed files in the PR from task directory
id: changed-dirs
uses: tj-actions/changed-files@v45
with:
files: |
# Any task yaml or script (including its tests) is changed
task/**/*.{yaml,sh}
dir_names: "true"
dir_names_max_depth: "3"
- name: Checkout build-defintions Repository
if: steps.changed-dirs.outputs.any_changed == 'true'
uses: actions/checkout@v4
with:
ref: "${{ github.event.pull_request.head.sha }}"
path: build-definitions
- name: Check if tests dir exists for all the tasks changed
if: steps.changed-dirs.outputs.any_changed == 'true'
id: tasks-to-be-tested
env:
CHANGED_DIRS: ${{ steps.changed-dirs.outputs.all_changed_files }}
run: |
echo "Task Dirs changed in PR: ${CHANGED_DIRS}"
# Check if tests dir exists under each task dir
TASKS_TO_BE_TESTED=()
for TASK_DIR in ${CHANGED_DIRS}; do
TESTS_DIR=build-definitions/${TASK_DIR}/tests
if [ ! -d $TESTS_DIR ]; then
echo "INFO: tests dir does not exist: $TESTS_DIR"
continue
else
echo "INFO: tests dir exists for task: $TASK_DIR"
TASKS_TO_BE_TESTED+=("$TASK_DIR")
fi
done
echo "Tasks with tests: ${TASKS_TO_BE_TESTED[*]}"
echo "tasklist=${TASKS_TO_BE_TESTED[*]}" >> $GITHUB_OUTPUT
- name: Install tkn
if: steps.tasks-to-be-tested.outputs.tasklist != ''
uses: ./build-definitions/.github/actions/install-tkn
- name: Checkout konflux-ci/konflux-ci Repository
if: steps.tasks-to-be-tested.outputs.tasklist != ''
uses: actions/checkout@v4
with:
repository: 'konflux-ci/konflux-ci'
path: konflux-ci
ref: d19c18bc2ec9c47c02d8bcf30305a3e5e198bc9f
- name: Create k8s Kind Cluster
if: steps.tasks-to-be-tested.outputs.tasklist != ''
uses: helm/kind-action@v1
with:
config: konflux-ci/kind-config.yaml
- name: Show version information
if: steps.tasks-to-be-tested.outputs.tasklist != ''
run: |
kubectl version
kind version
- name: Deploying Dependencies
if: steps.tasks-to-be-tested.outputs.tasklist != ''
run: |
cd $GITHUB_WORKSPACE/konflux-ci
./deploy-deps.sh
- name: Wait for the dependencies to be ready
if: steps.tasks-to-be-tested.outputs.tasklist != ''
run: |
cd $GITHUB_WORKSPACE/konflux-ci
./wait-for-all.sh
- name: Deploying Konflux
if: steps.tasks-to-be-tested.outputs.tasklist != ''
run: |
cd $GITHUB_WORKSPACE/konflux-ci
./deploy-konflux.sh
- name: List namespaces
if: steps.tasks-to-be-tested.outputs.tasklist != ''
run: |
kubectl get namespace
- name: Deploy test resources
if: steps.tasks-to-be-tested.outputs.tasklist != ''
run: |
cd $GITHUB_WORKSPACE/konflux-ci
./deploy-test-resources.sh
- name: Run the task tests
if: steps.tasks-to-be-tested.outputs.tasklist != ''
env:
TASK_LIST: ${{ steps.tasks-to-be-tested.outputs.tasklist }}
run: |
echo "Tasks to be tested: ${TASK_LIST}"
cd $GITHUB_WORKSPACE/build-definitions
./.github/scripts/test_tekton_tasks.sh ${TASK_LIST}