From 942f6122975faf27eb0977130721a0cdc37948c8 Mon Sep 17 00:00:00 2001 From: A5rocks Date: Tue, 23 Jan 2024 01:04:00 +0900 Subject: [PATCH 1/6] Try running an Alpine Linux CI job --- .github/workflows/ci.yml | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 02dda87953..ff00d28b54 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -179,6 +179,26 @@ jobs: name: macOS (${{ matrix.python }}) flags: macOS,${{ matrix.python }} + # run CI on a musl linux + Alpine: + name: "Alpine" + runs-on: ubuntu-latest + container: python:alpine + steps: + - name: Checkout + uses: actions/checkout@v3 + - name: Install necessary packages + run: apk update && apk add bash + - name: Run tests + run: ./ci.sh + - if: always() + uses: codecov/codecov-action@v3 + with: + directory: empty + token: 87cefb17-c44b-4f2f-8b30-1fff5769ce46 + name: Alpine + flags: Alpine,3.12 + # https://github.com/marketplace/actions/alls-green#why check: # This job does nothing and is only used for the branch protection @@ -188,6 +208,7 @@ jobs: - Windows - Ubuntu - macOS + - Alpine runs-on: ubuntu-latest From e9846f0b8eed58f9bcff54569f9e08143ead90df Mon Sep 17 00:00:00 2001 From: A5rocks Date: Tue, 23 Jan 2024 01:39:02 +0900 Subject: [PATCH 2/6] Fix pyright test --- .github/workflows/ci.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index ff00d28b54..5a649d6c22 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -188,7 +188,8 @@ jobs: - name: Checkout uses: actions/checkout@v3 - name: Install necessary packages - run: apk update && apk add bash + run: apk update && apk add bash nodejs + - run: pip install pyright && pyright --version - name: Run tests run: ./ci.sh - if: always() From 0766698dc343ab3778cee39fb3d38262f048a667 Mon Sep 17 00:00:00 2001 From: A5rocks Date: Tue, 23 Jan 2024 01:57:33 +0900 Subject: [PATCH 3/6] Try fixing tests for thread name and getaddrinfo errno --- .github/workflows/ci.yml | 2 +- src/trio/_tests/test_socket.py | 3 +++ src/trio/_tests/test_threads.py | 2 +- 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 5a649d6c22..661280d2ba 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -188,7 +188,7 @@ jobs: - name: Checkout uses: actions/checkout@v3 - name: Install necessary packages - run: apk update && apk add bash nodejs + run: apk update && apk add bash nodejs musl-dev - run: pip install pyright && pyright --version - name: Run tests run: ./ci.sh diff --git a/src/trio/_tests/test_socket.py b/src/trio/_tests/test_socket.py index bce3971b35..0b3a72055b 100644 --- a/src/trio/_tests/test_socket.py +++ b/src/trio/_tests/test_socket.py @@ -629,6 +629,9 @@ async def res( # Linux if hasattr(tsocket, "EAI_ADDRFAMILY"): expected_errnos.add(tsocket.EAI_ADDRFAMILY) + # musl libc + if hasattr(tsocket, "EAI_NODATA"): + expected_errnos.add(tsocket.EAI_NODATA) assert excinfo.value.errno in expected_errnos # A family where we know nothing about the addresses, so should just diff --git a/src/trio/_tests/test_threads.py b/src/trio/_tests/test_threads.py index aefb4ba27b..6ca455d177 100644 --- a/src/trio/_tests/test_threads.py +++ b/src/trio/_tests/test_threads.py @@ -237,7 +237,7 @@ def _get_thread_name(ident: int | None = None) -> str | None: libpthread_path = ctypes.util.find_library("pthread") if not libpthread_path: - print(f"no pthread on {sys.platform})") + print(f"no pthread on {sys.platform}") return None libpthread = ctypes.CDLL(libpthread_path) From 1c90784925c1f9bf3d5a3b6d784dab29ae1b7da3 Mon Sep 17 00:00:00 2001 From: A5rocks Date: Tue, 23 Jan 2024 02:02:34 +0900 Subject: [PATCH 4/6] More fixes --- .github/workflows/ci.yml | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 661280d2ba..7cc7594e63 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -183,13 +183,12 @@ jobs: Alpine: name: "Alpine" runs-on: ubuntu-latest - container: python:alpine + container: alpine steps: - name: Checkout uses: actions/checkout@v3 - name: Install necessary packages - run: apk update && apk add bash nodejs musl-dev - - run: pip install pyright && pyright --version + run: apk update && apk add python3-dev bash nodejs musl-dev - name: Run tests run: ./ci.sh - if: always() From 2a56b96df3799cc5aef32e1a041e3ae19c034ffc Mon Sep 17 00:00:00 2001 From: A5rocks Date: Tue, 23 Jan 2024 02:07:15 +0900 Subject: [PATCH 5/6] Ensure we have pip --- .github/workflows/ci.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 7cc7594e63..a348968085 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -189,8 +189,10 @@ jobs: uses: actions/checkout@v3 - name: Install necessary packages run: apk update && apk add python3-dev bash nodejs musl-dev + - name: Enter virtual environment + run: python -m venv .venv - name: Run tests - run: ./ci.sh + run: source .venv/bin/activate && ./ci.sh - if: always() uses: codecov/codecov-action@v3 with: From b435753b52f7f9bf9cbd9c854233fa44a8513b14 Mon Sep 17 00:00:00 2001 From: EXPLOSION Date: Mon, 29 Jan 2024 23:11:49 -0500 Subject: [PATCH 6/6] PR review --- .github/workflows/ci.yml | 5 ++++- src/trio/_tests/test_socket.py | 7 ++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index a348968085..fabc57b9c2 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -188,7 +188,10 @@ jobs: - name: Checkout uses: actions/checkout@v3 - name: Install necessary packages - run: apk update && apk add python3-dev bash nodejs musl-dev + # can't use setup-python because that python doesn't seem to work; + # `python3-dev` (rather than `python:alpine`) for some ctypes reason, + # `nodejs` for pyright (`node-env` pulls in nodejs but that takes a while and can time out the test). + run: apk update && apk add python3-dev bash nodejs - name: Enter virtual environment run: python -m venv .venv - name: Run tests diff --git a/src/trio/_tests/test_socket.py b/src/trio/_tests/test_socket.py index 9cf197e073..20841172bb 100644 --- a/src/trio/_tests/test_socket.py +++ b/src/trio/_tests/test_socket.py @@ -624,14 +624,11 @@ async def res( sock.setsockopt(tsocket.IPPROTO_IPV6, tsocket.IPV6_V6ONLY, True) with pytest.raises(tsocket.gaierror) as excinfo: await res(("1.2.3.4", 80)) - # Windows, macOS - expected_errnos = {tsocket.EAI_NONAME} + # Windows, macOS, musl/Linux + expected_errnos = {tsocket.EAI_NONAME, tsocket.EAI_NODATA} # Linux if hasattr(tsocket, "EAI_ADDRFAMILY"): expected_errnos.add(tsocket.EAI_ADDRFAMILY) - # musl libc - if hasattr(tsocket, "EAI_NODATA"): - expected_errnos.add(tsocket.EAI_NODATA) assert excinfo.value.errno in expected_errnos # A family where we know nothing about the addresses, so should just