2021-02-23 17:32:00 +00:00
|
|
|
stages:
|
2021-03-17 14:35:55 +00:00
|
|
|
- first
|
2021-02-23 17:32:00 +00:00
|
|
|
- build_and_test
|
|
|
|
- package
|
|
|
|
- security
|
|
|
|
- upload
|
|
|
|
|
|
|
|
.cljs-job: &cljs
|
2021-03-12 18:01:48 +00:00
|
|
|
image: domaindrivenarchitecture/shadow-cljs
|
2021-02-23 17:32:00 +00:00
|
|
|
cache:
|
|
|
|
key: ${CI_COMMIT_REF_SLUG}
|
|
|
|
paths:
|
|
|
|
- node_modules/
|
|
|
|
- .shadow-cljs/
|
2021-03-12 18:01:48 +00:00
|
|
|
- .m2
|
2021-02-23 17:32:00 +00:00
|
|
|
before_script:
|
|
|
|
- echo "//registry.npmjs.org/:_authToken=$NPM_TOKEN" > ~/.npmrc
|
2021-03-17 07:24:18 +00:00
|
|
|
- npm install
|
2021-02-23 17:32:00 +00:00
|
|
|
|
2021-03-17 07:24:18 +00:00
|
|
|
.clj-uploadjob: &clj
|
2021-03-12 18:01:48 +00:00
|
|
|
image: clojure:lein-2.7.1-alpine
|
|
|
|
cache:
|
|
|
|
key: ${CI_COMMIT_REF_SLUG}
|
|
|
|
paths:
|
|
|
|
- .m2
|
|
|
|
before_script:
|
|
|
|
- echo "{:auth {:repository-auth {#\"clojars\" {:username \"${CLOJARS_USER}\" :password \"${CLOJARS_PASSWORD}\" }}}}" > ~/.lein/profiles.clj
|
|
|
|
|
2021-03-17 07:59:58 +00:00
|
|
|
test-cljs:
|
2021-02-23 17:32:00 +00:00
|
|
|
<<: *cljs
|
|
|
|
stage: build_and_test
|
|
|
|
script:
|
|
|
|
- shadow-cljs compile test
|
|
|
|
|
2021-03-17 07:59:58 +00:00
|
|
|
test-clj:
|
|
|
|
<<: *clj
|
|
|
|
stage: build_and_test
|
|
|
|
script:
|
|
|
|
- lein test
|
|
|
|
|
2021-03-17 08:17:08 +00:00
|
|
|
report-frontend:
|
2021-02-23 17:32:00 +00:00
|
|
|
<<: *cljs
|
2021-03-17 08:17:08 +00:00
|
|
|
stage: package
|
2021-02-23 17:32:00 +00:00
|
|
|
script:
|
2021-03-17 07:24:18 +00:00
|
|
|
- mkdir -p target
|
2021-03-12 18:01:48 +00:00
|
|
|
- shadow-cljs run shadow.cljs.build-report frontend target/build-report.html
|
2021-02-23 17:32:00 +00:00
|
|
|
artifacts:
|
|
|
|
paths:
|
|
|
|
- target/build-report.html
|
|
|
|
|
2021-03-17 07:59:58 +00:00
|
|
|
package-frontend:
|
2021-02-23 17:32:00 +00:00
|
|
|
<<: *cljs
|
|
|
|
stage: package
|
|
|
|
script:
|
2021-03-17 07:59:58 +00:00
|
|
|
- mkdir -p target/frontend-build
|
|
|
|
- shadow-cljs release frontend
|
|
|
|
- cp public/js/main.js target/frontend-build/k8s-mastodon-bot.js
|
|
|
|
- sha256sum target/frontend-build/k8s-mastodon-bot.js > target/frontend-build/k8s-mastodon-bot.js.sha256
|
|
|
|
- sha512sum target/frontend-build/k8s-mastodon-bot.js > target/frontend-build/k8s-mastodon-bot.js.sha512
|
2021-02-23 17:32:00 +00:00
|
|
|
artifacts:
|
|
|
|
paths:
|
2021-03-17 07:59:58 +00:00
|
|
|
- target/frontend-build
|
|
|
|
|
|
|
|
package-uberjar:
|
|
|
|
<<: *clj
|
|
|
|
stage: package
|
|
|
|
script:
|
|
|
|
- lein uberjar
|
|
|
|
- sha256sum target/uberjar/k8s-mastodon-bot-standalone.jar > target/uberjar/k8s-mastodon-bot-standalone.jar.sha256
|
|
|
|
- sha512sum target/uberjar/k8s-mastodon-bot-standalone.jar > target/uberjar/k8s-mastodon-bot-standalone.jar.sha512
|
|
|
|
artifacts:
|
|
|
|
paths:
|
|
|
|
- target/uberjar
|
2021-02-23 17:32:00 +00:00
|
|
|
|
|
|
|
sast:
|
|
|
|
variables:
|
|
|
|
SAST_EXCLUDED_ANALYZERS:
|
|
|
|
bandit, brakeman, flawfinder, gosec, kubesec, phpcs-security-audit,
|
|
|
|
pmd-apex, security-code-scan, sobelow, spotbugs
|
|
|
|
stage: security
|
|
|
|
before_script:
|
|
|
|
- mkdir -p builds && cp -r target/ builds/
|
|
|
|
include:
|
|
|
|
- template: Security/SAST.gitlab-ci.yml
|
|
|
|
|
2021-03-12 18:01:48 +00:00
|
|
|
upload-clj-prerelease:
|
2021-03-17 07:24:18 +00:00
|
|
|
<<: *clj
|
2021-03-12 18:01:48 +00:00
|
|
|
stage: upload
|
|
|
|
rules:
|
|
|
|
- if: '$CI_COMMIT_BRANCH == "master" && $CI_COMMIT_TAG == null'
|
|
|
|
script:
|
|
|
|
- lein deploy clojars
|
|
|
|
|
2021-03-17 07:59:58 +00:00
|
|
|
release:
|
|
|
|
# Caution, as of 2021-02-02 these assets links require a login, see:
|
|
|
|
# https://gitlab.com/gitlab-org/gitlab/-/issues/299384
|
|
|
|
image: registry.gitlab.com/gitlab-org/release-cli:latest
|
2021-03-17 14:45:15 +00:00
|
|
|
stage: upload
|
|
|
|
rules:
|
|
|
|
- if: '$CI_COMMIT_TAG != null'
|
2021-03-17 07:59:58 +00:00
|
|
|
variables:
|
|
|
|
PACKAGE_REGISTRY_URL: "${CI_API_V4_URL}/projects/${CI_PROJECT_ID}/packages/generic"
|
|
|
|
UBERJAR_URL: "${PACKAGE_REGISTRY_URL}/k8s-mastodon-bot-standalone/${$CI_COMMIT_TAG}/k8s-mastodon-bot-standalone.jar"
|
|
|
|
FRONTEND_URL: "${PACKAGE_REGISTRY_URL}/k8s-mastodon-bot/${$CI_COMMIT_TAG}/k8s-mastodon-bot.js"
|
2021-02-23 17:32:00 +00:00
|
|
|
script:
|
2021-03-17 14:35:55 +00:00
|
|
|
- apk --no-cache add curl
|
2021-03-17 07:59:58 +00:00
|
|
|
- |
|
|
|
|
curl --header "JOB-TOKEN: ${CI_JOB_TOKEN}" --upload-file target/uberjar/k8s-mastodon-bot-standalone.jar ${UBERJAR_URL}
|
|
|
|
- |
|
|
|
|
curl --header "JOB-TOKEN: ${CI_JOB_TOKEN}" --upload-file target/frontend-build/k8s-mastodon-bot.js ${FRONTEND_URL}
|
|
|
|
- |
|
|
|
|
release-cli create --name "Release $CI_COMMIT_TAG" --tag-name $CI_COMMIT_TAG \
|
|
|
|
--assets-link "{\"name\":\"k8s-mastodon-bot-standalone.jar\",\"url\":\"${UBERJAR_URL}\"}" \
|
|
|
|
--assets-link "{\"name\":\"k8s-mastodon-bot.js\",\"url\":\"${FRONTEND_URL}\"}"
|