Skip to content

👻 add docker to ci #157

👻 add docker to ci

👻 add docker to ci #157

Workflow file for this run

name: Demo Testing
on: ["push", "pull_request", "workflow_dispatch"]
jobs:
test:
strategy:
fail-fast: false
matrix:
tool: ["podman", "docker"]
runs-on: ubuntu-latest
steps:
- name: Setup Homebrew
if: matrix.tool == 'podman'
uses: Homebrew/actions/setup-homebrew@master
- name: Setup podman
if: matrix.tool == '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
- name: Extract pull request number from inputs or PR description
run: |
echo "${{ github.event.pull_request.body }}"
PULL_REQUEST_NUMBER=$(echo "${{ github.event.pull_request.body }}" | grep -oP 'Analyzer PR: \K\d+' || true)
if [ -z "$PULL_REQUEST_NUMBER" ]; then
echo "ANALYZER_REF=main" >>$GITHUB_ENV
else
echo "ANALYZER_REF=refs/pull/$PULL_REQUEST_NUMBER/merge" >>$GITHUB_ENV
fi
- uses: actions/checkout@v3
with:
fetch-depth: 0
repository: konveyor/analyzer-lsp
ref: "${{ env.ANALYZER_REF}}"
path: analyzer-lsp
- name: Build analyzer and save image
working-directory: analyzer-lsp
run: |
${{ matrix.tool }} build -t quay.io/konveyor/analyzer-lsp:latest .
env:
DOCKER_BUILDKIT: 1
- uses: actions/checkout@v3
- name: Build image and binary
run: |
${{ matrix.tool }} build -t localhost/kantra:latest -f Dockerfile .
go build -o kantra main.go
env:
DOCKER_BUILDKIT: 1
- name: Run unit tests
if: matrix.tool == 'podman'
run: |
go test ./...
env:
RUNNER_IMG: localhost/kantra:latest
PODMAN_BIN: ${{ matrix.tool }}
- 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: |
./kantra analyze --input $(pwd)/example-applications/example-1/ \
--rules ./test-data/jni-native-code-test.windup.xml \
--output ./output/ --target cloud-readiness
env:
RUNNER_IMG: localhost/kantra:latest
PODMAN_BIN: ${{ matrix.tool }}
# TODO (pgaikwad): Change this to a yaml test and run `kantra test`
- name: Fail if analysis output does not match expected
run: |
sudo chmod 777 ./output/output.yaml ./output/dependencies.yaml
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