2023-06-23 08:48:53 +00:00
|
|
|
from os import environ
|
2023-06-30 15:45:22 +00:00
|
|
|
from subprocess import run
|
2023-10-13 13:44:20 +00:00
|
|
|
from pybuilder.core import init, task
|
2023-06-23 08:48:53 +00:00
|
|
|
from ddadevops import *
|
|
|
|
|
2023-10-13 13:44:20 +00:00
|
|
|
default_task = "dev"
|
|
|
|
name = 'c4k-forgejo'
|
|
|
|
MODULE = 'not-used'
|
|
|
|
PROJECT_ROOT_PATH = '.'
|
2023-06-23 08:48:53 +00:00
|
|
|
|
|
|
|
@init
|
|
|
|
def initialize(project):
|
2023-10-13 13:44:20 +00:00
|
|
|
project.build_depends_on("ddadevops>=4.7.0")
|
2023-06-23 08:48:53 +00:00
|
|
|
|
|
|
|
input = {
|
|
|
|
"name": name,
|
|
|
|
"module": MODULE,
|
|
|
|
"stage": "notused",
|
|
|
|
"project_root_path": PROJECT_ROOT_PATH,
|
|
|
|
"build_types": [],
|
|
|
|
"mixin_types": ["RELEASE"],
|
|
|
|
"release_primary_build_file": "project.clj",
|
2023-10-13 13:44:20 +00:00
|
|
|
"release_secondary_build_files": [
|
|
|
|
"package.json",
|
|
|
|
"infrastructure/backup/build.py",
|
|
|
|
"infrastructure/federated/build.py",
|
|
|
|
],
|
|
|
|
"release_artifact_server_url": "https://repo.prod.meissa.de",
|
|
|
|
"release_organisation": "meissa",
|
|
|
|
"release_repository_name": name,
|
|
|
|
"release_artifacts": [
|
2024-02-17 08:05:16 +00:00
|
|
|
"target/graalvm/c4k-forgejo",
|
2023-10-13 13:44:20 +00:00
|
|
|
"target/uberjar/c4k-forgejo-standalone.jar",
|
|
|
|
"target/frontend-build/c4k-forgejo.js",
|
|
|
|
],
|
2023-06-23 08:48:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
build = ReleaseMixin(project, input)
|
|
|
|
build.initialize_build_dir()
|
|
|
|
|
|
|
|
|
|
|
|
@task
|
2023-10-13 13:44:20 +00:00
|
|
|
def test_clj(project):
|
|
|
|
run("lein test", shell=True, check=True)
|
|
|
|
|
2023-06-23 08:48:53 +00:00
|
|
|
|
|
|
|
@task
|
2023-10-13 13:44:20 +00:00
|
|
|
def test_cljs(project):
|
|
|
|
run("shadow-cljs compile test", shell=True, check=True)
|
|
|
|
run("node target/node-tests.js", shell=True, check=True)
|
|
|
|
|
|
|
|
|
|
|
|
@task
|
|
|
|
def test_schema(project):
|
|
|
|
run("lein uberjar", shell=True, check=True)
|
|
|
|
run(
|
|
|
|
"java -jar target/uberjar/c4k-forgejo-standalone.jar "
|
|
|
|
+ "src/test/resources/forgejo-test/valid-config.yaml "
|
|
|
|
+ "src/test/resources/forgejo-test/valid-auth.yaml | "
|
2024-01-26 13:32:29 +00:00
|
|
|
+ """kubeconform --kubernetes-version 1.23.0 --strict --skip "Certificate,Middleware" -""",
|
2023-10-13 13:44:20 +00:00
|
|
|
shell=True,
|
|
|
|
check=True,
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
@task
|
|
|
|
def report_frontend(project):
|
|
|
|
run("mkdir -p target/frontend-build", shell=True, check=True)
|
|
|
|
run(
|
|
|
|
"shadow-cljs run shadow.cljs.build-report frontend target/frontend-build/build-report.html",
|
|
|
|
shell=True,
|
|
|
|
check=True,
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
@task
|
|
|
|
def package_frontend(project):
|
|
|
|
run("mkdir -p target/frontend-build", shell=True, check=True)
|
|
|
|
run("shadow-cljs release frontend", shell=True, check=True)
|
|
|
|
run(
|
2024-02-17 08:41:38 +00:00
|
|
|
"cp public/js/main.js target/frontend-build/" + project.name + ".js",
|
2023-10-13 13:44:20 +00:00
|
|
|
shell=True,
|
|
|
|
check=True,
|
|
|
|
)
|
|
|
|
run(
|
2024-02-17 08:41:38 +00:00
|
|
|
"sha256sum target/frontend-build/c4k-forgejo.js > target/frontend-build/" + project.name + ".js.sha256",
|
2023-10-13 13:44:20 +00:00
|
|
|
shell=True,
|
|
|
|
check=True,
|
|
|
|
)
|
|
|
|
run(
|
2024-02-17 08:41:38 +00:00
|
|
|
"sha512sum target/frontend-build/c4k-forgejo.js > target/frontend-build/" + project.name + ".js.sha512",
|
2023-10-13 13:44:20 +00:00
|
|
|
shell=True,
|
|
|
|
check=True,
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
@task
|
|
|
|
def package_uberjar(project):
|
|
|
|
run(
|
2024-02-17 08:41:38 +00:00
|
|
|
"sha256sum target/uberjar/c4k-forgejo-standalone.jar > target/uberjar/" + project.name + "-standalone.jar.sha256",
|
2023-10-13 13:44:20 +00:00
|
|
|
shell=True,
|
|
|
|
check=True,
|
|
|
|
)
|
|
|
|
run(
|
2024-02-17 08:41:38 +00:00
|
|
|
"sha512sum target/uberjar/c4k-forgejo-standalone.jar > target/uberjar/" + project.name + "-standalone.jar.sha512",
|
2023-10-13 13:44:20 +00:00
|
|
|
shell=True,
|
|
|
|
check=True,
|
|
|
|
)
|
|
|
|
|
2024-02-17 08:05:16 +00:00
|
|
|
|
2024-02-16 15:55:26 +00:00
|
|
|
@task
|
|
|
|
def package_native(project):
|
|
|
|
run(
|
|
|
|
"mkdir -p target/graalvm",
|
|
|
|
shell=True,
|
|
|
|
check=True,
|
|
|
|
)
|
|
|
|
run(
|
2024-02-17 08:21:08 +00:00
|
|
|
"native-image " +
|
|
|
|
"--native-image-info " +
|
|
|
|
"--report-unsupported-elements-at-runtime " +
|
|
|
|
"--no-server " +
|
|
|
|
"--no-fallback " +
|
|
|
|
"--features=clj_easy.graal_build_time.InitClojureClasses " +
|
2024-02-17 08:41:38 +00:00
|
|
|
"-jar target/uberjar/" + project.name + "-standalone.jar " +
|
2024-02-17 08:21:08 +00:00
|
|
|
"-H:IncludeResources=.*.yaml " +
|
|
|
|
"-H:Log=registerResource:verbose " +
|
2024-02-17 08:41:38 +00:00
|
|
|
"-H:Name=target/graalvm/" + project.name + "",
|
2024-02-16 15:55:26 +00:00
|
|
|
shell=True,
|
|
|
|
check=True,
|
|
|
|
)
|
2024-02-17 08:05:16 +00:00
|
|
|
run(
|
2024-02-17 08:41:38 +00:00
|
|
|
"sha256sum target/graalvm/c4k-forgejo > target/graalvm/" + project.name + ".sha256",
|
2024-02-17 08:05:16 +00:00
|
|
|
shell=True,
|
|
|
|
check=True,
|
|
|
|
)
|
|
|
|
run(
|
2024-02-17 08:41:38 +00:00
|
|
|
"sha512sum target/graalvm/c4k-forgejo > target/graalvm/" + project.name + ".sha512",
|
2024-02-17 08:05:16 +00:00
|
|
|
shell=True,
|
|
|
|
check=True,
|
|
|
|
)
|
|
|
|
|
2024-02-16 15:55:26 +00:00
|
|
|
|
|
|
|
@task
|
|
|
|
def inst(project):
|
|
|
|
run(
|
|
|
|
"lein uberjar",
|
|
|
|
shell=True,
|
|
|
|
check=True,
|
|
|
|
)
|
2024-02-17 08:41:38 +00:00
|
|
|
package_native(project)
|
2024-02-16 15:55:26 +00:00
|
|
|
run(
|
2024-02-17 08:41:38 +00:00
|
|
|
"sudo install -m=755 target/uberjar/" + project.name + "-standalone.jar /usr/local/bin/" + project.name + "-standalone.jar",
|
2024-02-16 15:55:26 +00:00
|
|
|
shell=True,
|
|
|
|
check=True,
|
|
|
|
)
|
|
|
|
run(
|
2024-02-17 08:41:38 +00:00
|
|
|
"sudo install -m=755 target/graalvm/" + project.name + " /usr/local/bin/" + project.name + "",
|
2024-02-16 15:55:26 +00:00
|
|
|
shell=True,
|
|
|
|
check=True,
|
|
|
|
)
|
|
|
|
|
2023-10-13 13:44:20 +00:00
|
|
|
|
|
|
|
@task
|
|
|
|
def upload_clj(project):
|
|
|
|
run("lein deploy", shell=True, check=True)
|
|
|
|
|
|
|
|
|
|
|
|
@task
|
|
|
|
def lint(project):
|
2023-10-13 14:06:42 +00:00
|
|
|
#run(
|
|
|
|
# "lein eastwood",
|
|
|
|
# shell=True,
|
|
|
|
# check=True,
|
|
|
|
#)
|
2023-10-13 13:44:20 +00:00
|
|
|
run(
|
|
|
|
"lein ancient check",
|
|
|
|
shell=True,
|
|
|
|
check=True,
|
|
|
|
)
|
|
|
|
|
2023-06-30 15:45:22 +00:00
|
|
|
|
|
|
|
@task
|
|
|
|
def patch(project):
|
2023-10-13 13:44:20 +00:00
|
|
|
linttest(project, "PATCH")
|
|
|
|
release(project)
|
|
|
|
|
2023-06-30 15:45:22 +00:00
|
|
|
|
|
|
|
@task
|
|
|
|
def minor(project):
|
2023-10-13 13:44:20 +00:00
|
|
|
linttest(project, "MINOR")
|
|
|
|
release(project)
|
|
|
|
|
2023-06-30 15:45:22 +00:00
|
|
|
|
|
|
|
@task
|
|
|
|
def major(project):
|
2023-10-13 13:44:20 +00:00
|
|
|
linttest(project, "MAJOR")
|
|
|
|
release(project)
|
|
|
|
|
|
|
|
|
2023-06-30 15:45:22 +00:00
|
|
|
@task
|
|
|
|
def dev(project):
|
2023-10-13 13:44:20 +00:00
|
|
|
linttest(project, "NONE")
|
|
|
|
|
2023-06-30 15:45:22 +00:00
|
|
|
|
|
|
|
@task
|
2023-10-13 13:44:20 +00:00
|
|
|
def prepare(project):
|
|
|
|
build = get_devops_build(project)
|
|
|
|
build.prepare_release()
|
|
|
|
|
2023-06-30 15:45:22 +00:00
|
|
|
|
|
|
|
@task
|
2023-10-13 13:44:20 +00:00
|
|
|
def tag(project):
|
|
|
|
build = get_devops_build(project)
|
|
|
|
build.tag_bump_and_push_release()
|
2023-06-30 15:45:22 +00:00
|
|
|
|
|
|
|
@task
|
2023-10-13 13:44:20 +00:00
|
|
|
def publish_artifacts(project):
|
|
|
|
build = get_devops_build(project)
|
|
|
|
build.publish_artifacts()
|
|
|
|
|
|
|
|
def release(project):
|
|
|
|
prepare(project)
|
|
|
|
tag(project)
|
2023-06-30 15:45:22 +00:00
|
|
|
|
2023-10-13 13:44:20 +00:00
|
|
|
|
|
|
|
def linttest(project, release_type):
|
2023-06-30 15:45:22 +00:00
|
|
|
build = get_devops_build(project)
|
|
|
|
build.update_release_type(release_type)
|
2023-10-13 13:44:20 +00:00
|
|
|
test_clj(project)
|
|
|
|
test_cljs(project)
|
|
|
|
test_schema(project)
|
|
|
|
lint(project)
|