Skip to content

Commit

Permalink
workflows: mark the working directory safe for git
Browse files Browse the repository at this point in the history
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 actions/checkout#762

Signed-off-by: Ondřej Budai <ondrej@budai.cz>
  • Loading branch information
ondrejbudai committed Jan 6, 2023
1 parent 1f78290 commit 8c4689f
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .github/workflows/tests.yml
Expand Up @@ -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" ",") ./...

Expand Down

0 comments on commit 8c4689f

Please sign in to comment.