Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add v2 recipe editing capabilities for bumping version & build number #2920

Closed
wants to merge 14 commits into from
Prev Previous commit
Next Next commit
add tests
  • Loading branch information
wolfv committed Aug 7, 2024
commit 4c83a3b2f494ec5272caf70f17315f7218e7e979
10 changes: 10 additions & 0 deletions tests/recipe_v2/build_number/test_1/expected.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# set the build number to something
context:
build: 0

package:
name: recipe_1
version: "0.1.0"

build:
number: ${{ build }}
10 changes: 10 additions & 0 deletions tests/recipe_v2/build_number/test_1/recipe.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# set the build number to something
context:
build: 123

package:
name: recipe_1
version: "0.1.0"

build:
number: ${{ build }}
11 changes: 11 additions & 0 deletions tests/recipe_v2/build_number/test_2/expected.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# set the build number to something
package:
name: recipe_1
version: "0.1.0"

# set the build number to something directly in the recipe text
build:
number: 0

source:
- url: foo
11 changes: 11 additions & 0 deletions tests/recipe_v2/build_number/test_2/recipe.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# set the build number to something
package:
name: recipe_1
version: "0.1.0"

# set the build number to something directly in the recipe text
build:
number: 321

source:
- url: foo
12 changes: 12 additions & 0 deletions tests/recipe_v2/version/test_1/expected.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
context:
name: xtensor
version: "0.25.0"


package:
name: ${{ name|lower }}
version: ${{ version }}

source:
url: https://github.com/xtensor-stack/xtensor/archive/${{ version }}.tar.gz
sha256: 32d5d9fd23998c57e746c375a544edf544b74f0a18ad6bc3c38cbba968d5e6c7
12 changes: 12 additions & 0 deletions tests/recipe_v2/version/test_1/recipe.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
context:
name: xtensor
version: "0.23.5"


package:
name: ${{ name|lower }}
version: ${{ version }}

source:
url: https://github.com/xtensor-stack/xtensor/archive/${{ version }}.tar.gz
sha256: 0811011e448628f0dfa6ebb5e3f76dc7bf6a15ee65ea9c5a277b12ea976d35bc
15 changes: 15 additions & 0 deletions tests/recipe_v2/version/test_2/expected.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
context:
name: xtensor
version: "0.25.0"


package:
name: ${{ name|lower }}
version: ${{ version }}

source:
# please update the version here.
- if: target_platform == linux-64
then:
url: https://github.com/xtensor-stack/xtensor/archive/${{ version }}.tar.gz
sha256: 32d5d9fd23998c57e746c375a544edf544b74f0a18ad6bc3c38cbba968d5e6c7
15 changes: 15 additions & 0 deletions tests/recipe_v2/version/test_2/recipe.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
context:
name: xtensor
version: "0.23.5"


package:
name: ${{ name|lower }}
version: ${{ version }}

source:
# please update the version here.
- if: target_platform == linux-64
then:
url: https://github.com/xtensor-stack/xtensor/archive/${{ version }}.tar.gz
sha256: 0811011e448628f0dfa6ebb5e3f76dc7bf6a15ee65ea9c5a277b12ea976d35bc
11 changes: 11 additions & 0 deletions tests/recipe_v2/version/test_3/expected.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
context:
name: pytest-aio
version: 1.9.0

package:
name: ${{ name|lower }}
version: ${{ version }}

source:
url: https://pypi.io/packages/source/${{ name[0] }}/${{ name }}/${{ name.replace('-', '_') }}-${{ version }}.tar.gz
sha256: aa72e6ca4672b7f5a08ce44e7c6254dca988d3d578bf0c9485a47c3bff393ac1
11 changes: 11 additions & 0 deletions tests/recipe_v2/version/test_3/recipe.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
context:
name: pytest-aio
version: 1.8.1

package:
name: ${{ name|lower }}
version: ${{ version }}

source:
url: https://pypi.io/packages/source/${{ name[0] }}/${{ name }}/${{ name.replace('-', '_') }}-${{ version }}.tar.gz
sha256: 97dcbc1c5ac991705f32bb2cf72f9ba94a8889fd0295d29ed4d7252b3e158684
14 changes: 14 additions & 0 deletions tests/recipe_v2/version/test_4/expected.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
context:
version: "1.1-30"
posix: ${{ 'm2' if win else '' }}
native: ${{ 'm2w64' if win else '' }}

package:
name: r-systemfit
version: ${{ version|replace("-", "_") }}

source:
url:
- ${{ cran_mirror }}/src/contrib/systemfit_${{ version }}.tar.gz
- ${{ cran_mirror }}/src/contrib/Archive/systemfit/systemfit_${{ version }}.tar.gz
sha256: 5994fbb81f1678325862414f58328cdc2c46d47efa1f23218e9416a4da431ce2
14 changes: 14 additions & 0 deletions tests/recipe_v2/version/test_4/recipe.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
context:
version: "1.1-26"
posix: ${{ 'm2' if win else '' }}
native: ${{ 'm2w64' if win else '' }}

package:
name: r-systemfit
version: ${{ version|replace("-", "_") }}

source:
url:
- ${{ cran_mirror }}/src/contrib/systemfit_${{ version }}.tar.gz
- ${{ cran_mirror }}/src/contrib/Archive/systemfit/systemfit_${{ version }}.tar.gz
sha256: a99a59787dc5556afe9a1a153f2a3a8047aa7d357aab450101e20ab1f329f758
38 changes: 38 additions & 0 deletions tests/test_recipe_editing_v2.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
import pytest
from pathlib import Path

from rattler_build_conda_compat.modify_recipe import update_build_number, update_version


@pytest.fixture
def data_dir() -> Path:
return Path(__file__).parent / "recipe_v2"

def test_build_number_mod(data_dir: Path) -> None:
tests = data_dir / "build_number"
result = update_build_number(tests / "test_1/recipe.yaml", 0)
expected = tests / "test_1/expected.yaml"
assert result == expected.read_text()

result = update_build_number(tests / "test_2/recipe.yaml", 0)
expected = tests / "test_2/expected.yaml"
assert result == expected.read_text()


def test_version_mod(data_dir: Path) -> None:
tests = data_dir / "version"
test_recipes = [tests / "test_1/recipe.yaml", tests / "test_2/recipe.yaml"]
for recipe in test_recipes:
result = update_version(recipe, "0.25.0", None)
expected = recipe.parent / "expected.yaml"
assert result == expected.read_text()

test_python = tests / "test_3/recipe.yaml"
result = update_version(test_python, "1.9.0", None)
expected = test_python.parent / "expected.yaml"
assert result == expected.read_text()

test_cran = tests / "test_4/recipe.yaml"
result = update_version(test_cran, "1.1-30", None)
expected = test_cran.parent / "expected.yaml"
assert result == expected.read_text()