2022-03-23 02:32:41 +00:00
|
|
|
# Crafty Controller 4.0 - Lint & Build Pipes
|
|
|
|
# [Maintainer: Zedifus(https://gitlab.com/Zedifus)]
|
|
|
|
###################################################
|
|
|
|
# yamllint disable rule:line-length
|
|
|
|
---
|
2021-09-10 21:15:47 +00:00
|
|
|
stages:
|
2022-03-23 02:41:19 +00:00
|
|
|
- lint
|
|
|
|
- prod-deployment
|
|
|
|
- dev-deployment
|
2021-09-10 21:15:47 +00:00
|
|
|
|
2021-12-21 01:25:04 +00:00
|
|
|
variables:
|
|
|
|
DOCKER_HOST: tcp://docker:2376
|
|
|
|
DOCKER_TLS_CERTDIR: "/certs"
|
|
|
|
|
2022-03-23 02:05:02 +00:00
|
|
|
yamllint:
|
|
|
|
stage: lint
|
|
|
|
image: registry.gitlab.com/pipeline-components/yamllint:latest
|
2022-03-23 02:12:18 +00:00
|
|
|
tags:
|
2022-03-24 19:28:37 +00:00
|
|
|
- "docker"
|
2022-03-23 02:12:18 +00:00
|
|
|
rules:
|
|
|
|
- if: '$CI_PIPELINE_SOURCE == "merge_request_event"'
|
2022-03-24 19:28:37 +00:00
|
|
|
- if: "$CI_COMMIT_BRANCH && $CI_OPEN_MERGE_REQUESTS"
|
2022-03-23 02:12:18 +00:00
|
|
|
when: never
|
2022-03-23 02:05:02 +00:00
|
|
|
script:
|
|
|
|
- yamllint .
|
|
|
|
|
2022-03-23 02:01:41 +00:00
|
|
|
jsonlint:
|
|
|
|
stage: lint
|
|
|
|
image: registry.gitlab.com/pipeline-components/jsonlint:latest
|
|
|
|
tags:
|
2022-03-24 19:28:37 +00:00
|
|
|
- "docker"
|
2022-03-23 02:01:41 +00:00
|
|
|
rules:
|
|
|
|
- if: '$CI_PIPELINE_SOURCE == "merge_request_event"'
|
2022-03-24 19:28:37 +00:00
|
|
|
- if: "$CI_COMMIT_BRANCH && $CI_OPEN_MERGE_REQUESTS"
|
2022-03-23 02:01:41 +00:00
|
|
|
when: never
|
|
|
|
script:
|
|
|
|
- |
|
|
|
|
find . -not -path './.git/*' -name '*.json' -type f -print0 |
|
|
|
|
parallel --will-cite -k -0 -n1 jsonlint -q
|
|
|
|
|
2022-03-23 01:57:46 +00:00
|
|
|
black:
|
|
|
|
stage: lint
|
|
|
|
image: registry.gitlab.com/pipeline-components/black:latest
|
|
|
|
tags:
|
2022-03-24 19:28:37 +00:00
|
|
|
- "docker"
|
2022-03-23 01:57:46 +00:00
|
|
|
rules:
|
|
|
|
- if: '$CI_PIPELINE_SOURCE == "merge_request_event"'
|
2022-03-24 19:28:37 +00:00
|
|
|
- if: "$CI_COMMIT_BRANCH && $CI_OPEN_MERGE_REQUESTS"
|
2022-03-23 01:57:46 +00:00
|
|
|
when: never
|
|
|
|
script:
|
|
|
|
- black --check --verbose -- .
|
|
|
|
|
2022-01-26 01:45:30 +00:00
|
|
|
pylint:
|
2022-03-23 01:57:46 +00:00
|
|
|
stage: lint
|
2022-03-24 19:34:11 +00:00
|
|
|
image: registry.gitlab.com/pipeline-components/pylint:latest
|
2022-01-26 01:45:30 +00:00
|
|
|
tags:
|
2022-03-24 19:28:37 +00:00
|
|
|
- "docker"
|
2022-01-26 01:45:30 +00:00
|
|
|
rules:
|
|
|
|
- if: '$CI_PIPELINE_SOURCE == "merge_request_event"'
|
2022-03-24 19:28:37 +00:00
|
|
|
- if: "$CI_COMMIT_BRANCH && $CI_OPEN_MERGE_REQUESTS"
|
2022-01-26 01:45:30 +00:00
|
|
|
when: never
|
2022-03-24 19:34:11 +00:00
|
|
|
# before_script:
|
|
|
|
# - mkdir -p public/badges public/lint
|
|
|
|
# - echo undefined > public/badges/$CI_JOB_NAME.score
|
2022-01-26 01:45:30 +00:00
|
|
|
script:
|
2022-03-24 19:28:37 +00:00
|
|
|
# - pylint --exit-zero --output-format=text $(find -type f -name "*.py" ! -path "**/.venv/**" ! -path "**/app/migrations/**") | tee /tmp/pylint.txt
|
|
|
|
# - sed -n 's/^Your code has been rated at \([-0-9.]*\)\/.*/\1/p' /tmp/pylint.txt > public/badges/$CI_JOB_NAME.score
|
2022-01-26 01:45:30 +00:00
|
|
|
- pylint --exit-zero --output-format=pylint_gitlab.GitlabCodeClimateReporter $(find -type f -name "*.py" ! -path "**/.venv/**" ! -path "**/app/migrations/**") > codeclimate.json
|
2022-03-24 19:28:37 +00:00
|
|
|
# after_script:
|
|
|
|
# - anybadge --overwrite --label $CI_JOB_NAME --value=$(cat public/badges/$CI_JOB_NAME.score) --file=public/badges/$CI_JOB_NAME.svg 4=red 6=orange 8=yellow 10=green
|
|
|
|
# - |
|
|
|
|
# echo "Your score is: $(cat public/badges/$CI_JOB_NAME.score)"
|
|
|
|
# Removed lint badge generation until public release
|
2022-01-26 01:45:30 +00:00
|
|
|
artifacts:
|
|
|
|
paths:
|
|
|
|
- public
|
|
|
|
reports:
|
|
|
|
codequality: codeclimate.json
|
|
|
|
when: always
|
|
|
|
|
2021-09-10 21:15:47 +00:00
|
|
|
docker-build-dev:
|
|
|
|
image: docker:latest
|
|
|
|
services:
|
|
|
|
- name: docker:dind
|
2022-01-12 22:22:51 +00:00
|
|
|
stage: dev-deployment
|
2021-09-21 00:52:18 +00:00
|
|
|
tags:
|
2022-03-24 19:28:37 +00:00
|
|
|
- "docker_priv"
|
2021-09-10 21:15:47 +00:00
|
|
|
rules:
|
|
|
|
- if: $CI_COMMIT_BRANCH == 'dev'
|
|
|
|
environment:
|
|
|
|
name: development
|
|
|
|
before_script:
|
2022-03-24 21:45:00 +00:00
|
|
|
- |
|
|
|
|
apk --no-cache add jq
|
|
|
|
MAJOR=$(cat app/config/version.json | jq '.major' )
|
|
|
|
MINOR=$(cat app/config/version.json | jq '.minor' )
|
|
|
|
SUB=$(cat app/config/version.json | jq '.sub' )
|
2022-03-24 22:07:50 +00:00
|
|
|
META=$(cat app/config/version.json | jq -r '.meta' )
|
2021-09-22 18:02:28 +00:00
|
|
|
- |
|
|
|
|
apk --no-cache add curl
|
|
|
|
latest_tag=$(curl -s https://api.github.com/repos/docker/buildx/releases/latest | sed -Ene '/^ *"tag_name": *"(v.+)",$/s//\1/p')
|
|
|
|
echo "Using buildx version $latest_tag"
|
|
|
|
curl -sSLo docker-buildx "https://github.com/docker/buildx/releases/download/$latest_tag/buildx-$latest_tag.linux-amd64"
|
|
|
|
chmod a+x docker-buildx
|
|
|
|
mkdir -p ~/.docker/cli-plugins
|
|
|
|
mv docker-buildx ~/.docker/cli-plugins/docker-buildx
|
|
|
|
docker version
|
2021-12-21 03:40:39 +00:00
|
|
|
- docker run --rm --privileged aptman/qus -- -r
|
|
|
|
- docker run --rm --privileged aptman/qus -s -- -p aarch64 x86_64
|
2021-09-22 18:02:28 +00:00
|
|
|
- echo $CI_BUILD_TOKEN | docker login -u "$CI_REGISTRY_USER" --password-stdin $CI_REGISTRY
|
2021-09-10 21:15:47 +00:00
|
|
|
script:
|
|
|
|
- |
|
|
|
|
tag=":$CI_COMMIT_REF_SLUG"
|
2022-03-24 21:45:00 +00:00
|
|
|
VERSION="${MAJOR}.${MINOR}.${SUB}-${META}"
|
|
|
|
- |
|
2021-09-10 21:15:47 +00:00
|
|
|
echo "Running on branch '$CI_COMMIT_BRANCH': tag = $tag"
|
2022-03-24 21:45:00 +00:00
|
|
|
echo "Crafty Version: $VERSION"
|
2021-12-21 01:25:04 +00:00
|
|
|
- docker context create tls-environment
|
|
|
|
- docker buildx create --name zedBuilder --use tls-environment
|
2021-09-10 21:15:47 +00:00
|
|
|
- docker buildx build
|
|
|
|
--cache-from type=registry,ref="$CI_REGISTRY_IMAGE${tag}"
|
|
|
|
--build-arg BUILDKIT_INLINE_CACHE=1
|
2022-03-24 21:45:00 +00:00
|
|
|
--build-arg "BUILD_DATE=$(date +"%Y-%m-%dT%H:%M:%SZ")"
|
|
|
|
--build-arg "BUILD_REF=${CI_COMMIT_SHA}"
|
|
|
|
--build-arg "CRAFTY_VER=${VERSION}"
|
2021-09-10 21:15:47 +00:00
|
|
|
--tag "$CI_REGISTRY_IMAGE${tag}"
|
|
|
|
--platform linux/arm64/v8,linux/amd64
|
|
|
|
--push .
|
|
|
|
after_script:
|
2021-09-22 17:35:36 +00:00
|
|
|
- |
|
|
|
|
docker buildx rm zedBuilder && echo "Successfully Stopped builder instance" || echo "Failed to stop builder instance."
|
2021-12-21 01:25:04 +00:00
|
|
|
docker context rm tls-environment || true
|
2021-09-22 17:35:36 +00:00
|
|
|
echo "Please review multi-arch manifests are present:"
|
2021-09-22 17:53:00 +00:00
|
|
|
docker buildx imagetools inspect "$CI_REGISTRY_IMAGE:$CI_COMMIT_REF_SLUG"
|
2021-09-10 21:15:47 +00:00
|
|
|
|
|
|
|
docker-build-prod:
|
|
|
|
image: docker:latest
|
|
|
|
services:
|
|
|
|
- name: docker:dind
|
2022-01-12 22:22:51 +00:00
|
|
|
stage: prod-deployment
|
2021-09-21 00:52:18 +00:00
|
|
|
tags:
|
2022-03-24 19:28:37 +00:00
|
|
|
- "docker_priv"
|
2021-09-10 21:15:47 +00:00
|
|
|
rules:
|
|
|
|
- if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH
|
|
|
|
environment:
|
|
|
|
name: production
|
|
|
|
before_script:
|
2022-03-24 21:45:00 +00:00
|
|
|
- |
|
|
|
|
apk --no-cache add jq
|
|
|
|
MAJOR=$(cat app/config/version.json | jq '.major' )
|
|
|
|
MINOR=$(cat app/config/version.json | jq '.minor' )
|
|
|
|
SUB=$(cat app/config/version.json | jq '.sub' )
|
2022-03-24 22:07:50 +00:00
|
|
|
META=$(cat app/config/version.json | jq -r '.meta' )
|
2021-09-22 18:02:28 +00:00
|
|
|
- |
|
|
|
|
apk --no-cache add curl
|
|
|
|
latest_tag=$(curl -s https://api.github.com/repos/docker/buildx/releases/latest | sed -Ene '/^ *"tag_name": *"(v.+)",$/s//\1/p')
|
|
|
|
echo "Using buildx version $latest_tag"
|
|
|
|
curl -sSLo docker-buildx "https://github.com/docker/buildx/releases/download/$latest_tag/buildx-$latest_tag.linux-amd64"
|
|
|
|
chmod a+x docker-buildx
|
|
|
|
mkdir -p ~/.docker/cli-plugins
|
|
|
|
mv docker-buildx ~/.docker/cli-plugins/docker-buildx
|
|
|
|
docker version
|
2021-12-21 03:40:39 +00:00
|
|
|
- docker run --rm --privileged aptman/qus -- -r
|
|
|
|
- docker run --rm --privileged aptman/qus -s -- -p aarch64 x86_64
|
2021-09-22 18:02:28 +00:00
|
|
|
- echo $CI_BUILD_TOKEN | docker login -u "$CI_REGISTRY_USER" --password-stdin $CI_REGISTRY
|
2021-09-10 21:15:47 +00:00
|
|
|
script:
|
|
|
|
- |
|
|
|
|
tag=""
|
2022-03-24 21:45:00 +00:00
|
|
|
VERSION="${MAJOR}.${MINOR}.${SUB}-${META}"
|
|
|
|
- |
|
|
|
|
echo "Running on branch '$CI_COMMIT_BRANCH': tag = $tag"
|
|
|
|
echo "Crafty Version: $VERSION"
|
2021-12-21 01:25:04 +00:00
|
|
|
- docker context create tls-environment
|
|
|
|
- docker buildx create --name zedBuilder --use tls-environment
|
2021-09-10 21:15:47 +00:00
|
|
|
- docker buildx build
|
|
|
|
--cache-from type=registry,ref="$CI_REGISTRY_IMAGE${tag}"
|
|
|
|
--build-arg BUILDKIT_INLINE_CACHE=1
|
2022-03-24 21:45:00 +00:00
|
|
|
--build-arg "BUILD_DATE=$(date +"%Y-%m-%dT%H:%M:%SZ")"
|
|
|
|
--build-arg "BUILD_REF=${CI_COMMIT_SHA}"
|
|
|
|
--build-arg "CRAFTY_VER=${VERSION}"
|
2021-09-10 21:15:47 +00:00
|
|
|
--tag "$CI_REGISTRY_IMAGE${tag}"
|
|
|
|
--platform linux/arm64/v8,linux/amd64
|
|
|
|
--push .
|
|
|
|
after_script:
|
2021-09-22 17:35:36 +00:00
|
|
|
- |
|
|
|
|
docker buildx rm zedBuilder && echo "Successfully Stopped builder instance" || echo "Failed to stop builder instance."
|
2021-12-21 01:25:04 +00:00
|
|
|
docker context rm tls-environment || true
|
2021-09-22 17:35:36 +00:00
|
|
|
echo "Please review multi-arch manifests are present:"
|
2021-09-22 17:53:00 +00:00
|
|
|
docker buildx imagetools inspect "$CI_REGISTRY_IMAGE${tag}"
|
2021-09-23 01:59:55 +00:00
|
|
|
|
|
|
|
win-dev-build:
|
2022-01-12 22:22:51 +00:00
|
|
|
stage: dev-deployment
|
2021-09-23 01:59:55 +00:00
|
|
|
tags:
|
2022-03-23 02:32:41 +00:00
|
|
|
- win64
|
2021-09-23 01:59:55 +00:00
|
|
|
cache:
|
|
|
|
paths:
|
|
|
|
- .venv/
|
|
|
|
rules:
|
2022-03-23 02:32:41 +00:00
|
|
|
- if: "$CI_COMMIT_BRANCH == 'dev'"
|
2021-09-23 01:59:55 +00:00
|
|
|
environment:
|
|
|
|
name: development
|
|
|
|
script:
|
2022-03-23 02:32:41 +00:00
|
|
|
- |
|
|
|
|
$ErrorActionPreference = "Stop"
|
|
|
|
py -m venv .venv
|
|
|
|
.venv\Scripts\activate.ps1
|
|
|
|
pip install pyinstaller
|
|
|
|
pip install -r requirements.txt
|
|
|
|
- pyinstaller -F main.py
|
|
|
|
--distpath .
|
|
|
|
--icon app\frontend\static\assets\images\Crafty_4-0_Logo_square.ico
|
|
|
|
--name "crafty_commander"
|
|
|
|
--paths .venv\Lib\site-packages
|
|
|
|
--hidden-import cryptography
|
|
|
|
--hidden-import cffi
|
|
|
|
--hidden-import apscheduler
|
|
|
|
--collect-all tzlocal
|
|
|
|
--collect-all tzdata
|
|
|
|
--collect-all pytz
|
|
|
|
--collect-all six
|
2022-01-14 22:48:13 +00:00
|
|
|
|
2022-03-23 02:41:19 +00:00
|
|
|
# Download latest:
|
|
|
|
# | https://gitlab.com/crafty-controller/crafty-commander/-/jobs/artifacts/dev/download?job=win-dev-build
|
2021-09-23 01:59:55 +00:00
|
|
|
artifacts:
|
2021-11-22 04:18:18 +00:00
|
|
|
name: "crafty-${CI_RUNNER_TAGS}-${CI_COMMIT_BRANCH}_${CI_COMMIT_SHORT_SHA}"
|
2021-09-23 01:59:55 +00:00
|
|
|
paths:
|
2022-03-23 02:32:41 +00:00
|
|
|
- app\
|
|
|
|
- .\crafty_commander.exe
|
2021-09-24 22:10:43 +00:00
|
|
|
exclude:
|
2022-03-23 02:32:41 +00:00
|
|
|
- app\classes\**\*
|
2022-03-23 02:41:19 +00:00
|
|
|
|
2021-09-23 01:59:55 +00:00
|
|
|
win-prod-build:
|
2022-01-12 22:22:51 +00:00
|
|
|
stage: prod-deployment
|
2021-09-23 01:59:55 +00:00
|
|
|
tags:
|
2022-03-23 02:32:41 +00:00
|
|
|
- win64
|
2021-09-23 01:59:55 +00:00
|
|
|
cache:
|
|
|
|
paths:
|
|
|
|
- .venv/
|
|
|
|
rules:
|
2022-03-23 02:32:41 +00:00
|
|
|
- if: "$CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH"
|
2021-09-23 01:59:55 +00:00
|
|
|
environment:
|
|
|
|
name: production
|
|
|
|
script:
|
2022-03-23 02:32:41 +00:00
|
|
|
- |
|
|
|
|
$ErrorActionPreference = "Stop"
|
|
|
|
py -m venv .venv
|
|
|
|
.venv\Scripts\activate.ps1
|
|
|
|
pip install pyinstaller
|
|
|
|
pip install -r requirements.txt
|
|
|
|
- pyinstaller -F main.py
|
|
|
|
--distpath .
|
|
|
|
--icon app\frontend\static\assets\images\Crafty_4-0_Logo_square.ico
|
|
|
|
--name "crafty_commander"
|
|
|
|
--paths .venv\Lib\site-packages
|
|
|
|
--hidden-import cryptography
|
|
|
|
--hidden-import cffi
|
|
|
|
--hidden-import apscheduler
|
|
|
|
--collect-all tzlocal
|
|
|
|
--collect-all tzdata
|
|
|
|
--collect-all pytz
|
|
|
|
--collect-all six
|
2022-01-14 22:32:41 +00:00
|
|
|
|
2022-03-23 02:41:19 +00:00
|
|
|
# Download latest:
|
|
|
|
# | https://gitlab.com/crafty-controller/crafty-commander/-/jobs/artifacts/master/download?job=win-prod-build
|
2021-09-23 01:59:55 +00:00
|
|
|
artifacts:
|
2021-11-22 04:18:18 +00:00
|
|
|
name: "crafty-${CI_RUNNER_TAGS}-${CI_COMMIT_BRANCH}_${CI_COMMIT_SHORT_SHA}"
|
2021-09-23 01:59:55 +00:00
|
|
|
paths:
|
2022-03-23 02:32:41 +00:00
|
|
|
- app\
|
|
|
|
- .\crafty_commander.exe
|
2021-09-24 22:10:43 +00:00
|
|
|
exclude:
|
2022-03-23 02:32:41 +00:00
|
|
|
- app\classes\**\*
|