diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml new file mode 100644 index 0000000..1c2364e --- /dev/null +++ b/.gitlab-ci.yml @@ -0,0 +1,12 @@ +include: + - local: .gitlab/defaults.yml + - local: .gitlab/shellcheck.yml + - local: .gitlab/sync-github.yml + +stages: + - lint + - sync + +sync-github: + variables: + GITHUB_REPO: DSS diff --git a/.gitlab/defaults.yml b/.gitlab/defaults.yml new file mode 100644 index 0000000..9ddd043 --- /dev/null +++ b/.gitlab/defaults.yml @@ -0,0 +1,32 @@ +.default_rules: + merge_only: + - if: $CI_PIPELINE_SOURCE == "merge_request_event" + variables: + BRANCH_NAME: $CI_MERGE_REQUEST_TARGET_BRANCH_NAME + SONAR_BRANCH: '' + - if: $CI_PIPELINE_SOURCE == "schedule" + when: never + - if: $CI_PIPELINE_SOURCE == "web" + merge_and_push: + - if: $CI_PIPELINE_SOURCE == "merge_request_event" + variables: + BRANCH_NAME: $CI_MERGE_REQUEST_TARGET_BRANCH_NAME + SONAR_BRANCH: '' + - if: $CI_COMMIT_BRANCH == "master" && $CI_PIPELINE_SOURCE == "push" + - if: $CI_COMMIT_BRANCH =~ /^stable\/.*/ && $CI_PIPELINE_SOURCE == "push" + - if: $CI_PIPELINE_SOURCE == "schedule" + when: never + - if: $CI_PIPELINE_SOURCE == "web" + push_only: + - if: $CI_COMMIT_BRANCH == "master" && $CI_PIPELINE_SOURCE == "push" + - if: $CI_COMMIT_BRANCH =~ /^stable\/.*/ && $CI_PIPELINE_SOURCE == "push" + scheduled_sync: + - if: $CI_PIPELINE_SOURCE == "schedule" && $SCHEDULE_TYPE == "sync" + +variables: + BRANCH_NAME: $CI_COMMIT_BRANCH + SONAR_BRANCH: -Dsonar.branch.name=$CI_COMMIT_BRANCH + +default: + image: + name: dss-build_$BRANCH_NAME diff --git a/.gitlab/shellcheck.yml b/.gitlab/shellcheck.yml new file mode 100644 index 0000000..22bcd51 --- /dev/null +++ b/.gitlab/shellcheck.yml @@ -0,0 +1,68 @@ +shellcheck: + stage: lint + image: koalaman/shellcheck-alpine:$SHELLCHECK_VER + before_script: + - apk update + - apk add git xmlstarlet + - shellcheck --version + - | + cat > checkstyle2junit.xslt < + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Line + + : + + See https://www.shellcheck.net/wiki/ + + + + + EOL + script: + - git ls-files --exclude='*.sh' --ignored -c -z | + xargs -t --no-run-if-empty -0 shellcheck --format=checkstyle | + xmlstarlet tr checkstyle2junit.xslt > + shellcheck.xml + artifacts: + when: always + reports: + junit: shellcheck.xml + variables: + SHELLCHECK_VER: v0.9.0 + needs: [] + rules: + - !reference [.default_rules, merge_and_push] diff --git a/.gitlab/sync-github.yml b/.gitlab/sync-github.yml new file mode 100644 index 0000000..d796442 --- /dev/null +++ b/.gitlab/sync-github.yml @@ -0,0 +1,21 @@ +sync-github: + stage: sync + image: + name: alpine:3.19.1 + before_script: + - apk add git + - git config --global http.sslVerify false + script: + - mkdir $GITHUB_REPO && cd $GITHUB_REPO + - git clone --branch $GITHUB_BRANCH https://github.com/$GITHUB_PROJECT/$GITHUB_REPO . + - git remote rename origin old-origin + - git remote add origin https://$CI_USERNAME:$CI_TOKEN@$CI_SERVER_HOST/$CI_PROJECT_PATH.git + - git push origin $GITHUB_BRANCH:$GITLAB_BRANCH + - git push -u origin --tags + variables: + GIT_STRATEGY: none + GITHUB_PROJECT: OpenMPDK + GITHUB_BRANCH: master + GITLAB_BRANCH: master + rules: + - !reference [.default_rules, scheduled_sync]