Skip to content

Commit

Permalink
Fix gix-url baseline script instead of taking ownership
Browse files Browse the repository at this point in the history
Taking ownership of cloned files in the container only fixed one
failing test, `gix-url::baseline run`. This had been failing with a
git `safe.directory` error in the the gix-url `make_baseline.sh`
fixture script. That failure was also reproduced locally by
recursively `chown`ing the cloned files to another user (while
preserving write permissions for the first user via the group).

Because the tests shouldn't unnecessarily depend on starting out in
a repository (nor anything about the outer repository they start
in), this should probably be considered a test bug that is not
specific to the current container setup on CI that triggered it.

This commit undoes the `chown -R` step in the CI workflow that had
previously worked around this, and instead fixes it by having the
gix-url `make_baseline.sh` fixture script run its `git fetch-pack`
commands in a temporary repo created in a subdirectory of the
fixture directory (and deleted afterwards).
  • Loading branch information
EliahKagan committed Nov 15, 2024
1 parent b8a23e7 commit da06fab
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 8 deletions.
6 changes: 0 additions & 6 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -180,12 +180,6 @@ jobs:
apt-get install --no-install-recommends -y -- "${prerequisites[@]}"
shell: bash
- uses: actions/checkout@v4
- name: Take ownership of repo
# FIXME: Eliminate the need for this by improving the test suite not to rely on ownership
# of preexisting files, nor on whether, where, or how we are contained in a repo (except
# where gix-testtools checks ignores to suppress archives). Note that `safe.directory`
# isn't a fix, due to config and environment sanitization when running fixture scripts.
run: chown -R "$(whoami)" -- "$GITHUB_WORKSPACE"
- uses: dtolnay/rust-toolchain@stable
with:
toolchain: stable-i686-unknown-linux-gnu # Otherwise it may misdetect based on the amd64 kernel.
Expand Down
11 changes: 9 additions & 2 deletions gix-url/tests/fixtures/make_baseline.sh
Original file line number Diff line number Diff line change
Expand Up @@ -55,14 +55,21 @@ tests_windows+=("c:repo")
tests_unix+=("${tests[@]}")
tests_windows+=("${tests[@]}")

# We will run `git fetch-pack` in this repo instead of the outer gitoxide repo,
# for full isolation. This avoids assuming there *is* a gitoxide repo, and also
# avoids `safe.directory` errors if the gitoxide repo has unusual ownership.
git init -q temp-repo

for url in "${tests_unix[@]}"
do
echo ";" # there are no `;` in the tested urls
git fetch-pack --diag-url "$url"
git -C temp-repo fetch-pack --diag-url "$url"
done >git-baseline.unix

for url in "${tests_windows[@]}"
do
echo ";" # there are no `;` in the tested urls
git fetch-pack --diag-url "$url"
git -C temp-repo fetch-pack --diag-url "$url"
done >git-baseline.windows

rm -rf temp-repo

0 comments on commit da06fab

Please sign in to comment.