generated from konveyor-ecosystem/template-repo
-
Notifications
You must be signed in to change notification settings - Fork 27
45 lines (38 loc) · 1.79 KB
/
testing.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
name: Demo Testing
on: ["push", "pull_request"]
jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Build image and binary
run: |
podman build -t localhost/kantra:latest -f Dockerfile .
go build -o kantra main.go
- name: Fetch sample applications
run: |
git clone https://github.com/konveyor/example-applications
git clone https://github.com/ivargrimstad/jakartaee-duke
- name: Run analysis test and copy output
run: |
RUNNER_IMG=localhost/kantra:latest ./kantra analyze --input $(pwd)/example-applications/example-1/ --output ./output/ --rules ./test-data/jni-native-code-test.windup.xml --target cloud-readiness
- name: Fail if analysis output does not match expected
run: |
expected_file=./test-data/analysis-output.yaml
actual_file=./output/output.yaml
function filter_and_sort() {
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 > $expected_file
filter_and_sort $actual_file > $actual_file
diff $expected_file $actual_file
- name: Fail if dependencies output does not match expected
run: |
expected_file=./test-data/deps-output.yaml
actual_file=./output/dependencies.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