karatelabs / karate

Test Automation Made Simple
https://karatelabs.github.io/karate
MIT License
8.14k stars 1.94k forks source link

Add support of arm64 for image karatelabs/karate-chrome #2422

Open jandry opened 1 year ago

jandry commented 1 year ago

Hi, As a growing part of developer are using M1 or M2 and that you now support more officially karatelabs/karate-chrome, it could be great to support multi os on the image adding arm64

Regards

ptrthomas commented 1 year ago

@jandry do consider contributing code or influencing someone who can

jandry commented 12 months ago

Not sure at all that solution is working in pipeline but here is a trial PR https://github.com/karatelabs/karate/pull/2424

ptrthomas commented 12 months ago

@jandry thanks ! I have a concern with chromium - we have teams that have been using chrome stable for years, and we like the fact that you can test on a "real browser" and not worry about the risk of differences between chrome and chromium

I am ok to ship a second docker image based on chromium if that helps, you can see how we do the release build here - after build-docker.sh runs: https://github.com/karatelabs/karate/blob/develop/.github/workflows/maven-release.yml

jandry commented 12 months ago

Make sens. I will try to do that next xeek

jandry commented 11 months ago

@ptrthomas I pushed an update that should build both images

I also switch default image pushed to local docker for tests depending platform for local testing. Default still the chrome one except on mac darwin

How can I check if push is working ? That the only part where I'm not sure : right tag, reuse of cache and login working

ptrthomas commented 11 months ago

@jandry you mean pushing to docker hub ? it is done as a github-action I can take care of that. we'll probably release 1.5.0.RC2 in a weeks time, so I will watch how it goes and tweak then

ptrthomas commented 11 months ago

I believe there are ways to run github actions locally if you search, but I have never tried @jandry

thanks a lot for contributing this :)

jandry commented 11 months ago

Thanks a lot for this super Open Source test framework

Yes I wanted to test in the git action to push is working fine. I'm working with gitlab CI usually so I'm not sure how is the isolation between actions is working. Because the "build docker" action is creating a cache in target/docker that is reused in the push action to retrieve already created layers. Do you know if the target folder is kept between actions ? (It's not the case in gitlabci). If not it will try to rebuild and will failed because of empty target folder.

ptrthomas commented 11 months ago

@jandry I really don't know, but will watch out for this. there is a concept of "matrix build" and I think one option is to fork the build into 2 parallel jobs

jandry commented 11 months ago

From what I read seems ok because you use steps in the same job (called build) so it still on same runner with same workspace https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idsteps

daviddavidgit commented 4 months ago

So what is the status of this issue?

ptrthomas commented 4 months ago

@daviddavidgit there is an open PR: https://github.com/karatelabs/karate/pull/2424 - do contribute if you can

daviddavidgit commented 4 months ago

As far as I unsterstand it correctly, the code from @jandry must be tested on github actions. @ptrthomas would it not be the easiest way if you test this PR, since you have permission to do that?

jandry commented 4 months ago

Yes , I can't do better 😅

ptrthomas commented 4 months ago

@jandry okay, apologies - I have a lot of stuff on my plate. may I request that you tweak the PR so that there are zero changes to karate-chrome and we have a separate github action flow which does only one thing which is release karate-chromium. and to start with it is ok if all this is mac only ? I can then run only that github action and see how it goes, does that make sense ?

I also wonder if in the meantime if chrome for arm is available, I haven't checked

daviddavidgit commented 4 months ago

Unfortunately there is still no linux/arm version of chrome.

jandry commented 4 months ago

@ptrthomas yes it's a what you initially asked for. So it's what I did:

This line build the chrome one only for linux/amd64 as actually docker buildx build --push --platform linux/amd64 --cache-from=type=local,src=./target/docker -t karate-chrome -t karatelabs/karate-chrome:latest -t karatelabs/karate-chrome:${{ github.event.inputs.version }} karate-docker/karate-chrome so same as docker build -t karate-chrome karate-docker/karate-chrome but using buildx instead

This line build the new chromium one on both platform docker buildx build --push --platform linux/amd64,linux/arm64 --cache-from=type=local,src=./target/docker -t karate-chromium -t karatelabs/karate-chromium:latest -t karatelabs/karate-chromium:${{ github.event.inputs.version }} karate-docker/karate-chromium

I didn't isolate in two different jobs for optimization purpose. Some elements of first build are reuse is second build thanks to the cache --cache-from=type=local,src=./target/docker

ptrthomas commented 4 months ago

@jandry okay, agreed with the approach. but trying to make sure - see screenshot below - this should be reverted right ?

image
jandry commented 4 months ago

Yes you are right A forgotten to revertit . I did this for local testing purpose on my mac I pushed the revert

ptrthomas commented 4 months ago

@jandry well, the attempt to run the docker push failed and I have no idea why. the login step (and credentials) were not changed at all, and they seem ok https://github.com/karatelabs/karate/actions/runs/9401006648/job/25891832379

image
ptrthomas commented 4 months ago

@jandry and the "old" script worked: https://github.com/karatelabs/karate/actions/runs/9401298251/job/25892764841

https://hub.docker.com/layers/karatelabs/karate-chrome/1.5.0.RC5/images/sha256-59e8d14e3c0c3f53509f3abfd027e2194a8288679a02250f8501729f0a21a238

jandry commented 4 months ago

That's what I couldn't test locally. locally a default name was working. Maybe because of I didn't put the "karatelabs/" before all image names

I can't push to my pull request anymore as you merged it

I think we should adjust like follow to also push the version number for the first image tag and latest for second tag

docker buildx build --platform linux/amd64 --cache-from=type=local,src=./target/docker --cache-to=type=local,dest=./target/docker -t karatelabs/karate-chrome:${{ github.event.inputs.version }} -t karatelabs/karate-chrome:latest karate-docker/karate-chrome
# build karate-chromium docker image that includes karate fatjar + maven jars for convenience
# Both platform
docker buildx build --platform linux/amd64,linux/arm64 --cache-from=type=local,src=./target/docker --cache-to=type=local,dest=./target/docker -t karatelabs/karate-chromium:${{ github.event.inputs.version }} -t karatelabs/karate-chromium:latest karate-docker/karate-chromium
ptrthomas commented 4 months ago

@jandry please just open a new PR, because I don't know buildx and where to use the --push flag or if it is needed. I think you should be easily able to experiment with your personal docker account if needed

jandry commented 4 months ago

@ptrthomas done here https://github.com/karatelabs/karate/pull/2571

ptrthomas commented 4 months ago

@jandry sorry that's the wrong file. the change needs to be made in https://github.com/karatelabs/karate/blob/6f162bbb1a20e955a4b8b1ba82bb53196bdb833b/.github/workflows/maven-release.yml

I would have done it but I don't know the syntax as I said before. anyway I merged it and ran the CI job without realizing that nothing had changed

daviddavidgit commented 4 months ago

@ptrthomas I made the changes in the requested file, see #2573. Is it possible that you merge the PR and run the github action?

ptrthomas commented 4 months ago

@daviddavidgit failed with a different error :(

image

https://github.com/karatelabs/karate/actions/runs/9501098584/job/26185805847#step:7:233

ptrthomas commented 2 months ago

update: have reverted to old state, since we don't have a solution yet: https://github.com/karatelabs/karate/commit/351c4d27b63cc6a109262c4cac26f9ab96e5b962