Skip to content

Commit

Permalink
👻 add workflow to run sanity tests on branches
Browse files Browse the repository at this point in the history
Signed-off-by: Pranav Gaikwad <[email protected]>
  • Loading branch information
pranavgaikwad committed May 1, 2024
1 parent b497577 commit f3cbbac
Show file tree
Hide file tree
Showing 3 changed files with 85 additions and 3 deletions.
20 changes: 20 additions & 0 deletions .github/workflows/nightly.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
name: Nightly tests

on:
schedule:
- cron: '0 0 * * *'
workflow_dispatch:
inputs:
tag:
type: string
default: latest
description: Container image tag to use for testing

jobs:
run_test:
uses: pranavgaikwad/kantra/.github/workflows/testing.yaml@main
with:
tag: ${{ github.ref_name == 'main' && 'latest' || github.ref_name }}



66 changes: 63 additions & 3 deletions .github/workflows/testing.yaml
Original file line number Diff line number Diff line change
@@ -1,9 +1,18 @@
name: Demo Testing

on: ["push", "pull_request", "workflow_dispatch"]
on:
push:
pull_request:
workflow_call:
inputs:
tag:
type: string
required: true

jobs:
test:
test-branch:
name: Run tests using image built from current branch
if: github.event_name == 'push' || github.event_name == 'pull_request'
runs-on: ubuntu-latest
steps:
- name: Setup Homebrew
Expand Down Expand Up @@ -34,7 +43,7 @@ jobs:
ref: "${{ env.ANALYZER_REF}}"
path: analyzer-lsp

- name: Build anaylzer and save image
- name: Build analyzer image
working-directory: analyzer-lsp
run: |
podman build -t quay.io/konveyor/analyzer-lsp:latest .
Expand Down Expand Up @@ -81,3 +90,54 @@ jobs:
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
test-published:
name: Run tests using published images
if: github.event_name != 'push' && github.event_name != 'pull_request'
runs-on: ubuntu-latest
steps:
- name: Setup Homebrew
uses: Homebrew/actions/setup-homebrew@master

- name: Upgrade podman
run: |
sudo apt-get install -y ansible
export DEB=$(curl -s https://passt.top/builds/latest/x86_64/ | grep deb | awk -F '"' '{ print $4}')
sudo ansible -m apt -a deb=https://passt.top/builds/latest/x86_64/${DEB} localhost
sudo apt-get remove podman crun
brew install crun podman
- uses: actions/checkout@v3

- name: download kantra and run test
run: |
git clone https://github.com/konveyor/example-applications
podman cp $(podman create --name kantra-download quay.io/konveyor/kantra:${{ inputs.tag }}):/usr/local/bin/kantra .
podman rm kantra-download
./kantra analyze --input $(pwd)/example-applications/example-1/ \
--output ./output/ --target cloud-readiness \
--rules ./test-data/jni-native-code-test.windup.xml
- name: fail if analysis output doesn't 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 deps output doesn't 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
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
![Test](https://github.com/konveyor/kantra/actions/workflows/nightly.yml/badge.svg?branch=main)

# Kantra

Kantra is a CLI that unifies analysis and transformation capabilities of Konveyor. It is available for Linux, Mac and Windows.
Expand Down

0 comments on commit f3cbbac

Please sign in to comment.