-
Notifications
You must be signed in to change notification settings - Fork 7
feat: git source test #56
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
Open
remimimimimi
wants to merge
14
commits into
prefix-dev:main
Choose a base branch
from
remimimimimi:feat/git-source-test
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+1,748
−1
Open
Changes from all commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
700245d
feat: git source test
remimimimimi aeb2d3f
chore: add .env.ci
remimimimimi 167ce83
fix: update lockfiles
remimimimimi cce94b6
Revert "chore: add .env.ci"
remimimimimi 79ebc41
chore: pin source to specific revision
remimimimimi 8c14d26
chore: add .env.ci
remimimimimi bbc7b42
chore: bump lockfiles
remimimimimi 46e7dba
Revert "fix: update lockfiles"
remimimimimi a10fdb3
Revert "chore: bump lockfiles"
remimimimimi 708a228
Revert "chore: add .env.ci"
remimimimimi f6dd74a
Add more tests
remimimimimi f8cb3c3
Add even more tests
remimimimimi f6b86c4
Add .env.ci
remimimimimi 1bb0de4
Also load `.env.ci`
Hofer-Julian File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
PIXI_PR_NUMBER="4446" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
# pixi environments | ||
.pixi | ||
|
||
# The build directory | ||
.build |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
# Simple C++ SDL Example with specified source path | ||
|
||
This is a simple pixi demo that showcases how to use C++ and SDL with specified source path. | ||
|
||
## How to use? | ||
|
||
Make sure you have `pixi` available in your terminal. | ||
Navigate to this directory and run: | ||
|
||
```shell | ||
|
||
# Start the build executable | ||
pixi run start | ||
``` |
1,291 changes: 1,291 additions & 0 deletions
1,291
tests/data/pixi_build/cpp-with-git-source/pixi.lock
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
[workspace] | ||
channels = ["https://prefix.dev/conda-forge"] | ||
platforms = ["win-64", "linux-64", "osx-64", "osx-arm64"] | ||
preview = ["pixi-build"] | ||
|
||
[dependencies] | ||
# Define a dependency on ourselves. This will invoke the build backend to build | ||
# the C++ code and install the executable in an environment ready to be used. | ||
sdl_example = { path = "." } | ||
|
||
[tasks.start] | ||
cmd = "sdl_example" | ||
description = "A tasks to run the executable that is build by the package section." | ||
|
||
[tasks] | ||
test = "sdl_example -h" | ||
|
||
[package] | ||
authors = ["Bas Zalmstra <[email protected]>"] | ||
description = "Showcases how to create a simple C++ executable with Pixi" | ||
name = "sdl_example" | ||
version = "0.1.0" | ||
|
||
[package.build.source] | ||
branch = "main" | ||
git = "https://github.com/prefix-dev/pixi-build-testsuite.git" | ||
subdirectory = "tests/data/pixi_build/cpp-with-path-to-source/project" | ||
|
||
[package.build.backend] | ||
channels = [ | ||
"https://prefix.dev/pixi-build-backends", | ||
"https://prefix.dev/conda-forge", | ||
] | ||
name = "pixi-build-cmake" | ||
version = "*" | ||
|
||
[package.host-dependencies] | ||
# This ensures that SDL2 is available at build time. | ||
sdl2 = ">=2.26.5,<3.0" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,8 @@ | ||
import json | ||
import os | ||
import shutil | ||
import subprocess | ||
from dataclasses import dataclass | ||
from pathlib import Path | ||
from typing import Any, cast | ||
|
||
|
@@ -150,6 +152,7 @@ def _validate_artifact_sources() -> None: | |
@pytest.fixture(scope="session", autouse=True) | ||
def load_dotenv() -> None: | ||
dotenv.load_dotenv(override=True) | ||
dotenv.load_dotenv(override=True, dotenv_path=Path(__file__).parents[2].joinpath(".env.ci")) | ||
_validate_artifact_sources() | ||
|
||
|
||
|
@@ -334,3 +337,81 @@ def multiple_versions_channel_1(channels: Path) -> str: | |
@pytest.fixture | ||
def target_specific_channel_1(channels: Path) -> str: | ||
return channels.joinpath("target_specific_channel_1").as_uri() | ||
|
||
|
||
@dataclass | ||
class LocalGitRepo: | ||
path: Path | ||
main_rev: str | ||
other_feature_rev: str | ||
tag: str | ||
|
||
|
||
@pytest.fixture | ||
def local_cpp_git_repo( | ||
pixi: Path, | ||
build_data: Path, | ||
tmp_path_factory: pytest.TempPathFactory, | ||
) -> LocalGitRepo: | ||
""" | ||
Create a local git repository mirroring cpp-with-path-to-source so tests can | ||
exercise git sources without touching the network. | ||
""" | ||
|
||
source_root = build_data.joinpath("cpp-with-path-to-source") | ||
repo_root = tmp_path_factory.mktemp("git-repo") | ||
repo_path = repo_root.joinpath("repo") | ||
shutil.copytree(source_root, repo_path) | ||
|
||
marker = repo_path.joinpath("project", "LOCAL_MARKER.txt") | ||
marker.write_text("local git fixture marker\n", encoding="utf-8") | ||
|
||
readme_path = repo_path.joinpath("README.md") | ||
|
||
def run_git(*args: str) -> str: | ||
result = subprocess.run( | ||
[str(pixi), "run", "git", *args], | ||
cwd=repo_path, | ||
capture_output=True, | ||
text=True, | ||
) | ||
if result.returncode != 0: | ||
raise RuntimeError( | ||
"git command failed ({}):\nstdout: {}\nstderr: {}".format( | ||
" ".join(args), result.stdout, result.stderr | ||
) | ||
) | ||
return result.stdout.strip() | ||
|
||
run_git("init", "-b", "main") | ||
run_git("config", "user.email", "[email protected]") | ||
run_git("config", "user.name", "Pixi Build Tests") | ||
run_git("add", ".") | ||
run_git("commit", "-m", "Initial commit") | ||
|
||
run_git("checkout", "-b", "other-feature") | ||
readme_path.write_text( | ||
readme_path.read_text(encoding="utf-8") + "\nLocal change on other-feature branch\n", | ||
encoding="utf-8", | ||
) | ||
run_git("add", readme_path.relative_to(repo_path).as_posix()) | ||
run_git("commit", "-m", "Add branch change") | ||
other_feature_rev = run_git("rev-parse", "HEAD") | ||
|
||
run_git("checkout", "main") | ||
readme_path.write_text( | ||
readme_path.read_text(encoding="utf-8") + "\nLocal change on main\n", | ||
encoding="utf-8", | ||
) | ||
run_git("add", readme_path.relative_to(repo_path).as_posix()) | ||
run_git("commit", "-m", "Update main") | ||
main_rev = run_git("rev-parse", "HEAD") | ||
|
||
run_git("tag", "fixture-v1") | ||
|
||
return LocalGitRepo( | ||
path=repo_path, | ||
main_rev=main_rev, | ||
other_feature_rev=other_feature_rev, | ||
tag="fixture-v1", | ||
) |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The backend will be overriden anyway so no need to specify channels for it