From 1f21d383159c782282fcfdf34f39d4b1e14cb6b6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ond=C5=99ej=20Budai?= Date: Mon, 2 Jan 2023 16:19:59 +0100 Subject: [PATCH] workflows: mark the working directory safe for git MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Github actions have a peculiar behaviour: The "job root" directory is owned by user with ID 1001 whereas many containers (like the Fedora one) run as root by default. This causes git to freak out because repositories owned by different users aren't considered safe anymore and must be explicitly allow- listed. This becomes a problem when we switch to Go 1.18 because it stamps build with Git information which fails because the repository technically isn't safe. Let's fix this by marking the repository as a safe one. Note that the actions/checkout action has a set-safe-directory feature, but this one is not permanent. After the action is done, the setting is removed. See https://github.com/actions/checkout/pull/762 Signed-off-by: Ondřej Budai --- .github/workflows/tests.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 5d0a604d79..de4153de99 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -29,6 +29,9 @@ jobs: with: ref: ${{ github.event.pull_request.head.sha }} + - name: Mark the working directory as safe for git + run: git config --global --add safe.directory "$(pwd)" + - name: Run unit tests run: go test -race -covermode=atomic -coverprofile=coverage.txt -coverpkg=$(go list ./... | grep -v rpmmd/test$ | tr "\n" ",") ./...