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/ .clj-kondo/
.lsp/ .lsp/
.eastwood

View file

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

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)