Use pyb for CI
This commit is contained in:
parent
aa8c69bbc2
commit
f1c3b9a021
2 changed files with 233 additions and 67 deletions
120
.gitlab-ci.yml
120
.gitlab-ci.yml
|
@ -5,11 +5,18 @@ stages:
|
||||||
- upload
|
- upload
|
||||||
- image
|
- image
|
||||||
|
|
||||||
services:
|
.img: &img
|
||||||
- docker:dind
|
image: "domaindrivenarchitecture/ddadevops-dind:4.7.2"
|
||||||
|
services:
|
||||||
|
- docker:dind
|
||||||
|
before_script:
|
||||||
|
- export RELEASE_ARTIFACT_TOKEN=$MEISSA_REPO_BUERO_RW
|
||||||
|
- export IMAGE_DOCKERHUB_USER=$DOCKERHUB_USER
|
||||||
|
- export IMAGE_DOCKERHUB_PASSWORD=$DOCKERHUB_PASSWORD
|
||||||
|
- export IMAGE_TAG=$CI_COMMIT_TAG
|
||||||
|
|
||||||
.cljs-job: &cljs
|
.cljs-job: &cljs
|
||||||
image: domaindrivenarchitecture/shadow-cljs
|
image: "domaindrivenarchitecture/ddadevops-clj-cljs:4.7.2"
|
||||||
cache:
|
cache:
|
||||||
key: ${CI_COMMIT_REF_SLUG}
|
key: ${CI_COMMIT_REF_SLUG}
|
||||||
paths:
|
paths:
|
||||||
|
@ -17,40 +24,45 @@ services:
|
||||||
- .shadow-cljs/
|
- .shadow-cljs/
|
||||||
- .m2
|
- .m2
|
||||||
before_script:
|
before_script:
|
||||||
- echo "//registry.npmjs.org/:_authToken=$NPM_TOKEN" > ~/.npmrc
|
- export RELEASE_ARTIFACT_TOKEN=$MEISSA_REPO_BUERO_RW
|
||||||
- npm install
|
- echo "//registry.npmjs.org/:_authToken=$NPM_TOKEN" > ~/.npmrc
|
||||||
|
- npm install
|
||||||
|
|
||||||
.clj-uploadjob: &clj
|
.clj-job: &clj
|
||||||
image: domaindrivenarchitecture/lein
|
image: "domaindrivenarchitecture/ddadevops-clj-cljs:4.7.2"
|
||||||
cache:
|
cache:
|
||||||
key: ${CI_COMMIT_REF_SLUG}
|
key: ${CI_COMMIT_REF_SLUG}
|
||||||
paths:
|
paths:
|
||||||
- .m2
|
- .m2
|
||||||
before_script:
|
before_script:
|
||||||
- mkdir -p /root/.lein
|
- export RELEASE_ARTIFACT_TOKEN=$MEISSA_REPO_BUERO_RW
|
||||||
- echo "{:auth {:repository-auth {#\"clojars\" {:username \"${CLOJARS_USER}\" :password \"${CLOJARS_TOKEN_DOMAINDRIVENARCHITECTURE}\" }}}}" > ~/.lein/profiles.clj
|
- mkdir -p /root/.lein
|
||||||
|
- echo "{:auth {:repository-auth {#\"clojars\" {:username \"${CLOJARS_USER}\" :password \"${CLOJARS_TOKEN_DOMAINDRIVENARCHITECTURE}\" }}}}" > ~/.lein/profiles.clj
|
||||||
|
|
||||||
test-cljs:
|
.tag_only: &tag_only
|
||||||
<<: *cljs
|
rules:
|
||||||
stage: build_and_test
|
- if: '$CI_PIPELINE_SOURCE == "merge_request_event"'
|
||||||
script:
|
when: never
|
||||||
- shadow-cljs compile test
|
- if: '$CI_COMMIT_TAG =~ /^[0-9]+\.[0-9]+\.[0-9]+$/'
|
||||||
- node target/node-tests.js
|
|
||||||
|
|
||||||
test-clj:
|
test-clj:
|
||||||
<<: *clj
|
<<: *clj
|
||||||
stage: build_and_test
|
stage: build_and_test
|
||||||
script:
|
script:
|
||||||
- lein test
|
- pyb test_clj
|
||||||
|
|
||||||
|
test-cljs:
|
||||||
|
<<: *cljs
|
||||||
|
stage: build_and_test
|
||||||
|
script:
|
||||||
|
- pyb test_cljs
|
||||||
|
|
||||||
test-schema:
|
test-schema:
|
||||||
<<: *clj
|
<<: *clj
|
||||||
stage: build_and_test
|
stage: build_and_test
|
||||||
script:
|
script:
|
||||||
- lein uberjar
|
- pyb test_schema
|
||||||
- java -jar target/uberjar/c4k-taiga-standalone.jar src/test/resources/taiga-test/valid-config.yaml src/test/resources/taiga-test/valid-auth.yaml | kubeconform --kubernetes-version 1.23.0 --strict --skip Certificate -
|
|
||||||
artifacts:
|
artifacts:
|
||||||
expire_in: 1h
|
|
||||||
paths:
|
paths:
|
||||||
- target/uberjar
|
- target/uberjar
|
||||||
|
|
||||||
|
@ -58,10 +70,8 @@ report-frontend:
|
||||||
<<: *cljs
|
<<: *cljs
|
||||||
stage: package
|
stage: package
|
||||||
script:
|
script:
|
||||||
- mkdir -p target/frontend-build
|
- pyb report_frontend
|
||||||
- shadow-cljs run shadow.cljs.build-report frontend target/frontend-build/build-report.html
|
|
||||||
artifacts:
|
artifacts:
|
||||||
expire_in: 1h
|
|
||||||
paths:
|
paths:
|
||||||
- target/frontend-build/build-report.html
|
- target/frontend-build/build-report.html
|
||||||
|
|
||||||
|
@ -69,13 +79,8 @@ package-frontend:
|
||||||
<<: *cljs
|
<<: *cljs
|
||||||
stage: package
|
stage: package
|
||||||
script:
|
script:
|
||||||
- mkdir -p target/frontend-build
|
- pyb package_frontend
|
||||||
- shadow-cljs release frontend
|
|
||||||
- cp public/js/main.js target/frontend-build/c4k-taiga.js
|
|
||||||
- sha256sum target/frontend-build/c4k-taiga.js > target/frontend-build/c4k-taiga.js.sha256
|
|
||||||
- sha512sum target/frontend-build/c4k-taiga.js > target/frontend-build/c4k-taiga.js.sha512
|
|
||||||
artifacts:
|
artifacts:
|
||||||
expire_in: 1h
|
|
||||||
paths:
|
paths:
|
||||||
- target/frontend-build
|
- target/frontend-build
|
||||||
|
|
||||||
|
@ -83,47 +88,28 @@ package-uberjar:
|
||||||
<<: *clj
|
<<: *clj
|
||||||
stage: package
|
stage: package
|
||||||
script:
|
script:
|
||||||
- lein uberjar
|
- pyb package_uberjar
|
||||||
- sha256sum target/uberjar/c4k-taiga-standalone.jar > target/uberjar/c4k-taiga-standalone.jar.sha256
|
|
||||||
- sha512sum target/uberjar/c4k-taiga-standalone.jar > target/uberjar/c4k-taiga-standalone.jar.sha512
|
|
||||||
artifacts:
|
artifacts:
|
||||||
expire_in: 1h
|
|
||||||
paths:
|
|
||||||
- target/uberjar
|
|
||||||
|
|
||||||
upload-clj-release:
|
|
||||||
<<: *clj
|
|
||||||
stage: upload
|
|
||||||
rules:
|
|
||||||
- if: '$CI_COMMIT_TAG != null'
|
|
||||||
script:
|
|
||||||
- lein deploy
|
|
||||||
|
|
||||||
release:
|
|
||||||
image: registry.gitlab.com/gitlab-org/release-cli:latest
|
|
||||||
stage: upload
|
|
||||||
rules:
|
|
||||||
- if: '$CI_COMMIT_TAG != null'
|
|
||||||
artifacts:
|
|
||||||
expire_in: 24h
|
|
||||||
paths:
|
paths:
|
||||||
- target/uberjar
|
- target/uberjar
|
||||||
- target/frontend-build
|
|
||||||
script:
|
|
||||||
- apk --no-cache add curl
|
|
||||||
- |
|
|
||||||
release-cli create --name "Release $CI_COMMIT_TAG" --tag-name $CI_COMMIT_TAG \
|
|
||||||
--assets-link "{\"name\":\"c4k-taiga-standalone.jar\",\"url\":\"https://gitlab.com/domaindrivenarchitecture/c4k-taiga/-/jobs/${CI_JOB_ID}/artifacts/file/target/uberjar/c4k-taiga-standalone.jar\"}" \
|
|
||||||
--assets-link "{\"name\":\"c4k-taiga-standalone.jar.sha256\",\"url\":\"https://gitlab.com/domaindrivenarchitecture/c4k-taiga/-/jobs/${CI_JOB_ID}/artifacts/file/target/uberjar/c4k-taiga-standalone.jar.sha256\"}" \
|
|
||||||
--assets-link "{\"name\":\"c4k-taiga-standalone.jar.sha512\",\"url\":\"https://gitlab.com/domaindrivenarchitecture/c4k-taiga/-/jobs/${CI_JOB_ID}/artifacts/file/target/uberjar/c4k-taiga-standalone.jar.sha512\"}" \
|
|
||||||
--assets-link "{\"name\":\"c4k-taiga.js\",\"url\":\"https://gitlab.com/domaindrivenarchitecture/c4k-taiga/-/jobs/${CI_JOB_ID}/artifacts/file/target/frontend-build/c4k-taiga.js\"}" \
|
|
||||||
--assets-link "{\"name\":\"c4k-taiga.js.sha256\",\"url\":\"https://gitlab.com/domaindrivenarchitecture/c4k-taiga/-/jobs/${CI_JOB_ID}/artifacts/file/target/frontend-build/c4k-taiga.js.sha256\"}" \
|
|
||||||
--assets-link "{\"name\":\"c4k-taiga.js.sha512\",\"url\":\"https://gitlab.com/domaindrivenarchitecture/c4k-taiga/-/jobs/${CI_JOB_ID}/artifacts/file/target/frontend-build/c4k-taiga.js.sha512\"}" \
|
|
||||||
|
|
||||||
taiga-image-test-publish:
|
release-to-clojars:
|
||||||
image: domaindrivenarchitecture/devops-build:latest
|
<<: *clj
|
||||||
stage: image
|
<<: *tag_only
|
||||||
rules:
|
stage: upload
|
||||||
- if: '$CI_COMMIT_TAG != null'
|
|
||||||
script:
|
script:
|
||||||
- cd infrastructure/c4k-taiga-build && pyb image test publish
|
- pyb upload_clj
|
||||||
|
|
||||||
|
release-to-forgejo:
|
||||||
|
<<: *clj
|
||||||
|
<<: *tag_only
|
||||||
|
stage: upload
|
||||||
|
script:
|
||||||
|
- pyb publish_artifacts
|
||||||
|
|
||||||
|
backup-image-publish:
|
||||||
|
<<: *img
|
||||||
|
<<: *tag_only
|
||||||
|
stage: image
|
||||||
|
script:
|
||||||
|
- cd infrastructure/backup && pyb image publish
|
||||||
|
|
180
build.py
Normal file
180
build.py
Normal file
|
@ -0,0 +1,180 @@
|
||||||
|
from os import environ
|
||||||
|
from subprocess import run
|
||||||
|
from pybuilder.core import init, task
|
||||||
|
from ddadevops import *
|
||||||
|
|
||||||
|
default_task = "dev"
|
||||||
|
base_name = "taiga"
|
||||||
|
name = 'c4k-taiga'
|
||||||
|
MODULE = 'not-used'
|
||||||
|
PROJECT_ROOT_PATH = '.'
|
||||||
|
|
||||||
|
@init
|
||||||
|
def initialize(project):
|
||||||
|
project.build_depends_on("ddadevops>=4.7.0")
|
||||||
|
|
||||||
|
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": [
|
||||||
|
"package.json",
|
||||||
|
"infrastructure/backup/build.py",
|
||||||
|
],
|
||||||
|
"release_artifact_server_url": "https://repo.prod.meissa.de",
|
||||||
|
"release_organisation": "meissa",
|
||||||
|
"release_repository_name": name,
|
||||||
|
"release_artifacts": [
|
||||||
|
f"target/uberjar/{name}-standalone.jar",
|
||||||
|
f"target/frontend-build/{name}.js",
|
||||||
|
],
|
||||||
|
"release_main_branch": "master",
|
||||||
|
}
|
||||||
|
|
||||||
|
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 test_schema(project):
|
||||||
|
run("lein uberjar", shell=True, check=True)
|
||||||
|
run(
|
||||||
|
f"java -jar target/uberjar/{name}-standalone.jar "
|
||||||
|
+ f"src/test/resources/{base_name}-test/valid-config.yaml "
|
||||||
|
+ f"src/test/resources/{base_name}-test/valid-auth.yaml | "
|
||||||
|
+ "kubeconform --kubernetes-version 1.23.0 --strict --skip Certificate -",
|
||||||
|
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(
|
||||||
|
f"cp public/js/main.js target/frontend-build/{name}.js",
|
||||||
|
shell=True,
|
||||||
|
check=True,
|
||||||
|
)
|
||||||
|
run(
|
||||||
|
f"sha256sum target/frontend-build/{name}.js > target/frontend-build/{name}.js.sha256",
|
||||||
|
shell=True,
|
||||||
|
check=True,
|
||||||
|
)
|
||||||
|
run(
|
||||||
|
f"sha512sum target/frontend-build/{name}.js > target/frontend-build/{name}.js.sha512",
|
||||||
|
shell=True,
|
||||||
|
check=True,
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
@task
|
||||||
|
def package_uberjar(project):
|
||||||
|
run(
|
||||||
|
f"sha256sum target/uberjar/{name}-standalone.jar > target/uberjar/{name}-standalone.jar.sha256",
|
||||||
|
shell=True,
|
||||||
|
check=True,
|
||||||
|
)
|
||||||
|
run(
|
||||||
|
f"sha512sum target/uberjar/{name}-standalone.jar > target/uberjar/{name}-standalone.jar.sha512",
|
||||||
|
shell=True,
|
||||||
|
check=True,
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
@task
|
||||||
|
def upload_clj(project):
|
||||||
|
run("lein deploy", 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()
|
||||||
|
|
||||||
|
@task
|
||||||
|
def publish_artifacts(project):
|
||||||
|
build = get_devops_build(project)
|
||||||
|
build.publish_artifacts()
|
||||||
|
|
||||||
|
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)
|
||||||
|
test_schema(project)
|
||||||
|
lint(project)
|
Loading…
Reference in a new issue