didi-website-erp-crm/erp_crm/.gitlab-ci.yml

102 lines
2.5 KiB
YAML

# DiDi ERP/CRM (ERPNext v15 + custom app didi_custom) — GitLab CI/CD
# ===================================================================
stages:
- security
- lint
- test
- build
- deploy
- release
security:gitleaks:
stage: security
image:
name: zricethezav/gitleaks:latest
entrypoint: [""]
script:
- gitleaks detect --source . --no-banner --report-format json --report-path gitleaks-report.json
artifacts:
when: on_failure
paths: [gitleaks-report.json]
expire_in: 1 month
allow_failure: true
rules:
- if: $CI_PIPELINE_SOURCE == "merge_request_event"
- if: $CI_COMMIT_BRANCH == "main"
lint:python:
stage: lint
image: python:3.11-slim
before_script:
- pip install --quiet ruff black
script:
- ruff check didi_custom/ scripts/ || true
- black --check didi_custom/ scripts/ || true
allow_failure: true
rules:
- if: $CI_PIPELINE_SOURCE == "merge_request_event"
- if: $CI_COMMIT_BRANCH == "main"
lint:shell:
stage: lint
image: koalaman/shellcheck-alpine:latest
script:
- shellcheck build-from-zero.sh seed-data.sh bin/*.sh || true
allow_failure: true
rules:
- if: $CI_PIPELINE_SOURCE == "merge_request_event"
test:doctype-validation:
stage: test
image: python:3.11-slim
before_script:
- pip install --quiet jsonschema
script:
- python3 -c "
import json, glob;
for f in glob.glob('didi_custom/**/doctype/*/*.json', recursive=True):
d = json.load(open(f));
assert 'doctype' in d.get('doctype', d), f'Bad doctype in {f}';
print(f'OK: {f}')
"
rules:
- if: $CI_PIPELINE_SOURCE == "merge_request_event"
changes: [didi_custom/**/*]
- if: $CI_COMMIT_BRANCH == "main"
build:image:
stage: build
script:
- docker compose build
rules:
- if: $CI_COMMIT_BRANCH == "main"
when: manual
tags: [shell, docker]
deploy:staging:
stage: deploy
script:
- ./build-from-zero.sh
- python3 scripts/setup/01-config.py
- python3 scripts/setup/02-doctypes.py
- python3 scripts/setup/08-email.py
environment:
name: staging
url: http://erp.example.com
rules:
- if: $CI_COMMIT_BRANCH == "main"
when: manual
tags: [shell, docker]
release:
stage: release
image: registry.gitlab.com/gitlab-org/release-cli:latest
script:
- echo "Release ${CI_COMMIT_TAG}"
release:
tag_name: '$CI_COMMIT_TAG'
name: 'Release $CI_COMMIT_TAG'
description: 'ERP/CRM release $CI_COMMIT_TAG'
rules:
- if: $CI_COMMIT_TAG =~ /^v[0-9]+\.[0-9]+\.[0-9]+$/