use pyb for ci

This commit is contained in:
Michael Jerger 2023-07-20 09:23:19 +02:00
parent f143587c95
commit 6d96d0e466
3 changed files with 137 additions and 13 deletions

1
.gitignore vendored
View file

@ -27,3 +27,4 @@ my-auth.edn
.clj-kondo/
.lsp/
.eastwood

View file

@ -5,7 +5,7 @@ stages:
- upload
.cljs-job: &cljs
image: domaindrivenarchitecture/shadow-cljs
image: "domaindrivenarchitecture/ddadevops-clojure:4.1.0"
cache:
key: ${CI_COMMIT_REF_SLUG}
paths:
@ -17,7 +17,7 @@ stages:
- npm install
.clj-job: &clj
image: domaindrivenarchitecture/lein
image: "domaindrivenarchitecture/ddadevops-clojure:4.1.0"
cache:
key: ${CI_COMMIT_REF_SLUG}
paths:
@ -26,33 +26,34 @@ stages:
- mkdir -p /root/.lein
- echo "{:auth {:repository-auth {#\"clojars\" {:username \"${CLOJARS_USER}\" :password \"${CLOJARS_TOKEN_DOMAINDRIVENARCHITECTURE}\" }}}}" > ~/.lein/profiles.clj
.tag_only: &tag_only
rules:
- if: '$CI_PIPELINE_SOURCE == "merge_request_event"'
when: never
- if: '$CI_COMMIT_TAG =~ /^[0-9]+\.[0-9]+\.[0-9]+$/'
test-clj:
<<: *clj
stage: build_and_test
script:
- lein test
- pyb test_clj
test-cljs:
<<: *cljs
stage: build_and_test
script:
- shadow-cljs compile test
- node target/node-tests.js
- pyb test_cljs
upload-clj-release:
<<: *clj
<<: *tag_only
stage: upload
rules:
- if: '$CI_COMMIT_TAG != null'
script:
- lein deploy
- pyb upload_clj
upload-cljs-release:
<<: *clj
<<: *tag_only
stage: upload
rules:
- if: '$CI_COMMIT_TAG != null'
script:
- mv project.clj project-clj.clj && mv project-cljs.clj project.clj
- lein deploy
- pyb upload_cljs

122
build.py Normal file
View file

@ -0,0 +1,122 @@
from os import environ
from subprocess import run
from pybuilder.core import init, task
from ddadevops import *
default_task = "dev"
name = "c4k-common"
MODULE = "not-used"
PROJECT_ROOT_PATH = "."
@init
def initialize(project):
input = {
"name": name,
"module": MODULE,
"stage": "notused",
"project_root_path": PROJECT_ROOT_PATH,
"build_types": [],
"mixin_types": ["RELEASE"],
"release_primary_build_file": "project.clj",
"release_secondary_build_files": [
"project-cljs.clj",
],
}
build = ReleaseMixin(project, input)
build.initialize_build_dir()
@task
def test_clj(project):
run("lein test", shell=True, check=True)
@task
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 upload_clj(project):
run("lein deploy", shell=True, check=True)
@task
def upload_cljs(project):
run(
"mv project.clj project-clj.clj && mv project-cljs.clj project.clj",
shell=True,
check=True,
)
run("lein deploy", shell=True, check=True)
run(
"mv project.clj project-cljs.clj && mv project-clj.clj project.clj",
shell=True,
check=True,
)
@task
def lint(project):
run(
"lein eastwood",
shell=True,
check=True,
)
run(
"lein ancient check",
shell=True,
check=True,
)
@task
def patch(project):
linttest(project, "PATCH")
release(project)
@task
def minor(project):
linttest(project, "MINOR")
release(project)
@task
def major(project):
linttest(project, "MAJOR")
release(project)
@task
def dev(project):
linttest(project, "NONE")
@task
def prepare(project):
build = get_devops_build(project)
build.prepare_release()
@task
def tag(project):
build = get_devops_build(project)
build.tag_bump_and_push_release()
def release(project):
prepare(project)
tag(project)
def linttest(project, release_type):
build = get_devops_build(project)
build.update_release_type(release_type)
test_clj(project)
test_cljs(project)
lint(project)