Skip to content

Commit

Permalink
👻 add mac, windows to ci test
Browse files Browse the repository at this point in the history
Signed-off-by: Pranav Gaikwad <[email protected]>
  • Loading branch information
pranavgaikwad committed Apr 29, 2024
1 parent 1c84548 commit 7cfdb8b
Showing 1 changed file with 62 additions and 36 deletions.
98 changes: 62 additions & 36 deletions .github/workflows/testing.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,48 @@ name: Demo Testing

on: ["push", "pull_request", "workflow_dispatch"]

jobs:
test:
runs-on: ubuntu-latest
jobs:
e2e-test:
strategy:
matrix:
os: ["ubuntu-latest", "macos-latest", "windows-latest"]
tool: ["podman", "docker"]
runs-on: ${{ matrix.os }}
steps:
- name: Setup Homebrew
- name: Setup Homebrew (linux)
if: matrix.os == 'ubuntu-latest'
uses: Homebrew/actions/setup-homebrew@master

- name: Upgrade podman
- name: Upgrade podman (linux)
if: matrix.os == 'ubuntu-latest'
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
- name: Install podman/docker (mac)
if: matrix.os == 'macos-latest'
run: |
brew install ${{ matrix.tool }}
- name: Start docker (mac)
if: matrix.os == 'macos-latest' && matrix.tool == 'docker'
run: |
open /Applications/Docker.app
while ! docker system info > /dev/null 2>&1; do sleep 1; done
- name: Install podman (windows)
if: matrix.os == 'windows-latest'
run: |
choco install podman
- name: Init podman machine (mac/windows)
if: (matrix.os == 'windows-latest' || matrix.os == 'macos-latest') && matrix.tool == 'podman'
run: |
podman machine init
- name: Extract pull request number from inputs or PR description
run: |
echo "${{ github.event.pull_request.body }}"
Expand All @@ -28,56 +55,55 @@ jobs:
fi
- uses: actions/checkout@v3
if: env.ANALYZER_REF != 'main'
with:
fetch-depth: 0
repository: konveyor/analyzer-lsp
ref: "${{ env.ANALYZER_REF}}"
ref: "${{ env.ANALYZER_REF }}"
path: analyzer-lsp

- name: Build anaylzer and save image
if: env.ANALYZER_REF != 'main'
working-directory: analyzer-lsp
run: |
podman build -t quay.io/konveyor/analyzer-lsp:latest .
${{ matrix.tool }} build -t quay.io/konveyor/analyzer-lsp:latest .
- uses: actions/checkout@v3

- name: Build image and binary
run: |
podman build -t localhost/kantra:latest -f Dockerfile .
${{ matrix.tool }} build -t localhost/kantra:latest -f Dockerfile .
go build -o kantra main.go
- name: Run unit tests
run: |
RUNNER_IMG=localhost/kantra:latest go test ./...
- 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: Run analysis test and copy output
# if: matrix.os == 'ubuntu-latest'
# run: |
# RUNNER_IMG=localhost/kantra:latest PODMAN_BIN=${{ matrix.tool }} ./kantra analyze --input $(pwd)/example-applications/example-1/ --output ./output/ --rules ./test-data/jni-native-code-test.windup.xml --target cloud-readiness

# TODO (pgaikwad): Change this to a yaml test and run `kantra test`
- 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
# # TODO (pgaikwad): Change this to a yaml test and run `kantra test`
# - 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
# - 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

0 comments on commit 7cfdb8b

Please sign in to comment.