Skip to content

feat: check if required binaries are present#272

Merged
nikola-jokic merged 4 commits intoactions:mainfrom
vvanouytsel-trendminer:main
Nov 10, 2025
Merged

feat: check if required binaries are present#272
nikola-jokic merged 4 commits intoactions:mainfrom
vvanouytsel-trendminer:main

Conversation

@vvanouytsel-trendminer
Copy link
Copy Markdown
Contributor

This closes #271 and #266.

Previously the necessary binaries were copied over using the runner container. This lead to issues in case your main container was using the musl libc implementation.

Instead of copying over any binaries, the initContainer now checks if the required binaries are present in the main container.

Previously the necessary binaries were copied over using the runner
container. This lead to issues in case your main container was using the
musl libc implementation.

Instead of copying over any binaries, the initContainer now checks if
the required binaries are present in the main container.
Comment thread packages/k8s/src/k8s/index.ts
rm "$0" # remove script after running
mv /__w/_temp/_github_home /github/home && \
mv /__w/_temp/_github_workflow /github/workflow && \
mv /__w/_temp/_runner_file_commands /github/file_commands && \
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why remove this?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The /__w/_temp/_runner_file_commands directory did not exist when I was testing this via container actions, which resulted in the mv command failing.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What we can do is not fail if it doesn't exist, but this _runner_file_commands is the one containing add_path and other functionalities
I'm not sure why it wasn't present, that is strange
Do you have maybe something I could use to reproduce it?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I will add it again and double check if my findings were correct last week. (It was a busy day).

If the issue still persists I can provide you with something to reproduce it.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've added the moving of the _runner_file_commands again and the issues pops up.

name: Attempt test staging
on:
  workflow_dispatch:
jobs:
  staging-test2:
    name: "[STG] Container action via staging runner"
    runs-on: default-staging
    container: my-registry/tm-gha-base:v3 # Just an ubuntu based container running as root
    steps:
      - uses: TrendMiner/tm-actions-commit-lint@v2

The tm-actions-commit-lint action is in a private organization so you will have to use a different action. But basically any container based action should result in this error.

Here is the action.yml of that action.

---
name: Commit Lint Action
description: |
  Lints commit messages using commitlint.
  For push events, it lints the latest commit.
  For pull request events, it lints all commits from base to head.

  It is important to note that this action needs to be run in a job where your repository is checked out.
  The action requires your full git history to be available. You can do that by using the 'fetch-depth: 0' option.

  - name: Checkout repository
    uses: actions/checkout@x.y.z
    with:
          fetch-depth: 0

inputs:
  event_name:
    description: "GitHub event name"
    default: ${{ github.event_name }}
  base_sha:
    description: "Base SHA for pull request events"
    default: ${{ github.event.pull_request.base.sha }}
  head_sha:
    description: "Head SHA for pull request events"
    default: ${{ github.event.pull_request.head.sha }}

runs:
  using: docker
  entrypoint: /entrypoint.sh
  image: "docker://my-repo/tm-commitlint:3.0.0"
  args:
    - ${{ inputs.event_name }}
    - ${{ inputs.base_sha }}
    - ${{ inputs.head_sha }}

Below is the output from attempting to run the workflow.

Run '/home/runner/k8s/index.js'
##[debug]/home/runner/externals/node20/bin/node /home/runner/k8s/index.js
##[debug]Copying files from pod default-staging-b9kr6-runner-d94br-workflow to /home/runner/_work/tm-pnt-dummy/tm-pnt-dummy
##[debug]Copying from pod default-staging-b9kr6-runner-d94br-workflow /__w to /home/runner/_work/__w
##[debug]internalExecOutput response: {"metadata":{},"status":"Success"}
(node:105) [DEP0005] DeprecationWarning: Buffer() is deprecated due to security and usability issues. Please use the Buffer.alloc(), Buffer.allocUnsafe(), or Buffer.from() methods instead.
(Use `node --trace-deprecation ...` to show where the warning was created)
##[debug]Attempt 1 failed: Error: child process exited with code 2
##[debug]Writing container step script to /home/runner/_work/__w/_temp/fb8735f0-be32-11f0-84c4-6d00f3e880f5.sh
##[debug]Copying /home/runner/_work/__w to pod default-staging-b9kr6-runner-d94br-step-6e5aa24e at /__w
##[debug]internalExecOutput response: {"metadata":{},"status":"Success"}
##[debug]Executing container step script in pod default-staging-b9kr6-runner-d94br-step-6e5aa24e
##[debug]execPodStep response: {"metadata":{},"status":"Failure","message":"command terminated with non-zero exit code: command terminated with exit code 1","reason":"NonZeroExitCode","details":{"causes":[{"reason":"ExitCode","message":"1"}]}}
##[debug]{"message":"command terminated with non-zero exit code: command terminated with exit code 1","details":{"causes":[{"reason":"ExitCode","message":"1"}]}}
mv: can't rename '/__w/_temp/_runner_file_commands': No such file or directory
##[debug]execPodStep failed: {}
Error: Failed to run container step: Error: failed to run script step: Error: command terminated with non-zero exit code: command terminated with exit code 1
Error: Error: failed to run script step: Error: command terminated with non-zero exit code: command terminated with exit code 1
Error: Process completed with exit code 1.
Error: Executing the custom container implementation failed. Please contact your self hosted runner administrator.
##[debug]System.Exception: Executing the custom container implementation failed. Please contact your self hosted runner administrator.
##[debug] ---> System.Exception: The hook script at '/home/runner/k8s/index.js' running command 'RunContainerStep' did not execute successfully
##[debug]   at GitHub.Runner.Worker.Container.ContainerHooks.ContainerHookManager.ExecuteHookScript[T](IExecutionContext context, HookInput input, ActionRunStage stage, String prependPath)
##[debug]   --- End of inner exception stack trace ---
##[debug]   at GitHub.Runner.Worker.Container.ContainerHooks.ContainerHookManager.ExecuteHookScript[T](IExecutionContext context, HookInput input, ActionRunStage stage, String prependPath)
##[debug]   at GitHub.Runner.Worker.Container.ContainerHooks.ContainerHookManager.RunContainerStepAsync(IExecutionContext context, ContainerInfo container, String dockerFile)
##[debug]   at GitHub.Runner.Worker.Handlers.ContainerActionHandler.RunAsync(ActionRunStage stage)
##[debug]   at GitHub.Runner.Worker.ActionRunner.RunAsync()
##[debug]   at GitHub.Runner.Worker.StepsRunner.RunStepAsync(IStep step, CancellationToken jobCancellationToken)
##[debug]Finishing: Run tm-actions-commit-lint

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I say leave it in, and we can create a separate PR fixing this issue.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've added it back, but prevented it from failing, if that is okay for you.

@vvanouytsel-trendminer
Copy link
Copy Markdown
Contributor Author

I wonder if we should also check (and fail) if find is not present.
Since it is also being used:

export function listDirAllCommand(dir: string): string {
return `cd ${shlex.quote(dir)} && find . -not -path '*/_runner_hook_responses*' -exec stat -c '%b %n' {} \\;`
}

Even though the action does not fail, it probably might be a good idea to also make sure that find is in the container, or we should get rid of the find command being used.

Run TrendMiner/tm-actions-mvn-spotless@v1
Run actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8
Run '/home/runner/k8s/index.js'
(node:225) [DEP0005] DeprecationWarning: Buffer() is deprecated due to security and usability issues. Please use the Buffer.alloc(), Buffer.allocUnsafe(), or Buffer.from() methods instead.
(Use `node --trace-deprecation ...` to show where the warning was created)
sh: line 1: find: command not found
sh: line 1: find: command not found
sh: line 1: find: command not found
sh: line 1: find: command not found
sh: line 1: find: command not found
sh: line 1: find: command not found
sh: line 1: find: command not found
sh: line 1: find: command not found
sh: line 1: find: command not found
sh: line 1: find: command not found
sh: line 1: find: command not found
sh: line 1: find: command not found
sh: line 1: find: command not found
sh: line 1: find: command not found
sh: line 1: find: command not found
GITHUB_EVENT_PATH /github/workflow/event.json does not exist
GITHUB_EVENT_PATH /github/workflow/event.json does not exist
Syncing repository: TrendMiner/tm-example
Getting Git version info
Temporarily overriding HOME='/__w/_temp/44edf1c7-1a75-4851-85bc-df454d9a80ef' before making global git config changes
Adding repository directory to the temporary git global config as a safe directory

@vvanouytsel-trendminer vvanouytsel-trendminer marked this pull request as draft November 10, 2025 12:08
@vvanouytsel-trendminer vvanouytsel-trendminer marked this pull request as ready for review November 10, 2025 13:27
Copy link
Copy Markdown
Collaborator

@nikola-jokic nikola-jokic left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, Thanks!

@nikola-jokic nikola-jokic merged commit ad9cb43 into actions:main Nov 10, 2025
5 checks passed
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.

Container actions that use the musl libc implementation do not work in v0.8.0

2 participants