Skip to content

Commit afa5754

Browse files
authored
Merge pull request #1826 from EliahKagan/docker
Test in Docker with Alpine Linux on CI
2 parents 1f37b48 + 4b427c9 commit afa5754

File tree

2 files changed

+75
-1
lines changed

2 files changed

+75
-1
lines changed

.github/workflows/alpine-test.yml

+72
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
name: test-alpine
2+
3+
on: [push, pull_request, workflow_dispatch]
4+
5+
jobs:
6+
build:
7+
runs-on: ubuntu-latest
8+
9+
container:
10+
image: alpine:latest
11+
12+
defaults:
13+
run:
14+
shell: sudo -u runner sh -exo pipefail {0}
15+
16+
steps:
17+
- name: Prepare Alpine Linux
18+
run: |
19+
apk add sudo git git-daemon python3 py3-pip
20+
echo 'Defaults env_keep += "CI GITHUB_* RUNNER_*"' >/etc/sudoers.d/ci_env
21+
addgroup -g 127 docker
22+
adduser -D -u 1001 runner
23+
adduser runner docker
24+
shell: sh -exo pipefail {0} # Run this as root, not the "runner" user.
25+
26+
- uses: actions/checkout@v4
27+
with:
28+
fetch-depth: 0
29+
30+
- name: Set workspace ownership
31+
run: |
32+
chown -R runner:docker -- "$GITHUB_WORKSPACE"
33+
shell: sh -exo pipefail {0} # Run this as root, not the "runner" user.
34+
35+
- name: Prepare this repo for tests
36+
run: |
37+
./init-tests-after-clone.sh
38+
39+
- name: Set git user identity and command aliases for the tests
40+
run: |
41+
git config --global user.email "travis@ci.com"
42+
git config --global user.name "Travis Runner"
43+
# If we rewrite the user's config by accident, we will mess it up
44+
# and cause subsequent tests to fail
45+
cat test/fixtures/.gitconfig >> ~/.gitconfig
46+
47+
- name: Set up virtualenv
48+
run: |
49+
python -m venv .venv
50+
. .venv/bin/activate
51+
printf '%s=%s\n' 'PATH' "$PATH" 'VIRTUAL_ENV' "$VIRTUAL_ENV" >>"$GITHUB_ENV"
52+
53+
- name: Update PyPA packages
54+
run: |
55+
# Get the latest pip, wheel, and prior to Python 3.12, setuptools.
56+
python -m pip install -U pip $(pip freeze --all | grep -ow ^setuptools) wheel
57+
58+
- name: Install project and test dependencies
59+
run: |
60+
pip install ".[test]"
61+
62+
- name: Show version and platform information
63+
run: |
64+
uname -a
65+
command -v git python
66+
git version
67+
python --version
68+
python -c 'import os, sys; print(f"sys.platform={sys.platform!r}, os.name={os.name!r}")'
69+
70+
- name: Test with pytest
71+
run: |
72+
pytest --color=yes -p no:sugar --instafail -vv

test/test_util.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,9 @@ def permission_error_tmpdir(tmp_path):
5151
# Set up PermissionError on Windows, where we can't delete read-only files.
5252
(td / "x").chmod(stat.S_IRUSR)
5353

54-
# Set up PermissionError on Unix, where we can't delete files in read-only directories.
54+
# Set up PermissionError on Unix, where non-root users can't delete files in
55+
# read-only directories. (Tests that rely on this and assert that rmtree raises
56+
# PermissionError will fail if they are run as root.)
5557
td.chmod(stat.S_IRUSR | stat.S_IXUSR)
5658

5759
yield td

0 commit comments

Comments
 (0)