Skip to content

Commit

Permalink
Add task-lint CI
Browse files Browse the repository at this point in the history
  • Loading branch information
tisutisu committed Nov 15, 2024
1 parent 6c9cafd commit 49db4a5
Show file tree
Hide file tree
Showing 2 changed files with 54 additions and 1 deletion.
2 changes: 1 addition & 1 deletion .github/workflows/run-task-tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ jobs:
with:
repository: 'konflux-ci/konflux-ci'
path: konflux-ci
commit: f6d9d0fe8f34199eb118febcbf7f7944ae7772a9
ref: f6d9d0fe8f34199eb118febcbf7f7944ae7772a9

- name: Create k8s Kind Cluster
if: steps.changed-files.outputs.any_changed == 'true'
Expand Down
53 changes: 53 additions & 0 deletions .github/workflows/task-lint.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
---
name: tasklint
"on":
pull_request:
branches: [main]
jobs:
tasklint:
runs-on: ubuntu-latest
steps:
- name: Get all changed files in the PR from task directories
id: changed-files
uses: tj-actions/changed-files@v45
with:
# Avoid using single or double quotes for multiline patterns
files: |
task/*/*/*.yaml

Check failure on line 17 in .github/workflows/task-lint.yaml

View workflow job for this annotation

GitHub Actions / yamllint

17:1 [trailing-spaces] trailing spaces
- name: Setup Go
if: steps.changed-files.outputs.any_changed == 'true'
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@4e9385885cc638fe337bcb9cc5f3d64cc8c262c5
- name: Run tektor linter
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}"
function print_changed_tasks_to_console() {
echo ${CHANGED_FILES} | grep -o 'task/[^\/]*/[^\/]*/*[^/]*.yaml' || true
}
function validate_task_yaml_using_tektor() {
all_tasks="$*"
for task in ${all_tasks}; do
# Skip if it is kustomize related yaml files
if [[ ${task} == *"kustomization.yaml" || ${task} == *"patch.yaml" || ${task} == *"recipe.yaml" ]]; then
continue
fi
tektor validate ${task}
done
}

Check failure on line 48 in .github/workflows/task-lint.yaml

View workflow job for this annotation

GitHub Actions / yamllint

48:1 [trailing-spaces] trailing spaces
# Validate task yamls using tektor linter
tasks_changed=$(print_changed_tasks_to_console)
[[ ! -z ${tasks_changed} ]] && {
validate_task_yaml_using_tektor "${tasks_changed}"
}

0 comments on commit 49db4a5

Please sign in to comment.