Skip to content

Commit be4f4f5

Browse files
committed
chore(ci): run tests as root, install git
On GHA, tests that run in containers must use `root`[^1]. Otherwise, you don't have access to write in the workspace. For example, our tests failing couldn't write the `.t.err` files. Therefore, to use the `archlinux` container, we have to remove this test that was asserting errors when running as non-`root`. In testing that this would work, I used `sudo just test` locally, which ran into an unrelated error being unable to write in `/tmp`. This is probably solvable, but we never used that file, so I replaced it with `/dev/null`. Lastly, I installed `git` since I know we'll need that. [^1]: https://docs.github.com/en/actions/reference/workflows-and-actions/dockerfile-support#user
1 parent 6fa3f9a commit be4f4f5

File tree

3 files changed

+29
-24
lines changed

3 files changed

+29
-24
lines changed

.github/workflows/ci.yml

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,5 @@ jobs:
1616

1717
steps:
1818
- uses: actions/checkout@v6
19-
- run: pacman -Sy --needed --noconfirm just python-cram
20-
- run: |
21-
useradd ci
22-
runuser -u ci -- just test
19+
- run: pacman -Sy --needed --noconfirm git just python-cram
20+
- run: just test

test/main/one-choice.t

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ It doesn't present packages when there's only one choice
77
> DOWNGRADE_IGNORE=always
88
> DOWNGRADE_FROM_CACHE=1
99
> search_cache() { printf "%s\n" "$TMP/foo.pkg"; }
10-
> main foo 2>/tmp/downgradechoicelog; exit_code=$?
10+
> main foo 2>/dev/null; exit_code=$?
1111
> printf "ignore: %s\n" "${to_ignore[@]}"
1212
> printf "install: %s\n" "${to_install[@]}"
1313
> printf "exit code: %s\n" "$exit_code"

test/pacignore/parse_failure.t

Lines changed: 26 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -48,25 +48,32 @@ Check that pacignore fails if no argument provided
4848
[options]
4949
IgnorePkg = foo bar
5050

51-
Check that pacignore fails if no root access provided for add or rm
52-
53-
$ PACMAN_CONF="$(write_pacman_conf "[options]" "IgnorePkg = foo bar")"
54-
> pacignore add 2>&1
55-
> printf "exit_code=%s\n" "$?"
56-
> cat "$PACMAN_CONF"
57-
pacignore must be run as root for this subcommand
58-
exit_code=1
59-
[options]
60-
IgnorePkg = foo bar
61-
62-
$ PACMAN_CONF="$(write_pacman_conf "[options]" "IgnorePkg = foo bar")"
63-
> pacignore rm 2>&1
64-
> printf "exit_code=%s\n" "$?"
65-
> cat "$PACMAN_CONF"
66-
pacignore must be run as root for this subcommand
67-
exit_code=1
68-
[options]
69-
IgnorePkg = foo bar
51+
# TODO: Because CI is running on an archlinux container on GitHub Actions, the
52+
# tests must run as root there.
53+
#
54+
# https://docs.github.com/en/actions/reference/workflows-and-actions/dockerfile-support#user
55+
#
56+
# That means this test won't work there.
57+
#
58+
# Check that pacignore fails if no root access provided for add or rm
59+
#
60+
# $ PACMAN_CONF="$(write_pacman_conf "[options]" "IgnorePkg = foo bar")"
61+
# > pacignore add 2>&1
62+
# > printf "exit_code=%s\n" "$?"
63+
# > cat "$PACMAN_CONF"
64+
# pacignore must be run as root for this subcommand
65+
# exit_code=1
66+
# [options]
67+
# IgnorePkg = foo bar
68+
#
69+
# $ PACMAN_CONF="$(write_pacman_conf "[options]" "IgnorePkg = foo bar")"
70+
# > pacignore rm 2>&1
71+
# > printf "exit_code=%s\n" "$?"
72+
# > cat "$PACMAN_CONF"
73+
# pacignore must be run as root for this subcommand
74+
# exit_code=1
75+
# [options]
76+
# IgnorePkg = foo bar
7077

7178
Check that parsing fails if no package is package is specified for add or rm
7279

0 commit comments

Comments
 (0)