Skip to content

Commit 495bfa7

Browse files
fix: updated integration and unit tests to reflect new feature.
Signed-off-by: Abhinav Pradeep <[email protected]>
1 parent 4a8bd7e commit 495bfa7

File tree

9 files changed

+110
-9
lines changed

9 files changed

+110
-9
lines changed

src/macaron/build_spec_generator/dockerfile/pypi_dockerfile_output.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,6 @@ def gen_dockerfile(buildspec: BaseBuildSpecDict) -> str:
124124
EOF
125125
126126
# Run the build
127-
128127
RUN source /deps/bin/activate && {modern_build_command if version in SpecifierSet(">=3.6") else legacy_build_command}
129128
130129
# Validate script

tests/build_spec_generator/dockerfile/__snapshots__/test_pypi_dockerfile_output.ambr

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
FROM oraclelinux:9
77

88
# Install core tools
9-
RUN dnf -y install which wget tar git
9+
RUN dnf -y install which wget tar unzip git
1010

1111
# Install compiler and make
1212
RUN dnf -y install gcc make
@@ -69,5 +69,26 @@
6969
# Run the build
7070
RUN source /deps/bin/activate && python -m build
7171

72+
# Validate script
73+
RUN cat <<'EOF' >/validate
74+
# Capture artifacts generated
75+
ARTIFACTS=(/src/dist/*)
76+
# Ensure we only have one artefact
77+
[ ${#ARTIFACTS[@]} -eq 1 ] || { echo "Unexpected artifacts prodced!"; exit 1; }
78+
# BUILT_WHEEL is the artefact we built
79+
BUILT_WHEEL=${ARTIFACTS[0]}
80+
# Download the wheel
81+
wget -q https://files.pythonhosted.org/packages/96/c5/1e741d26306c42e2bf6ab740b2202872727e0f606033c9dd713f8b93f5a8/cachetools-6.2.1-py3-none-any.whl
82+
# Compare wheel names
83+
[ $(basename $BUILT_WHEEL) == "cachetools-6.2.1-py3-none-any.whl" ] || { echo "Wheel name does not match!"; exit 1; }
84+
# Compare file tree
85+
(unzip -Z1 $BUILT_WHEEL | sort) > built.tree
86+
(unzip -Z1 "cachetools-6.2.1-py3-none-any.whl" | sort ) > pypi_artefact.tree
87+
diff -u built.tree pypi_artefact.tree || { echo "File trees do not match!"; exit 1; }
88+
echo "Success!"
89+
EOF
90+
91+
ENTRYPOINT ["/bin/bash","/validate"]
92+
7293
'''
7394
# ---

tests/build_spec_generator/dockerfile/test_pypi_dockerfile_output.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Copyright (c) 2025 - 2025, Oracle and/or its affiliates. All rights reserved.
1+
# Copyright (c) 2025 - 2026, Oracle and/or its affiliates. All rights reserved.
22
# Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl/.
33

44
"""
@@ -31,6 +31,12 @@ def fixture_base_build_spec() -> BaseBuildSpecDict:
3131
"build_commands": [["python", "-m", "build"]],
3232
"build_requires": {"setuptools": "==80.9.0", "wheel": ""},
3333
"build_backends": ["setuptools.build_meta"],
34+
"upstream_artifacts": {
35+
"wheel": "https://files.pythonhosted.org/packages/96/c5/"
36+
"1e741d26306c42e2bf6ab740b2202872727e0f606033c9dd713f8b93f5a8/cachetools-6.2.1-py3-none-any.whl",
37+
"sdist": "https://files.pythonhosted.org/packages/cc/7e/"
38+
"b975b5814bd36faf009faebe22c1072a1fa1168db34d285ef0ba071ad78c/cachetools-6.2.1.tar.gz",
39+
},
3440
}
3541
)
3642

tests/integration/cases/pypi_cachetools/expected_default.buildspec

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,5 +30,9 @@
3030
},
3131
"build_backends": [
3232
"setuptools.build_meta"
33-
]
33+
],
34+
"upstream_artifacts": {
35+
"wheel": "https://files.pythonhosted.org/packages/96/c5/1e741d26306c42e2bf6ab740b2202872727e0f606033c9dd713f8b93f5a8/cachetools-6.2.1-py3-none-any.whl",
36+
"sdist": "https://files.pythonhosted.org/packages/cc/7e/b975b5814bd36faf009faebe22c1072a1fa1168db34d285ef0ba071ad78c/cachetools-6.2.1.tar.gz"
37+
}
3438
}

tests/integration/cases/pypi_cachetools/expected_dockerfile.buildspec

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
FROM oraclelinux:9
44

55
# Install core tools
6-
RUN dnf -y install which wget tar git
6+
RUN dnf -y install which wget tar unzip git
77

88
# Install compiler and make
99
RUN dnf -y install gcc make
@@ -65,3 +65,24 @@ EOF
6565

6666
# Run the build
6767
RUN source /deps/bin/activate && python -m build --wheel -n
68+
69+
# Validate script
70+
RUN cat <<'EOF' >/validate
71+
# Capture artifacts generated
72+
ARTIFACTS=(/src/dist/*)
73+
# Ensure we only have one artefact
74+
[ ${#ARTIFACTS[@]} -eq 1 ] || { echo "Unexpected artifacts prodced!"; exit 1; }
75+
# BUILT_WHEEL is the artefact we built
76+
BUILT_WHEEL=${ARTIFACTS[0]}
77+
# Download the wheel
78+
wget -q https://files.pythonhosted.org/packages/96/c5/1e741d26306c42e2bf6ab740b2202872727e0f606033c9dd713f8b93f5a8/cachetools-6.2.1-py3-none-any.whl
79+
# Compare wheel names
80+
[ $(basename $BUILT_WHEEL) == "cachetools-6.2.1-py3-none-any.whl" ] || { echo "Wheel name does not match!"; exit 1; }
81+
# Compare file tree
82+
(unzip -Z1 $BUILT_WHEEL | sort) > built.tree
83+
(unzip -Z1 "cachetools-6.2.1-py3-none-any.whl" | sort ) > pypi_artefact.tree
84+
diff -u built.tree pypi_artefact.tree || { echo "File trees do not match!"; exit 1; }
85+
echo "Success!"
86+
EOF
87+
88+
ENTRYPOINT ["/bin/bash","/validate"]

tests/integration/cases/pypi_markdown-it-py/expected_default.buildspec

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,5 +28,9 @@
2828
},
2929
"build_backends": [
3030
"flit_core.buildapi"
31-
]
31+
],
32+
"upstream_artifacts": {
33+
"wheel": "https://files.pythonhosted.org/packages/94/54/e7d793b573f298e1c9013b8c4dade17d481164aa517d1d7148619c2cedbf/markdown_it_py-4.0.0-py3-none-any.whl",
34+
"sdist": "https://files.pythonhosted.org/packages/5b/f5/4ec618ed16cc4f8fb3b701563655a69816155e79e24a17b651541804721d/markdown_it_py-4.0.0.tar.gz"
35+
}
3236
}

tests/integration/cases/pypi_markdown-it-py/expected_dockerfile.buildspec

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
FROM oraclelinux:9
44

55
# Install core tools
6-
RUN dnf -y install which wget tar git
6+
RUN dnf -y install which wget tar unzip git
77

88
# Install compiler and make
99
RUN dnf -y install gcc make
@@ -65,3 +65,24 @@ EOF
6565

6666
# Run the build
6767
RUN source /deps/bin/activate && pip install flit && if test -f "flit.ini"; then python -m flit.tomlify; fi && flit build
68+
69+
# Validate script
70+
RUN cat <<'EOF' >/validate
71+
# Capture artifacts generated
72+
ARTIFACTS=(/src/dist/*)
73+
# Ensure we only have one artefact
74+
[ ${#ARTIFACTS[@]} -eq 1 ] || { echo "Unexpected artifacts prodced!"; exit 1; }
75+
# BUILT_WHEEL is the artefact we built
76+
BUILT_WHEEL=${ARTIFACTS[0]}
77+
# Download the wheel
78+
wget -q https://files.pythonhosted.org/packages/94/54/e7d793b573f298e1c9013b8c4dade17d481164aa517d1d7148619c2cedbf/markdown_it_py-4.0.0-py3-none-any.whl
79+
# Compare wheel names
80+
[ $(basename $BUILT_WHEEL) == "markdown_it_py-4.0.0-py3-none-any.whl" ] || { echo "Wheel name does not match!"; exit 1; }
81+
# Compare file tree
82+
(unzip -Z1 $BUILT_WHEEL | sort) > built.tree
83+
(unzip -Z1 "markdown_it_py-4.0.0-py3-none-any.whl" | sort ) > pypi_artefact.tree
84+
diff -u built.tree pypi_artefact.tree || { echo "File trees do not match!"; exit 1; }
85+
echo "Success!"
86+
EOF
87+
88+
ENTRYPOINT ["/bin/bash","/validate"]

tests/integration/cases/pypi_toga/expected_default.buildspec

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,5 +32,9 @@
3232
},
3333
"build_backends": [
3434
"setuptools.build_meta"
35-
]
35+
],
36+
"upstream_artifacts": {
37+
"wheel": "https://files.pythonhosted.org/packages/2b/1a/6a9c8230ad30e819f0965bbd596c736a03e16003d27b0363c632c84d4861/toga-0.5.1-py3-none-any.whl",
38+
"sdist": "https://files.pythonhosted.org/packages/17/e7/0924150329474d61e9f40f8bba1056d640cba22438e05355924019111b46/toga-0.5.1.tar.gz"
39+
}
3640
}

tests/integration/cases/pypi_toga/expected_dockerfile.buildspec

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
FROM oraclelinux:9
44

55
# Install core tools
6-
RUN dnf -y install which wget tar git
6+
RUN dnf -y install which wget tar unzip git
77

88
# Install compiler and make
99
RUN dnf -y install gcc make
@@ -65,3 +65,24 @@ EOF
6565

6666
# Run the build
6767
RUN source /deps/bin/activate && python -m build --wheel -n
68+
69+
# Validate script
70+
RUN cat <<'EOF' >/validate
71+
# Capture artifacts generated
72+
ARTIFACTS=(/src/dist/*)
73+
# Ensure we only have one artefact
74+
[ ${#ARTIFACTS[@]} -eq 1 ] || { echo "Unexpected artifacts prodced!"; exit 1; }
75+
# BUILT_WHEEL is the artefact we built
76+
BUILT_WHEEL=${ARTIFACTS[0]}
77+
# Download the wheel
78+
wget -q https://files.pythonhosted.org/packages/2b/1a/6a9c8230ad30e819f0965bbd596c736a03e16003d27b0363c632c84d4861/toga-0.5.1-py3-none-any.whl
79+
# Compare wheel names
80+
[ $(basename $BUILT_WHEEL) == "toga-0.5.1-py3-none-any.whl" ] || { echo "Wheel name does not match!"; exit 1; }
81+
# Compare file tree
82+
(unzip -Z1 $BUILT_WHEEL | sort) > built.tree
83+
(unzip -Z1 "toga-0.5.1-py3-none-any.whl" | sort ) > pypi_artefact.tree
84+
diff -u built.tree pypi_artefact.tree || { echo "File trees do not match!"; exit 1; }
85+
echo "Success!"
86+
EOF
87+
88+
ENTRYPOINT ["/bin/bash","/validate"]

0 commit comments

Comments
 (0)