Skip to content

Commit

Permalink
✨ adding reflection client to determine what provider provides (#586)
Browse files Browse the repository at this point in the history
Fixes #573 

* Testing external providers
* writing makefile to easily test pod in Podman
* fixing race condition around what SHA is used for resolved identifiers in java provider


---------

Signed-off-by: Shawn Hurley <shawn@hurley.page>
Signed-off-by: Pranav Gaikwad <pgaikwad@redhat.com>
Co-authored-by: Pranav Gaikwad <pgaikwad@redhat.com>
  • Loading branch information
shawn-hurley and pranavgaikwad authored Apr 24, 2024
1 parent 20e6323 commit 5cfd080
Show file tree
Hide file tree
Showing 37 changed files with 1,597 additions and 765 deletions.
62 changes: 7 additions & 55 deletions .github/workflows/demo-testing.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,63 +38,15 @@ jobs:
# build all provider images and the analyzer-lsp image
- name: build images
run: |
function build_image {
dir=$1
name=$2
pushd ${dir}
podman build -t quay.io/konveyor/${name}:latest -f Dockerfile .
popd
}
pushd ./external-providers/
build_image golang-dependency-provider golang-dependency-provider
build_image java-external-provider java-external-provider
build_image yq-external-provider yq-external-provider
build_image generic-external-provider generic-external-provider
popd
build_image . analyzer-lsp
make build-external
podman build -t quay.io/konveyor/analyzer-lsp:latest -f Dockerfile .
# run the demo in a podman pod
- name: run demo image
run: |
function run_provider {
name=$1
img=$2
port=$3
podman run -d --pod analyzer --name ${name} -v test-data:/analyzer-lsp/examples/:Z \
quay.io/konveyor/${img}:latest --port ${port}
}
mkdir /tmp/examples/ && \
cp -r examples/* /tmp/examples/ && \
cp -r ./external-providers/java-external-provider/examples/* /tmp/examples/
podman volume create test-data
podman run --rm -v test-data:/target -v /tmp/examples/:/src/:Z \
--entrypoint=cp alpine -a /src/. /target/
podman pod create --name=analyzer
run_provider golang generic-external-provider 9999
run_provider nodejs generic-external-provider 9998
run_provider python generic-external-provider 9997
run_provider java java-external-provider 9996
run_provider yq yq-external-provider 9995
jq 'map(
if .name == "go" then del(.binaryPath) | .address = "localhost:9999"
elif .name == "nodejs" then del(.binaryPath) | .address = "localhost:9998"
elif .name == "python" then del(.binaryPath) | .address = "localhost:9997"
elif .name == "java" then del(.binaryPath) | .address = "localhost:9996"
elif .name == "yaml" then del(.binaryPath) | .address = "localhost:9995"
else .
end
)' provider_container_settings.json | tee provider_container_settings.json
podman build -f demo.Dockerfile -t localhost/testing:latest
podman run --entrypoint /usr/local/bin/konveyor-analyzer \
--pod=analyzer \
-v $(pwd)/demo-dep-output.yaml:/analyzer-lsp/demo-dep-output.yaml:Z \
-v $(pwd)/demo-output.yaml:/analyzer-lsp/output.yaml:Z \
localhost/testing:latest --dep-output-file=demo-dep-output.yaml
run : |
make run-external-providers-pod
podman build -f demo-local.Dockerfile -t localhost/testing:latest
make run-demo-image
- name: install yq for testing
run: go install github.com/mikefarah/yq/v4@latest
Expand Down Expand Up @@ -133,4 +85,4 @@ jobs:
uses: konveyor/ci/.github/workflows/global-ci.yml@main
with:
component_name: tackle2-addon-analyzer
api_tests_ref: "${{ needs.test.outputs.api_tests_ref }}"
api_tests_ref: "${{ needs.test.outputs.api_tests_ref }}"
2 changes: 1 addition & 1 deletion .github/workflows/pr-testing.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ jobs:
- name: Set up Go
uses: actions/setup-go@v3
with:
go-version: 1.18
go-version: '1.20'

- name: Test
run: go test -v ./...
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM golang:1.19 as builder
FROM golang:1.20 as builder
WORKDIR /analyzer-lsp

COPY cmd /analyzer-lsp/cmd
Expand Down
71 changes: 70 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
DOCKER_IMAGE = test

build: analyzer deps external-generic golang-dependency-provider yq-external-provider java-external-provider
build: analyzer deps golang-dependency-provider external-generic yq-external-provider java-external-provider

analyzer:
go build -o konveyor-analyzer ./cmd/analyzer/main.go
Expand All @@ -22,3 +22,72 @@ deps:

image-build:
docker build -f Dockerfile . -t $(DOCKER_IMAGE)

build-external: build-dotnet-provider build-golang-dep-provider build-generic-provider build-java-provider build-yq-provider

build-dotnet-provider:
cd external-providers/dotnet-external-provider/ && go mod edit --replace=github.com/konveyor/analyzer-lsp=/analyzer-lsp
podman build -f external-providers/dotnet-external-provider/Dockerfile -t dotnet-provider .

build-generic-provider:
cd external-providers/generic-external-provider/ && go mod edit --replace=github.com/konveyor/analyzer-lsp=/analyzer-lsp
sed -i 's,quay.io/konveyor/golang-dependency-provider,golang-dep-provider,g' external-providers/generic-external-provider/Dockerfile
podman build -f external-providers/generic-external-provider/Dockerfile -t generic-provider .

build-golang-dep-provider:
cd external-providers/golang-dependency-provider/ && go mod edit --replace=github.com/konveyor/analyzer-lsp=/analyzer-lsp
podman build -f external-providers/golang-dependency-provider/Dockerfile -t golang-dep-provider .

build-java-provider:
cd external-providers/java-external-provider/ && go mod edit --replace=github.com/konveyor/analyzer-lsp=/analyzer-lsp
podman build -f external-providers/java-external-provider/Dockerfile -t java-provider .

build-yq-provider:
cd external-providers/yq-external-provider/ && go mod edit --replace=github.com/konveyor/analyzer-lsp=/analyzer-lsp
podman build -f external-providers/yq-external-provider/Dockerfile -t yq-provider .

run-external-providers-local:
podman run --name java-provider -d -p 14651:14651 -v $(PWD)/external-providers/java-external-provider/examples:/examples java-provider --port 14651
podman run --name yq -d -p 14652:14652 -v $(PWD)/examples:/examples yq-provider --port 14652
podman run --name golang-provider -d -p 14653:14653 -v $(PWD)/examples:/examples generic-provider --port 14653
podman run --name nodejs -d -p 14654:14654 -v $(PWD)/examples:/examples generic-provider --port 14654 --name nodejs
podman run --name python -d -p 14655:14655 -v $(PWD)/examples:/examples generic-provider --port 14655 --name pylsp

stop-external-providers:
podman kill java-provider || true
podman kill yq || true
podman kill golang-provider || true
podman kill nodejs || true
podman kill python || true
podman rm java-provider || true
podman rm yq || true
podman rm golang-provider || true
podman rm nodejs || true
podman rm python || true
cd external-providers/yq-external-provider/ && go mod edit --dropreplace=github.com/konveyor/analyzer-lsp
cd external-providers/java-external-provider/ && go mod edit --dropreplace=github.com/konveyor/analyzer-lsp
cd external-providers/golang-dependency-provider/ && go mod edit --dropreplace=github.com/konveyor/analyzer-lsp
cd external-providers/generic-external-provider/ && go mod edit --dropreplace=github.com/konveyor/analyzer-lsp
cd external-providers/dotnet-external-provider/ && go mod edit --dropreplace=github.com/konveyor/analyzer-lsp

run-external-providers-pod:
podman volume create test-data
# copy data to test data volume
podman run --rm -v test-data:/target -v $(PWD)/examples:/src/ --entrypoint=cp alpine -a /src/. /target/
podman run --rm -v test-data:/target -v $(PWD)/external-providers/java-external-provider/examples:/src/ --entrypoint=cp alpine -a /src/. /target/
# run pods w/ defined ports for the test volumes
podman pod create --name=analyzer
podman run --pod analyzer --name java-provider -d -v test-data:/analyzer-lsp/examples java-provider --port 14651
podman run --pod analyzer --name yq -d -v test-data:/analyzer-lsp/examples yq-provider --port 14652
podman run --pod analyzer --name golang-provider -d -v test-data:/analyzer-lsp/examples generic-provider --port 14653
podman run --pod analyzer --name nodejs -d -v test-data:/analyzer-lsp/examples generic-provider --port 14654 --name nodejs
podman run --pod analyzer --name python -d -v test-data:/analyzer-lsp/examples generic-provider --port 14655 --name pylsp
podman build -f demo-local.Dockerfile -t localhost/testing:latest

run-demo-image:
podman run --entrypoint /usr/local/bin/konveyor-analyzer --pod=analyzer -v $(PWD)/demo-dep-output.yaml:/analyzer-lsp/demo-dep-output.yaml:Z -v $(PWD)/demo-output.yaml:/analyzer-lsp/output.yaml:Z localhost/testing:latest --dep-output-file=demo-dep-output.yaml

stop-external-providers-pod:
podman pod kill analyzer
podman pod rm analyzer
podman volume rm test-data
Loading

0 comments on commit 5cfd080

Please sign in to comment.