Commit 863957a9 authored by Mattia Rizzolo's avatar Mattia Rizzolo

change completely how the deployment is done, just build the website and serve...

change completely how the deployment is done, just build the website and serve it in place from the git repository
Signed-off-by: Mattia Rizzolo's avatarMattia Rizzolo <mattia@debian.org>
parent 9dc4ff72
...@@ -44,7 +44,6 @@ class Branch: ...@@ -44,7 +44,6 @@ class Branch:
self.pinned = name in manager.config["keep-branches"] self.pinned = name in manager.config["keep-branches"]
self.check_remote_status() self.check_remote_status()
self.load_config()
def check_remote_status(self): def check_remote_status(self):
"""Check the branch merging status on GitLab""" """Check the branch merging status on GitLab"""
...@@ -120,7 +119,7 @@ class Branch: ...@@ -120,7 +119,7 @@ class Branch:
def load_config(self): def load_config(self):
"""Load the configuration of this branch""" """Load the configuration of this branch"""
file = self.manager.root / "branches" / self.name / "config.json" file = self.manager.root / "branches" / self.name / "managetests.json"
self.config = None self.config = None
...@@ -213,7 +212,6 @@ class Branch: ...@@ -213,7 +212,6 @@ class Branch:
branch.mkdir() branch.mkdir()
git_url = self.manager.config["git-url"] git_url = self.manager.config["git-url"]
build_dir = branch / "build"
log_file = branch / "build.log" log_file = branch / "build.log"
# Clear the log file # Clear the log file
...@@ -224,9 +222,6 @@ class Branch: ...@@ -224,9 +222,6 @@ class Branch:
with log_file.open("a") as f: with log_file.open("a") as f:
f.write(msg+"\n") f.write(msg+"\n")
# Create subdirectories
build_dir.mkdir()
# Create the version file # Create the version file
with (branch / "version").open("w") as f: with (branch / "version").open("w") as f:
f.write("%s\n" % BRANCH_DIR_VERSION) f.write("%s\n" % BRANCH_DIR_VERSION)
...@@ -234,26 +229,26 @@ class Branch: ...@@ -234,26 +229,26 @@ class Branch:
# Update the bare git repository and checkout the branch # Update the bare git repository and checkout the branch
subprocess.call([ subprocess.call([
"git", "clone", "--depth", "1", "--branch", self.name, git_url, "git", "clone", "--depth", "1", "--branch", self.name, git_url,
str(build_dir), str(branch),
], stdout=log_file.open("a"), stderr=subprocess.STDOUT) ], stdout=log_file.open("a"), stderr=subprocess.STDOUT)
# Get the commit of the branch # Get the commit of the branch
commit_file = branch / "commit" commit_file = branch / "commit"
subprocess.call([ subprocess.call([
"git", "--git-dir", str(build_dir / ".git"), "rev-parse", "git", "--git-dir", str(branch / ".git"), "rev-parse",
self.name self.name
], stdout=commit_file.open("w"), stderr=log_file.open("a")) ], stdout=commit_file.open("w"), stderr=log_file.open("a"))
self.update_status("running") self.update_status("running")
# Copy and load the configuration file # Copy and load the configuration file
if not (build_dir / "managetests.json").exists(): if not (branch / "managetests.json").exists():
log("[!] No managetests.json found in the branch!") log("[!] No managetests.json found in the branch!")
log("[!] Aborting!") log("[!] Aborting!")
return False return False
shutil.copy( shutil.copy(
str(build_dir / "managetests.json"), str(branch / "managetests.json"),
str(branch / "config.json") str(branch / "config.json")
) )
self.load_config() self.load_config()
...@@ -265,35 +260,6 @@ class Branch: ...@@ -265,35 +260,6 @@ class Branch:
log("[!] Aborting!") log("[!] Aborting!")
return False return False
# Execute the pre-install commands
for cmd in self.config["before_install"]:
if not self.exec_command(cmd, build=True):
log("[!] Failed to execute before_install command: %s" % " ".join(cmd))
log("[!] Aborting!")
return False
# Install the builded artifacts
total = 0
for part in self.config["install"]:
artifacts = list(build_dir.glob(part["artifacts"]))
total += len(artifacts)
for artifact in artifacts:
self.exec_command(part["command"], {
"artifact": str(artifact),
}, build=True)
if total == 0:
log("[!] Warning: no artifact was installed!")
# Execute the post-install commands
if "after_install" in self.config:
for cmd in self.config["after_install"]:
if not self.exec_command(cmd, build=True):
log("[!] Failed to execute after_install command: %s" % " ".join(cmd))
log("[!] Aborting!")
return False
# Check if the branch was successifully built # Check if the branch was successifully built
popen_args = self.command_popen_args(self.config["run"]) popen_args = self.command_popen_args(self.config["run"])
if os.path.exists(popen_args[0][0][0]): if os.path.exists(popen_args[0][0][0]):
...@@ -303,9 +269,6 @@ class Branch: ...@@ -303,9 +269,6 @@ class Branch:
log("[!] Warning: build seems to have failed") log("[!] Warning: build seems to have failed")
self.update_status("failed") self.update_status("failed")
# Delete the build directory
shutil.rmtree(str(build_dir))
self.manager.details["branches"][self.name] = self.mr self.manager.details["branches"][self.name] = self.mr
self.manager.save_details() self.manager.save_details()
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment