From 722a6b3dc093992d21ffcebb8a84dc4d676944ad Mon Sep 17 00:00:00 2001 From: Pranav Gaikwad Date: Fri, 20 Oct 2023 11:17:27 -0400 Subject: [PATCH 1/3] :sparkles: improve CI Signed-off-by: Pranav Gaikwad --- .github/workflows/testing.yaml | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/.github/workflows/testing.yaml b/.github/workflows/testing.yaml index e84e54b..2d4b22b 100644 --- a/.github/workflows/testing.yaml +++ b/.github/workflows/testing.yaml @@ -26,9 +26,13 @@ jobs: run: | expected_file=./test-data/analysis-output.yaml actual_file=./output/output.yaml - sed 's/^[ \t-]*//' $expected_file | sort -s > /tmp/expected_file - sed 's/^[ \t-]*//' $actual_file | sort -s > /tmp/actual_file - diff /tmp/expected_file /tmp/actual_file || diff $expected_file $actual_file + function filter_and_sort() { + yq e 'del(.[].skipped) | del(.[].unmatched)' $1 > /tmp/filtered + yq e '(.[] | select(.violations != null) | .violations |= (. | to_entries | sort_by(.key) | from_entries))' /tmp/filtered > $1 + } + filter_and_sort $expected_file + filter_and_sort $actual_file + diff $expected_file $actual_file - name: Fail if dependencies output does not match expected run: | From b1d58452c23e2a942565a2700734ac15e4597624 Mon Sep 17 00:00:00 2001 From: Pranav Gaikwad Date: Fri, 20 Oct 2023 12:05:43 -0400 Subject: [PATCH 2/3] :sparkles: update Signed-off-by: Pranav Gaikwad --- .github/workflows/testing.yaml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/testing.yaml b/.github/workflows/testing.yaml index 2d4b22b..3b65914 100644 --- a/.github/workflows/testing.yaml +++ b/.github/workflows/testing.yaml @@ -28,7 +28,8 @@ jobs: actual_file=./output/output.yaml function filter_and_sort() { yq e 'del(.[].skipped) | del(.[].unmatched)' $1 > /tmp/filtered - yq e '(.[] | select(.violations != null) | .violations |= (. | to_entries | sort_by(.key) | from_entries))' /tmp/filtered > $1 + yq e '.[]?.violations |= (. | to_entries | sort_by(.key) | from_entries)' /tmp/filtered > /tmp/sorted + yq e '.[]?.violations[]?.incidents |= sort_by(.uri)' /tmp/sorted > $1 } filter_and_sort $expected_file filter_and_sort $actual_file From 05635464ebcdeeabb40216f5ab186e99faed6fde Mon Sep 17 00:00:00 2001 From: Pranav Gaikwad Date: Fri, 20 Oct 2023 14:24:53 -0400 Subject: [PATCH 3/3] sort tags Signed-off-by: Pranav Gaikwad --- .github/workflows/testing.yaml | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/.github/workflows/testing.yaml b/.github/workflows/testing.yaml index 3b65914..01cadf3 100644 --- a/.github/workflows/testing.yaml +++ b/.github/workflows/testing.yaml @@ -27,12 +27,13 @@ jobs: expected_file=./test-data/analysis-output.yaml actual_file=./output/output.yaml function filter_and_sort() { - yq e 'del(.[].skipped) | del(.[].unmatched)' $1 > /tmp/filtered - yq e '.[]?.violations |= (. | to_entries | sort_by(.key) | from_entries)' /tmp/filtered > /tmp/sorted - yq e '.[]?.violations[]?.incidents |= sort_by(.uri)' /tmp/sorted > $1 + yq e 'del(.[].skipped) | del(.[].unmatched)' $1 \ + | yq e '.[]?.violations |= (. | to_entries | sort_by(.key) | from_entries)' \ + | yq e '.[]?.violations[]?.incidents |= sort_by(.uri)' \ + | yq e '.[] | (.tags // []) |= sort' } - filter_and_sort $expected_file - filter_and_sort $actual_file + filter_and_sort $expected_file > $expected_file + filter_and_sort $actual_file > $actual_file diff $expected_file $actual_file - name: Fail if dependencies output does not match expected