Skip to content

Commit 843cfa6

Browse files
committed
Merge branch 'topic/default/ci' into 'branch/default'
ci: GitHub Actions See merge request fluiddyn/install-locked-env!10
2 parents 0ca75fa + 9044fa3 commit 843cfa6

File tree

7 files changed

+78
-4
lines changed

7 files changed

+78
-4
lines changed

.github/workflows/ci.yml

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
name: CI Test
2+
3+
on:
4+
- push
5+
- pull_request
6+
7+
jobs:
8+
build:
9+
runs-on: ${{ matrix.os }}
10+
strategy:
11+
matrix:
12+
os: [ubuntu-latest, windows-latest, macos-latest]
13+
python-version: ["3.11", "3.14"]
14+
steps:
15+
- uses: actions/checkout@v4
16+
- name: Install UV
17+
uses: astral-sh/setup-uv@v4
18+
- if: runner.os != 'Windows'
19+
name: Install Mercurial with UV
20+
run: |
21+
uv tool install mercurial
22+
- name: Setup PDM
23+
uses: pdm-project/setup-pdm@v4
24+
with:
25+
python-version: ${{ matrix.python-version }}
26+
- name: Install dependencies with PDM
27+
run: pdm sync --clean
28+
- name: Run tests
29+
run: pdm run pytest test -v --run-slow --cov=install_locked_env

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
![Supported Python versions](https://img.shields.io/pypi/pyversions/install-locked-env.svg)
55
[![Project Status: Active – The project has reached a stable, usable state and is being actively developed.](https://www.repostatus.org/badges/latest/active.svg)](https://www.repostatus.org/#active)
66
[![Heptapod CI](https://foss.heptapod.net/fluiddyn/install-locked-env/badges/branch/default/pipeline.svg)](https://foss.heptapod.net/fluiddyn/install-locked-env/-/pipelines)
7+
[![Github Actions](https://github.com/fluiddyn/install-locked-env/actions/workflows/ci.yml/badge.svg?branch=branch/default)](https://github.com/fluiddyn/install-locked-env/actions/workflows/ci.yml)
78

89
A minimalist CLI tool easing the local installation of "locked environments" described in
910
lock files available in repositories on the web.

test/functional/test_cli.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
from unittest.mock import Mock, patch
22

33
import pytest
4+
import requests
45
from typer.testing import CliRunner
56

67
from install_locked_env import app
@@ -41,6 +42,15 @@ def test_app_simple(tmp_path, platform, minimal):
4142
):
4243
result = runner.invoke(app, options)
4344

45+
exc = result.exception
46+
if (
47+
exc is not None
48+
and isinstance(exc, requests.exceptions.HTTPError)
49+
and exc.response.status_code == 403
50+
):
51+
# Forbidden (typically rate limit exceeded GitHub API)
52+
pytest.skip("Skipping because of 403 HTTP error")
53+
4454
assert result.exit_code == 0
4555

4656
assert "Repository: fluiddyn/install-locked-env" in result.output

test/functional/test_download_clone.py

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,25 @@
1+
import shutil
2+
13
import pytest
24

35
from install_locked_env.downloaders import download_via_clone
46

57
from .util import get_url_info_env
68

79

10+
has_hg = bool(shutil.which("hg"))
11+
has_git = bool(shutil.which("git"))
12+
skipif = pytest.mark.skipif
13+
14+
815
@pytest.mark.slow
9-
@pytest.mark.parametrize("platform", ["github", "heptapod"])
16+
@pytest.mark.parametrize(
17+
"platform",
18+
[
19+
pytest.param("github", marks=skipif(not has_git, reason="Needs Git")),
20+
pytest.param("heptapod", marks=skipif(not has_hg, reason="Needs Mercurial")),
21+
],
22+
)
1023
def test_download_via_clone(tmp_path, platform):
1124
"""test download via archives"""
1225
url_info = get_url_info_env(platform, "root")

test/functional/test_download_file_per_file.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import pytest
2-
2+
import requests
33

44
from install_locked_env.downloaders import download_file_per_file
55

@@ -11,7 +11,15 @@
1111
def test_download_file_per_file(tmp_path, platform):
1212
"""test download file per file"""
1313
url_info = get_url_info_env(platform, "pdm-pylock")
14-
download_file_per_file(url_info, tmp_path)
14+
15+
try:
16+
download_file_per_file(url_info, tmp_path)
17+
except requests.exceptions.HTTPError as exc:
18+
status_code = exc.response.status_code
19+
if status_code == 403:
20+
# Forbidden (typically rate limit exceeded GitHub API)
21+
pytest.skip("Skipping because of 403 HTTP error")
22+
1523
paths = set(path.name for path in tmp_path.glob("*"))
1624
assert "pdm.toml" in paths
1725
assert "pylock.toml" in paths

test/functional/util.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
import pytest
2+
import requests
3+
14
from install_locked_env.parsers import UrlInfo
25

36

@@ -25,4 +28,11 @@ def get_url_env(platform: str, kind: str) -> str:
2528
def get_url_info_env(platform: str, kind: str) -> UrlInfo:
2629
"""Create a UrlInfo corresponding to a venv"""
2730

28-
return UrlInfo.from_url(get_url_env(platform, kind))
31+
try:
32+
return UrlInfo.from_url(get_url_env(platform, kind))
33+
except requests.exceptions.HTTPError as exc:
34+
status_code = exc.response.status_code
35+
if status_code == 403:
36+
# Forbidden (typically rate limit exceeded GitHub API)
37+
pytest.skip("Skipping because of 403 HTTP error")
38+
raise

test/test_downloaders.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -466,6 +466,9 @@ def test_raises_when_clone_with_path(self, tmp_path):
466466
class TestIntegration:
467467
"""Integration tests that test multiple components together."""
468468

469+
@pytest.mark.skipif(
470+
sys.version_info < (3, 13), reason="test broken for python < 3.13?"
471+
)
469472
@pytest.mark.slow
470473
@patch("install_locked_env.downloaders.requests.get")
471474
@patch("install_locked_env.downloaders.zipfile.ZipFile")

0 commit comments

Comments
 (0)