-
Notifications
You must be signed in to change notification settings - Fork 140
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
595 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,98 @@ | ||
name: Run Task Tests | ||
|
||
"on": | ||
pull_request | ||
|
||
jobs: | ||
run-task-tests: | ||
runs-on: ubuntu-22.04 | ||
steps: | ||
- name: Get all changed files in the PR from task or test directories | ||
id: changed-files | ||
uses: tj-actions/changed-files@v45 | ||
with: | ||
# Avoid using single or double quotes for multiline patterns | ||
files: | | ||
task/** | ||
test/** | ||
- name: Free Disk Space | ||
if: steps.changed-files.outputs.any_changed == 'true' | ||
uses: jlumbroso/free-disk-space@main | ||
with: | ||
tool-cache: false | ||
docker-images: false | ||
|
||
- name: Setup Go | ||
uses: actions/setup-go@v5 | ||
with: | ||
go-version: '1.22' | ||
|
||
- name: Install tektor | ||
if: steps.changed-files.outputs.any_changed == 'true' | ||
run: | | ||
go install github.com/lcarva/tektor@latest | ||
- name: Checkout build-defintions Repository | ||
if: steps.changed-files.outputs.any_changed == 'true' | ||
uses: actions/checkout@v3 | ||
with: | ||
ref: "${{ github.event.pull_request.head.sha }}" | ||
path: build-definitions | ||
|
||
- name: Checkout konflux-ci/konflux-ci Repository | ||
if: steps.changed-files.outputs.any_changed == 'true' | ||
uses: actions/checkout@v3 | ||
with: | ||
repository: 'konflux-ci/konflux-ci' | ||
path: konflux-ci | ||
|
||
- name: Create k8s Kind Cluster | ||
if: steps.changed-files.outputs.any_changed == 'true' | ||
uses: helm/kind-action@v1 | ||
with: | ||
config: konflux-ci/kind-config.yaml | ||
|
||
- name: Show version information | ||
if: steps.changed-files.outputs.any_changed == 'true' | ||
run: | | ||
kubectl version | ||
kind version | ||
- name: Deploying Dependencies | ||
if: steps.changed-files.outputs.any_changed == 'true' | ||
run: | | ||
cd $GITHUB_WORKSPACE/konflux-ci | ||
./deploy-deps.sh | ||
- name: Wait for the dependencies to be ready | ||
if: steps.changed-files.outputs.any_changed == 'true' | ||
run: | | ||
#cd $GITHUB_WORKSPACE/konflux-ci | ||
./wait-for-all.sh | ||
- name: Deploying Konflux | ||
if: steps.changed-files.outputs.any_changed == 'true' | ||
run: | | ||
#cd $GITHUB_WORKSPACE/konflux-ci | ||
./deploy-konflux.sh | ||
- name: List namespaces | ||
if: steps.changed-files.outputs.any_changed == 'true' | ||
run: | | ||
kubectl get namespace | ||
- name: Deploy test resources | ||
if: steps.changed-files.outputs.any_changed == 'true' | ||
run: | | ||
#cd $GITHUB_WORKSPACE/konflux-ci | ||
./deploy-test-resources.sh | ||
- name: Run the task tests | ||
if: steps.changed-files.outputs.any_changed == 'true' | ||
env: | ||
CHANGED_FILES: ${{ steps.changed-files.outputs.all_changed_files }} | ||
run: | | ||
echo "Files changed in PR: ${CHANGED_FILES}" | ||
cd $GITHUB_WORKSPACE/build-definitions | ||
./test/test-tasks.sh |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
#!/bin/bash | ||
|
||
set -ex | ||
|
||
cd $(git rev-parse --show-toplevel) | ||
source test/common.sh | ||
|
||
if [[ -z ${@} || ${1} == "-h" ]];then | ||
cat <<EOF | ||
This script will run a single task to help developers testing directly a | ||
single task without sending it to CI. | ||
You need to specify the resource kind as the first argument, resource name | ||
as the second argument and the resource version as the second argument. | ||
For example : | ||
${0} task git-clone 0.1 | ||
will run the tests for the git-clone task | ||
while | ||
${0} stepaction git-clone 0.1 | ||
will run the tests for the git-clone stepaction. | ||
EOF | ||
exit 0 | ||
fi | ||
|
||
TMPF=$(mktemp /tmp/.mm.XXXXXX) | ||
clean() { rm -f ${TMPF}; } | ||
trap clean EXIT | ||
|
||
RESOURCE=${1} | ||
NAME=${2} | ||
VERSION=${3} | ||
|
||
resourcedir=${RESOURCE}/${NAME}/${VERSION} | ||
|
||
if [[ ! -d ${resourcedir}/tests ]];then | ||
echo "No 'tests' directory is located in ${resourcedir}" | ||
exit 1 | ||
fi | ||
|
||
tns=${NAME}-${VERSION//./-} | ||
|
||
# Delete the tns if already exists | ||
${KUBECTL_CMD} delete ns ${tns} >/dev/null 2>/dev/null || : | ||
|
||
${KUBECTL_CMD} create namespace ${tns} | ||
|
||
#create appstudio-pipeline SA in the test namespace if not already | ||
if ! ${KUBECTL_CMD} get sa appstudio-pipeline -n ${tns} | grep 'appstudio-pipeline'; then | ||
$KUBECTL_CMD create sa appstudio-pipeline -n ${tns} | ||
fi | ||
|
||
test_resource_creation ${RESOURCE}/${NAME}/${VERSION}/tests |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
#!/bin/bash | ||
|
||
echo "example of pre-apply-task-hook, this script can be used to run kubernetes commands" | ||
${KUBECTL_CMD} get ns |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
#!/bin/bash | ||
|
||
echo "an example of pre-apply-taskrun-hook script" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
--- | ||
apiVersion: tekton.dev/v1beta1 | ||
kind: TaskRun | ||
metadata: | ||
name: git-clone-run-noargs | ||
spec: | ||
workspaces: | ||
- name: output | ||
emptyDir: {} | ||
taskRef: | ||
name: git-clone | ||
params: | ||
- name: url | ||
value: https://github.com/kelseyhightower/nocode | ||
--- | ||
apiVersion: tekton.dev/v1beta1 | ||
kind: TaskRun | ||
metadata: | ||
name: git-clone-run-tag | ||
spec: | ||
workspaces: | ||
- name: output | ||
emptyDir: {} | ||
taskRef: | ||
name: git-clone | ||
params: | ||
- name: url | ||
value: https://github.com/kelseyhightower/nocode | ||
- name: revision | ||
value: 1.0.0 |
Oops, something went wrong.