diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index a8221589..5def7a0b 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -42,6 +42,15 @@ jobs: username: ${{ github.actor }} password: ${{ secrets.GITHUB_TOKEN }} + - name: Create cache directory + run: | + mkdir -p ./.buildx-cache/cache + mkdir ./.buildx-cache/cache-new + mkdir ./.buildx-cache/cache/test + mkdir ./.buildx-cache/cache/latest + mkdir ./.buildx-cache/cache-new/test + mkdir ./.buildx-cache/cache-new/latest + - name: Test build if: github.event_name == 'pull_request' uses: docker/build-push-action@v3 @@ -50,8 +59,8 @@ jobs: file: ./build/docker/agent/Dockerfile load: true tags: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME}}:test - cache-from: type=gha - cache-to: type=gha,mode=max + cache-from: type=local,src=./.buildx-cache/cache/test/ + cache-to: type=local,dest=./.buildx-cache/cache-new/test/,mode=max build-args: | USERNAME=paf USER_UID=1000 @@ -67,8 +76,8 @@ jobs: push: true # tag 'latest' and version on push to main, otherwise use the commit hash tags: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest - cache-from: type=gha - cache-to: type=gha,mode=max + cache-from: type=local,src=./.buildx-cache/cache/latest/ + cache-to: type=local,dest=./.buildx-cache/cache-new/latest/,mode=max build-args: | USERNAME=paf USER_UID=1000 @@ -85,4 +94,11 @@ jobs: uses: actions/upload-artifact@v4 with: name: pr_id - path: pr/ \ No newline at end of file + path: pr/ + retention-days: 1 + + - name: Clean up cache + run: | + rm -rf ./.buildx-cache/cache/test + rm -rf ./.buildx-cache/cache/latest + mv ./.buildx-cache/cache-new ./.buildx-cache/cache \ No newline at end of file diff --git a/.github/workflows/drive.yml b/.github/workflows/drive.yml index 5aa0733c..c8a23b83 100644 --- a/.github/workflows/drive.yml +++ b/.github/workflows/drive.yml @@ -32,6 +32,10 @@ jobs: let matchArtifact = allArtifacts.data.artifacts.filter((artifact) => { return artifact.name == "pr_id" })[0]; + if (!matchArtifact) { + core.setFailed('No pr_id artifact found from the build workflow'); + return; + } let download = await github.rest.actions.downloadArtifact({ owner: context.repo.owner, repo: context.repo.repo, @@ -42,12 +46,23 @@ jobs: fs.writeFileSync(`${process.env.GITHUB_WORKSPACE}/pr_id.zip`, Buffer.from(download.data)); - name: 'Unzip artifact (PR ID)' - run: unzip pr_id.zip + run: | + unzip pr_id.zip + + - name: Check PR ID + uses: actions/github-script@v6 + with: + script: | + let issue_number = fs.readFileSync('./pr_id'); + if (!issue_number || isNaN(Number(issue_number))) { + core.setFailed(`Invalid PR ID: ${prIdContent}`); + return; + } - name: Run docker-compose run: | xhost +local: - USERNAME=$(whoami) USER_UID=$(id -u) USER_GID=$(id -g) docker compose up --quiet-pull --exit-code-from agent + USERNAME=$(whoami) USER_UID=$(id -u) USER_GID=$(id -g) RENDER_OFFSCREEN=-RenderOffScreen 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 diff --git a/.vscode/settings.json b/.vscode/settings.json index 14b08a01..b83bfc4e 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -22,7 +22,7 @@ "docker.commands.composeUp": [ { "label": "Compose Up", - "template": "xhost +local: && USERNAME=$(whoami) USER_UID=$(id -u) USER_GID=$(id -g) ${composeCommand} ${configurationFile} up" + "template": "xhost +local: && USERNAME=$(whoami) USER_UID=$(id -u) USER_GID=$(id -g) RENDER_OFFSCREEN= ${composeCommand} ${configurationFile} up" } ], "workbench.iconTheme": "vscode-icons", diff --git a/build/docker-compose.carla-simulator.yaml b/build/docker-compose.carla-simulator.yaml index 9106806f..2fe43d31 100644 --- a/build/docker-compose.carla-simulator.yaml +++ b/build/docker-compose.carla-simulator.yaml @@ -1,7 +1,7 @@ services: # based on https://github.com/ll7/paf21-1/blob/master/scenarios/docker-carla-sim-compose.yml carla-simulator: - command: /bin/bash CarlaUE4.sh -quality-level=Epic -world-port=2000 -resx=800 -resy=600 -nosound -carla-settings="/home/carla/CarlaUE4/Config/CustomCarlaSettings.ini" + command: /bin/bash CarlaUE4.sh -quality-level=Epic -world-port=2000 -resx=800 -resy=600 -nosound -carla-settings="/home/carla/CarlaUE4/Config/CustomCarlaSettings.ini" ${RENDER_OFFSCREEN} image: ghcr.io/una-auxme/paf23:leaderboard-2.0 init: true deploy: