Skip to content

Commit 437b091

Browse files
authored
Fix CI failures due to removed runners in Github Actions (#1354)
The "ubuntu-20.04" runner was removed a few months ago, causing the Loguru CI to repeatedly fail since then. On top of that, migrating to "ubuntu-22.04" or "ubuntu-24.04" was not straightforward because these runners were incompatible with "actions/setup-python" for Python 3.5 and 3.6. As a workaround, I replaced "actions/setup-python" with a "python-slim" Docker image for these versions that went unsupported. That's probably the closest we can get to a stable and reproducible CI setup that won't break overnight due to upstream decisions. ;) Eventually, this solution will likely need to be repeated for other Python versions as theyh become deprecated. I've considered defaulting to a Docker image, but I assume the recommended approach is still to favor "actions/setup-python" when it's available. Additionally, because "actions/download-artifact" would not work within the Docker image (conflicting GLIB versions between the OS and their executable), I've moved the Codecov upload to a later stage in charge of uploading all the coverage reports once the tests have been completed. The downside is that we lose the "flags" that enabled us to identify coverage reports individually on Codecov. But I don't know if we can do otherwise.
1 parent a69bfc4 commit 437b091

File tree

1 file changed

+24
-8
lines changed

1 file changed

+24
-8
lines changed

.github/workflows/tests.yml

Lines changed: 24 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,14 @@ jobs:
2626
allow-failure:
2727
- false
2828
include:
29-
- os: ubuntu-20.04
29+
- os: ubuntu-22.04
3030
python-version: '3.5'
3131
allow-failure: false
32-
- os: ubuntu-20.04
32+
container: python:3.5-slim
33+
- os: ubuntu-22.04
3334
python-version: '3.6'
3435
allow-failure: false
36+
container: python:3.6-slim
3537
- os: windows-2022
3638
python-version: '3.12'
3739
allow-failure: false
@@ -42,16 +44,18 @@ jobs:
4244
python-version: 3.14-dev
4345
allow-failure: true
4446
runs-on: ${{ matrix.os }}
47+
# Some versions of Python are not longer supported by GitHub Actions.
48+
# For those, we use a container image and skip the setup-python step.
49+
# It will be empty and ignored for the other matrix entries.
50+
container: ${{ matrix.container }}
4551
steps:
4652
- name: Checkout repository
4753
uses: actions/checkout@v4
4854
- name: Set up Python
55+
if: ${{ matrix.container == null }}
4956
uses: actions/setup-python@v5
5057
with:
5158
python-version: ${{ matrix.python-version }}
52-
env:
53-
# Workaround for https://github.com/actions/setup-python/issues/866
54-
PIP_TRUSTED_HOST: pypi.python.org pypi.org files.pythonhosted.org
5559
- name: Install dependencies
5660
run: |
5761
python -m pip install --upgrade pip
@@ -60,11 +64,23 @@ jobs:
6064
run: |
6165
tox -e tests
6266
continue-on-error: ${{ matrix.allow-failure }}
63-
- name: Upload coverage to Codecov
67+
- name: Upload coverage data
68+
uses: actions/upload-artifact@v4
69+
with:
70+
name: coverage-${{ matrix.python-version }}-${{ matrix.os }}
71+
path: coverage.xml
72+
continue-on-error: ${{ matrix.allow-failure }}
73+
push-coverage-to-codecov:
74+
runs-on: ubuntu-22.04
75+
needs: tests
76+
steps:
77+
- name: Checkout
78+
uses: actions/checkout@v2
79+
- name: Download artifacts
80+
uses: actions/download-artifact@v4
81+
- name: Upload to Codecov
6482
uses: codecov/codecov-action@v5
6583
with:
6684
token: ${{ secrets.CODECOV_TOKEN }}
67-
flags: ${{ matrix.os }}_${{ matrix.python-version }}
6885
verbose: true
6986
fail_ci_if_error: true
70-
continue-on-error: ${{ matrix.allow-failure }}

0 commit comments

Comments
 (0)