Skip to content

Commit

Permalink
Merge pull request #131 from olehermanse/build
Browse files Browse the repository at this point in the history
ENT-9351: Test and fix for cfbs build on modules added by URL
  • Loading branch information
olehermanse committed Sep 30, 2022
2 parents 93828a9 + c1e4db2 commit 5b83953
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 1 deletion.
5 changes: 4 additions & 1 deletion cfbs/commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -623,7 +623,10 @@ def _download_dependencies(
if not os.path.exists(module_dir):
if url.endswith(SUPPORTED_ARCHIVES):
fetch_archive(url, commit)
elif "index" in module or ignore_versions:
# a couple of cases where there will not be an archive available:
# - using an alternate index (index property in module data)
# - added by URL instead of name (no version property in module data)
elif "index" in module or "url" in module or ignore_versions:
sh("git clone %s %s" % (url, commit_dir))
sh("(cd %s && git checkout %s)" % (commit_dir, commit))
else:
Expand Down
22 changes: 22 additions & 0 deletions tests/shell/013_add_url_commit.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,25 @@ grep scl cfbs.json
cfbs build
ls out/masterfiles/lib/scl/
grep scl_dmidecode_example out/masterfiles/scl_example.json

# Build should be possible to do on another machine
# so let's test that it works after deleting the things which
# will not be on the next machine.
# Notably, cfbs add will download some things which can be reused in
# cfbs build (git clones / zip downloads in ~/.cfengine/cfbs)

rm -rf out/
rm -rf ~/.cfengine/cfbs

cfbs build
ls out/masterfiles/lib/scl/
grep scl_dmidecode_example out/masterfiles/scl_example.json

# Finally, let's also test that we can build it again (now with the cached
# files)

rm -rf out/

cfbs build
ls out/masterfiles/lib/scl/
grep scl_dmidecode_example out/masterfiles/scl_example.json

0 comments on commit 5b83953

Please sign in to comment.