Skip to content

Commit

Permalink
ci: fix socketdir too long-error
Browse files Browse the repository at this point in the history
  • Loading branch information
christian-monch committed Nov 8, 2024
1 parent 962cf85 commit 41cf128
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 25 deletions.
4 changes: 2 additions & 2 deletions .appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,8 @@ for:
# verify that a PY variable is declared that identifies the desired Python version
# for this run
- "[ \"x$PY\" != x ]"
# create a dedicated socket directory to prevent too long socket names
- tools/appveyor/setup-gpg
# Missing system software
- tools/appveyor/install-syspkgs $INSTALL_SYSPKGS
# activate Python env solely to get `python` to become available consistently
Expand All @@ -152,8 +154,6 @@ for:
- tools/appveyor/install-git-annex ${INSTALL_GITANNEX}
# enable the git-annex provisioned by the installer
- "[ -f ${HOME}/dlinstaller_env.sh ] && . ${HOME}/dlinstaller_env.sh || true"
# start gpg-agent once to enable gpg imports in tests
- gpg-agent --daemon

test_script:
- 'hatch run tests.py${PY}:run-cov -s -v --doctest-modules --durations 10 -k "$KEYWORDS"'
Expand Down
25 changes: 2 additions & 23 deletions datalad_remake/annexremotes/tests/test_remake_remote.py
Original file line number Diff line number Diff line change
Expand Up @@ -174,25 +174,8 @@ def create_keypair(gpg_dir: Path, name: bytes = b'Test User'):
# unset $HOME to prevent accidental changes to the user's keyring
environment = {'HOME': '/dev/null'}

# start a gpg-agent
result = subprocess.run(
[
'gpg-agent',
'--homedir',
str(gpg_dir),
'--daemon',
],
env=environment,
capture_output=True,
)
print('STDOUT:', result.stdout)
print('STDERR:', result.stderr)
# ignore "gpg-agent already running"-error
if result.returncode not in (0, 2):
raise RuntimeError('Failed to start gpg-agent')

# use gpg to generate a keypair
result = subprocess.run(
subprocess.run(
[ # noqa: S607
'gpg',
'--batch',
Expand All @@ -204,13 +187,9 @@ def create_keypair(gpg_dir: Path, name: bytes = b'Test User'):
],
input=script,
capture_output=True,
#check=True,
check=True,
env=environment,
)
print('STDOUT:', result.stdout)
print('STDERR:', result.stderr)
if result.returncode not in (0, 2):
raise RuntimeError('Failed to generate key')

result = subprocess.run(
[ # noqa: S607
Expand Down
12 changes: 12 additions & 0 deletions tools/appveyor/setup-gpg
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#!/bin/bash
#
# Set up gpg to use a short socket directory name
#
set -e -u

if (which apt-get > /dev/null ); then
sudo mkdir -p /run/user/$(id -u)
sudo chmod 700 /run/user/$(id -u)
sudo chown $(id -u) /run/user/$(id -u)
gpgconf -v --create-socketdir
fi

0 comments on commit 41cf128

Please sign in to comment.