TYPO3BestPractices / tea

Example extension for unit testing and best practices.
https://typo3.org/community/teams/best-practices
GNU General Public License v2.0
78 stars 26 forks source link

Generate Docs failed on MacBook Pro #1490

Open linxpinx opened 1 month ago

linxpinx commented 1 month ago

./Build/Scripts/runTests.sh -s docsGenerate failed on MacBook Pro.

Acceptance Criteria

Additional Information

Errormessage:

adduser: unknown group typo3
su: unknown user typo3
oliverklee commented 1 month ago

If I remember, I encountered a similar problem on my machine quite some time ago.

Are you using Docker or Podman?

linxpinx commented 1 month ago

Hi Oli, I use https://github.com/abiosoft/colima. But I can try with docker.

linxpinx commented 1 month ago

Ok i checked it with docker and it works with or without my changes. So I think we can take my changes into the code.

We also have the composer docs:generate command in the composer.json and in the Documentation.rst.

Maybe we can discuss this with the team.

sbuerk commented 1 month ago

Is the group identifier really needed ?

Literally, instead of adding it dirctly to the command call following check should be investigated:

https://github.com/FriendsOfTYPO3/tea/blob/9a8834998f383cddae7fe58666e739ed8983cca1/Build/Scripts/runTests.sh#L437-L440

if [ "$(uname)" != "Darwin" ] && [ "${CONTAINER_BIN}" == "docker" ]; then
    # Run docker jobs as current user to prevent permission issues. Not needed with podman.
    USERSET="--user $HOST_UID"
fi

First, does the condition not work on your side and leaves USERSET empty ?

I would suggest to add a "DOCUMENTATION_USERSET" here in the condition setting the user along and replace ${USERSET} for the conrainer execution (run) call.

Not sure about the impact doing it in USERSET directly which are used for all container executions. At least should be checked for all if the group is added. In the end, should only target for macos and docker usage (docker command available).

linxpinx commented 1 month ago

The group is needed otherwise the Rendering Process is not working.

First, does the condition not work on your side and leaves USERSET empty ? yes USERSET is empty cause I have a Mac, so Darwin is true.

I added this in runTests.sh:

if [ "$(uname)" != "Darwin" ] && [ "${CONTAINER_BIN}" == "docker" ]; then
    # Run docker jobs as current user to prevent permission issues. Not needed with podman.
    USERSET="--user $HOST_UID"
    elif [ "$(uname)" == "Darwin" ] && [ "${CONTAINER_BIN}" == "docker" ]; then
        USERSET="--user=$(id -u):$(id -g)"
fi

and extend the composer command: "docs:generate": "docker run --rm --user=$(id -u):$(id -g) -v $(pwd):/project ghcr.io/typo3-documentation/render-guides:latest --progress --config ./Documentation", and tested the other commands in runTests.sh where USERSET is used, works on Mac and Colima.

Maybe Windows/Linux can tested by someone else.

garvinhicking commented 1 month ago

Please note that for the render-guide repository the entrypoint of the Docker file:

https://github.com/TYPO3-Documentation/render-guides/blob/main/entrypoint.sh#L107

does some "magic" to try unifying the system to work on macos, windows and linux due the specialties of Docker in each of them.

We're open to optimizing this, if anyone has ideas on how it should be done so it works accross all systems without too much if-conditions ;)

garvinhicking commented 1 month ago

(Please note that in https://docs.typo3.org/other/t3docs/render-guides/main/en-us/Installation/Index.html#Setup_Docker we actually have a place that mentions this --user... command argument. Still, it would be great to somehow detect this properly within the container)