Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use Dockerfile and script for building in container instead of running the entire job in the container #34

Draft
wants to merge 25 commits into
base: master
Choose a base branch
from

Conversation

SonicGDX
Copy link

@SonicGDX SonicGDX commented Nov 27, 2024

As I mentioned in #23 and in libgdx/libgdx#7477, the upload-artifact and download-artifact@v3 versions will be deprecated on November 30th. As v4 and v5 require node 20, when this happens it will break the existing linux job that uses a docker container for the whole job as the container uses glibc 2.17 which doesn't work with node 20.

This isn't fully ready yet, but I've changed the setup so that hopefully it continues to work with newer versions of actions like upload-artifact and setup-java. I've done this by moving the docker setup into its own action (which is local to the repo) that runs a script in the container that builds the natives and snapshots, but doesn't use any third party actions - meaning it should not be need node 20 to be used in the container.

Inspired by https://docs.github.com/en/actions/sharing-automations/creating-actions/creating-a-docker-container-action#introduction

The action does seem to run properly but of course I haven't tested it fully and there could be other issues with it.

I thought the action name could be anything, but apparently it has to be action.yml. I created an actions folder just to make it clearer that this is an action, not a workflow
Used cd in a weird way but if it works it works
Few mistakes I made while porting over the code
Need it for the snapshot and publish outside the docker container
…build finishes

Caused by gradle files being left behind by the docker container. Having to install gradle two times for the linux job is a bit unclean, though.

Also added no-daemon to the gradle task used because only one gradle command is being executed in the docker container.
Using apt-get because apparently apt does not have a stable CLI interface. While apt install is probably safe, using apt-get will prevent the warnings in the log at least.

See https://askubuntu.com/a/990838

As for sudo, while it's not needed sudo also doesn't cause any harm and those commands technically do need root permissions and using sudo makes that clear.
Seems the zulu package I'm adding pulls in x11 which is unnecessary as we are running this in a headless setting.
Can't use sudo as the start as it needs to be installed first... so I just decided to not use sudo at all if it's not needed. But I'll keep the package install of sudo in case some other command needs it
We're installing zulu, so I don't think this is needed.
Hopefully this fixes the "Unable to delete directory build/generated/sources/annotationProcessor/java/main" error

Not using a daemon still because it's only two tasks.
Probably needed for the deploy to work properly. Honestly maybe I could move the deploy into the docker container but thing is it'd require passing in the secrets
@SonicGDX
Copy link
Author

How it works is that when it enters the docker container, the working directory is mounted and mapped from the runner onto the container. So the runner does all the GitHub actions to clone/setup the repo and then enters the container to build the natives and snapshot. After the container exits the changes persist on the runner and the runner uploads the artifacts and deploys the snapshot.

@SonicGDX SonicGDX changed the title Use Dockerfile and script for build instead of running job in container Use Dockerfile and script for building in container instead of running the entire job in the container Nov 27, 2024
No longer doing it in multiple steps, so adding it to GITHUB_ENV won't really do anything, if it even works in the docker container right now which it probably doesn't.
Hopefully should prevent java 11 JRE from being installed, as zulu should provide what maven and ant needs.

Also specified default find path as recommended by https://github.com/koalaman/shellcheck/wiki/SC2185
The log seems to be massive for the docker step so hopefully this reduces it a bit.
Strangely I got an error while trying to download an artifact for no reason. So maybe updating actions could help? Either way we should be good to do this now that the job is no longer being run in a docker container with glibc 2.17

May need to audit these actions though.
The new setup-gradle seems to validate the wrappers, but strangely the wrappers from the sdl submodule fail to verify for some reason.
From TheOfficialGman's response to my questions here:
libgdx#23 (comment)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant