From f01db34038e41af6ab1efd2dc318622a912794cb Mon Sep 17 00:00:00 2001 From: JulianTrommer Date: Wed, 23 Oct 2024 16:49:10 +0200 Subject: [PATCH 1/2] First attempt at fixing the drive action --- .github/workflows/drive.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/drive.yml b/.github/workflows/drive.yml index 3b2940e9..eccd62bf 100644 --- a/.github/workflows/drive.yml +++ b/.github/workflows/drive.yml @@ -21,7 +21,9 @@ jobs: echo "AGENT_VERSION=${AGENT_VERSION}" echo "COMPOSE_FILE=${COMPOSE_FILE}" - name: Run docker-compose - run: docker compose up --quiet-pull --exit-code-from agent + run: | + xhost +local: + USERNAME=$(whoami) USER_UID=$(id -u) USER_GID=$(id -g) docker compose up --quiet-pull --exit-code-from agent - name: Copy results run: docker compose cp agent:/tmp/simulation_results.json . - name: Stop docker-compose From 5aa49df065c6679f2ea782015657906d4f6215e5 Mon Sep 17 00:00:00 2001 From: JulianTrommer Date: Thu, 24 Oct 2024 09:33:21 +0200 Subject: [PATCH 2/2] Fixed simulation results comment --- .github/workflows/build.yml | 13 +++++++++++++ .github/workflows/drive.yml | 27 ++++++++++++++++++++++++++- 2 files changed, 39 insertions(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 6dbf6165..a8221589 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -73,3 +73,16 @@ jobs: USERNAME=paf USER_UID=1000 USER_GID=1000 + + - name: Save PR ID + env: + PR_ID: ${{ github.event.number }} + run: | + mkdir -p ./pr + echo $PR_ID > ./pr/pr_id + + - name: Upload PR ID + uses: actions/upload-artifact@v4 + with: + name: pr_id + path: pr/ \ No newline at end of file diff --git a/.github/workflows/drive.yml b/.github/workflows/drive.yml index eccd62bf..5aa0733c 100644 --- a/.github/workflows/drive.yml +++ b/.github/workflows/drive.yml @@ -20,6 +20,30 @@ jobs: run: | echo "AGENT_VERSION=${AGENT_VERSION}" echo "COMPOSE_FILE=${COMPOSE_FILE}" + - name: 'Download artifact (PR ID)' + uses: actions/github-script@v6 + with: + script: | + let allArtifacts = await github.rest.actions.listWorkflowRunArtifacts({ + owner: context.repo.owner, + repo: context.repo.repo, + run_id: context.payload.workflow_run.id, + }); + let matchArtifact = allArtifacts.data.artifacts.filter((artifact) => { + return artifact.name == "pr_id" + })[0]; + let download = await github.rest.actions.downloadArtifact({ + owner: context.repo.owner, + repo: context.repo.repo, + artifact_id: matchArtifact.id, + archive_format: 'zip', + }); + let fs = require('fs'); + fs.writeFileSync(`${process.env.GITHUB_WORKSPACE}/pr_id.zip`, Buffer.from(download.data)); + + - name: 'Unzip artifact (PR ID)' + run: unzip pr_id.zip + - name: Run docker-compose run: | xhost +local: @@ -52,8 +76,9 @@ jobs: // add everything to the resultsTable resultsTable = resultsTableHeader + '\n' + resultsTableDivider + '\n' + resultsTable.join('\n'); // add the results as a comment to the pull request + let issue_number = Number(fs.readFileSync('./pr_id')); github.rest.issues.createComment({ - issue_number: context.issue.number, + issue_number: issue_number, owner: context.repo.owner, repo: context.repo.repo, body: "## Simulation results\n" + resultsTable