Skip to content
New issue

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

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

Already on GitHub? # to your account

feat: compatibility with self-hosted runners with SELinux #355

Merged
merged 6 commits into from
Mar 11, 2022
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Ensure folders are created
paulpach committed Mar 11, 2022
commit 777186b015249c0530a22d831b3454302172d9c3
11 changes: 9 additions & 2 deletions src/model/docker.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import { exec } from '@actions/exec';
import ImageTag from './image-tag';
import ImageEnvironmentFactory from './image-environment-factory';
import { existsSync, mkdirSync } from 'fs';
import { join } from 'path';

class Docker {
static async build(buildParameters, silent = false) {
@@ -42,12 +44,17 @@ class Docker {
static getBaseOsSpecificArguments(baseOs, workspace, unitySerial, runnerTemporaryPath, sshAgent): string {
switch (baseOs) {
case 'linux':
const github_home = join(runnerTemporaryPath, "_github_home");
existsSync(github_home) || mkdirSync(github_home);
const github_workflow = join(runnerTemporaryPath, "_github_workflow");
existsSync(github_workflow) || mkdirSync(github_workflow);
Copy link
Member

Choose a reason for hiding this comment

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

I believe these directories should exist according to the spec. Could you explain a little bit about why this is needed?

Also prefer the more semantic if(condition) // do something over || which makes the code harder to read for new developers

Copy link
Contributor Author

@paulpach paulpach Mar 11, 2022

Choose a reason for hiding this comment

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

They do exist in github runners, but when running in self-hosted runners, the _temp folder is completely empty.

I get this error:

Error: statfs /var/github/_temp/_github_home: no such file or directory
Error: The process '/usr/bin/docker' failed with exit code 125

I worked around the problem by doing this in my workflow:

      # this is a workaround for self hosted runners
      - name: Create Folders
        run: |
          cd $RUNNER_TEMP
          mkdir -p _github_home
          mkdir -p _github_workflow
      - uses: game-ci/unity-builder@v2
        env:
          UNITY_LICENSE: ${{ secrets.UNITY_LICENSE }}
          UNITY_EMAIL: ${{ secrets.UNITY_EMAIL }}
          UNITY_PASSWORD: ${{ secrets.UNITY_PASSWORD }}
        with:
          targetPlatform: StandaloneLinux64
          buildMethod: com.mindblocks.build.BuildAutomation.LinuxServer

and that worked.

I will change them to if


return `--env UNITY_SERIAL \
--env GITHUB_WORKSPACE=/github/workspace \
${sshAgent ? '--env SSH_AUTH_SOCK=/ssh-agent' : ''} \
--volume "/var/run/docker.sock":"/var/run/docker.sock:z" \
--volume "${runnerTemporaryPath}/_github_home":"/root:z" \
--volume "${runnerTemporaryPath}/_github_workflow":"/github/workflow:z" \
--volume "${github_home}":"/root:z" \
--volume "${github_workflow}":"/github/workflow:z" \
--volume "${workspace}":"/github/workspace:z" \
${sshAgent ? `--volume ${sshAgent}:/ssh-agent` : ''} \
${sshAgent ? '--volume /home/runner/.ssh/known_hosts:/root/.ssh/known_hosts:ro' : ''}`;