diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index e7dd9d87..44f556b4 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -34,270 +34,9 @@ stages: - test - build -.rules-branch-and-MR-manual: - rules: - - if: $CI_COMMIT_BRANCH || $CI_PIPELINE_SOURCE == "merge_request_event" - when: manual - allow_failure: true - - when: never +include: + - local: ci/rules.yml + - local: ci/env.yml + - local: ci/test.yml + - local: ci/build.yml -.rules-branch-manual-MR-and-devel-always: - rules: - - if: $CI_COMMIT_BRANCH == "devel" || $CI_PIPELINE_SOURCE == "merge_request_event" - when: always - allow_failure: false - - if: $CI_COMMIT_BRANCH - when: manual - allow_failure: true - - when: never - -.rules-branch-manual-scheduled-and-test-branch-always: - rules: - - if: $CI_PIPELINE_SOURCE == "schedule" - when: always - allow_failure: false - - if: $CI_MERGE_REQUEST_SOURCE_BRANCH_NAME=~ /^test/ - when: always - allow_failure: false - - if: $CI_COMMIT_BRANCH - when: manual - allow_failure: true - - when: never - -# ENV -.env-windows: - before_script: - - export BRIDGE_SYNC_FORCE_MINIMUM_SPEC=1 - - export GOROOT=/c/Go1.20/ - - export PATH=$GOROOT/bin:$PATH - - export GOARCH=amd64 - - export GOPATH=~/go1.20 - - export GO111MODULE=on - - export PATH="${GOPATH}/bin:${PATH}" - - export MSYSTEM= - - export QT6DIR=/c/grrrQt/6.4.3/msvc2019_64 - - export PATH=$PATH:${QT6DIR}/bin - - export PATH="/c/Program Files/Microsoft Visual Studio/2022/Community/Common7/IDE/CommonExtensions/Microsoft/CMake/CMake/bin:$PATH" - - $(git config --global -l | grep -o 'url.*gitlab.protontech.ch.*insteadof' | xargs -L 1 git config --global --unset &> /dev/null) || echo "nothing to remove" - - git config --global url.https://gitlab-ci-token:${CI_JOB_TOKEN}@${CI_SERVER_HOST}.insteadOf https://${CI_SERVER_HOST} - - git config --global safe.directory '*' - - git status --porcelain - cache: {} - tags: - - windows-bridge - -.env-darwin: - before_script: - - export BRIDGE_SYNC_FORCE_MINIMUM_SPEC=1 - - export PATH=/usr/local/bin:$PATH - - export PATH=/usr/local/opt/git/bin:$PATH - - export PATH=/usr/local/opt/make/libexec/gnubin:$PATH - - export PATH=/usr/local/opt/gnu-sed/libexec/gnubin:$PATH - - export GOROOT=~/local/opt/go@1.20 - - export PATH="${GOROOT}/bin:$PATH" - - export GOPATH=~/go1.20 - - export PATH="${GOPATH}/bin:$PATH" - - export QT6DIR=/opt/Qt/6.4.3/macos - - export PATH="${QT6DIR}/bin:$PATH" - - uname -a - cache: {} - tags: - - macos-m1-bridge - -.env-linux-build: - image: gitlab.protontech.ch:4567/go/bridge-internal:build-go1.20-qt6.4.3 - variables: - VCPKG_DEFAULT_BINARY_CACHE: ${CI_PROJECT_DIR}/.cache - cache: - key: linux-vcpkg - paths: - - .cache - when: 'always' - before_script: - - mkdir -p .cache/bin - - export BRIDGE_SYNC_FORCE_MINIMUM_SPEC=1 - - export PATH=$(pwd)/.cache/bin:$PATH - - export GOPATH="$CI_PROJECT_DIR/.cache" - - export PATH=$PATH:$QT6DIR/bin - - $(git config --global -l | grep -o 'url.*gitlab.protontech.ch.*insteadof' | xargs -L 1 git config --global --unset &> /dev/null) || echo "nothing to remove" - - git config --global url.https://gitlab-ci-token:${CI_JOB_TOKEN}@${CI_SERVER_HOST}.insteadOf https://${CI_SERVER_HOST} - tags: - - shared-large - -# Stage: TEST - -lint: - stage: test - extends: - - .rules-branch-manual-MR-and-devel-always - script: - - make lint - tags: - - shared-medium - -bug-report-preview: - stage: test - extends: - - .rules-branch-and-MR-manual - script: - - make lint-bug-report-preview - tags: - - shared-medium - -.script-test: - stage: test - extends: - - .rules-branch-manual-MR-and-devel-always - script: - - make test - artifacts: - paths: - - coverage/** - -test-linux: - extends: - - .script-test - tags: - - shared-large - -fuzz-linux: - stage: test - extends: - - .rules-branch-manual-MR-and-devel-always - script: - - make fuzz - tags: - - shared-large - -test-linux-race: - extends: - - test-linux - - .rules-branch-and-MR-manual - script: - - make test-race - -test-integration: - extends: - - test-linux - script: - - make test-integration - -test-integration-race: - extends: - - test-integration - - .rules-branch-and-MR-manual - script: - - make test-integration-race - -test-integration-nightly: - extends: - - test-integration - - .rules-branch-manual-scheduled-and-test-branch-always - needs: - - test-integration - script: - - make test-integration-nightly - -test-windows: - extends: - - .env-windows - - .script-test - -test-darwin: - extends: - - .env-darwin - - .script-test - -test-coverage: - stage: test - extends: - - .rules-branch-manual-scheduled-and-test-branch-always - script: - - ./utils/coverage.sh - coverage: '/total:.*\(statements\).*\d+\.\d+%/' - needs: - - test-linux - - test-windows - - test-darwin - - test-integration - - test-integration-nightly - tags: - - shared-small - artifacts: - paths: - - coverage* - - coverage/** - when: 'always' - reports: - coverage_report: - coverage_format: cobertura - path: coverage.xml - -# Stage: BUILD - -.script-build: - stage: build - needs: ["lint"] - extends: - - .rules-branch-and-MR-manual - script: - - make build - - git diff && git diff-index --quiet HEAD - - make vault-editor - artifacts: - expire_in: 1 day - when: always - name: "$CI_JOB_NAME-$CI_COMMIT_SHORT_SHA" - paths: - - bridge_*.tgz - - vault-editor - -build-linux: - extends: - - .script-build - - .env-linux-build - -build-linux-qa: - extends: - - build-linux - - .rules-branch-manual-MR-and-devel-always - variables: - BUILD_TAGS: "build_qa" - -build-darwin: - extends: - - .script-build - - .env-darwin - -build-darwin-qa: - extends: - - build-darwin - variables: - BUILD_TAGS: "build_qa" - -build-windows: - extends: - - .script-build - - .env-windows - -build-windows-qa: - extends: - - build-windows - variables: - BUILD_TAGS: "build_qa" - -trigger-qa-installer: - stage: build - needs: ["lint"] - extends: - - .rules-branch-and-MR-manual - variables: - APP: bridge - WORKFLOW: build-all - SRC_TAG: $CI_COMMIT_BRANCH - SRC_HASH: $CI_COMMIT_SHA - trigger: - project: "jcuth/bridge-release" - branch: master - -# TODO: PUT BACK ALL THE JOBS! JUST DID THIS FOR NOW TO GET CI WORKING AGAIN... diff --git a/ci/build.yml b/ci/build.yml new file mode 100644 index 00000000..50628571 --- /dev/null +++ b/ci/build.yml @@ -0,0 +1,68 @@ + +--- + +.script-build: + stage: build + needs: ["lint"] + extends: + - .rules-branch-and-MR-manual + script: + - make build + - git diff && git diff-index --quiet HEAD + - make vault-editor + artifacts: + expire_in: 1 day + when: always + name: "$CI_JOB_NAME-$CI_COMMIT_SHORT_SHA" + paths: + - bridge_*.tgz + - vault-editor + +build-linux: + extends: + - .script-build + - .env-linux-build + +build-linux-qa: + extends: + - build-linux + - .rules-branch-manual-MR-and-devel-always + variables: + BUILD_TAGS: "build_qa" + +build-darwin: + extends: + - .script-build + - .env-darwin + +build-darwin-qa: + extends: + - build-darwin + variables: + BUILD_TAGS: "build_qa" + +build-windows: + extends: + - .script-build + - .env-windows + +build-windows-qa: + extends: + - build-windows + variables: + BUILD_TAGS: "build_qa" + +trigger-qa-installer: + stage: build + needs: ["lint"] + extends: + - .rules-branch-and-MR-manual + variables: + APP: bridge + WORKFLOW: build-all + SRC_TAG: $CI_COMMIT_BRANCH + SRC_HASH: $CI_COMMIT_SHA + trigger: + project: "jcuth/bridge-release" + branch: master + diff --git a/ci/env.yml b/ci/env.yml new file mode 100644 index 00000000..4968666a --- /dev/null +++ b/ci/env.yml @@ -0,0 +1,62 @@ + +--- + +.env-windows: + before_script: + - export BRIDGE_SYNC_FORCE_MINIMUM_SPEC=1 + - export GOROOT=/c/Go1.20/ + - export PATH=$GOROOT/bin:$PATH + - export GOARCH=amd64 + - export GOPATH=~/go1.20 + - export GO111MODULE=on + - export PATH="${GOPATH}/bin:${PATH}" + - export MSYSTEM= + - export QT6DIR=/c/grrrQt/6.4.3/msvc2019_64 + - export PATH=$PATH:${QT6DIR}/bin + - export PATH="/c/Program Files/Microsoft Visual Studio/2022/Community/Common7/IDE/CommonExtensions/Microsoft/CMake/CMake/bin:$PATH" + - $(git config --global -l | grep -o 'url.*gitlab.protontech.ch.*insteadof' | xargs -L 1 git config --global --unset &> /dev/null) || echo "nothing to remove" + - git config --global url.https://gitlab-ci-token:${CI_JOB_TOKEN}@${CI_SERVER_HOST}.insteadOf https://${CI_SERVER_HOST} + - git config --global safe.directory '*' + - git status --porcelain + cache: {} + tags: + - windows-bridge + +.env-darwin: + before_script: + - export BRIDGE_SYNC_FORCE_MINIMUM_SPEC=1 + - export PATH=/usr/local/bin:$PATH + - export PATH=/usr/local/opt/git/bin:$PATH + - export PATH=/usr/local/opt/make/libexec/gnubin:$PATH + - export PATH=/usr/local/opt/gnu-sed/libexec/gnubin:$PATH + - export GOROOT=~/local/opt/go@1.20 + - export PATH="${GOROOT}/bin:$PATH" + - export GOPATH=~/go1.20 + - export PATH="${GOPATH}/bin:$PATH" + - export QT6DIR=/opt/Qt/6.4.3/macos + - export PATH="${QT6DIR}/bin:$PATH" + - uname -a + cache: {} + tags: + - macos-m1-bridge + +.env-linux-build: + image: gitlab.protontech.ch:4567/go/bridge-internal:build-go1.20-qt6.4.3 + variables: + VCPKG_DEFAULT_BINARY_CACHE: ${CI_PROJECT_DIR}/.cache + cache: + key: linux-vcpkg + paths: + - .cache + when: 'always' + before_script: + - mkdir -p .cache/bin + - export BRIDGE_SYNC_FORCE_MINIMUM_SPEC=1 + - export PATH=$(pwd)/.cache/bin:$PATH + - export GOPATH="$CI_PROJECT_DIR/.cache" + - export PATH=$PATH:$QT6DIR/bin + - $(git config --global -l | grep -o 'url.*gitlab.protontech.ch.*insteadof' | xargs -L 1 git config --global --unset &> /dev/null) || echo "nothing to remove" + - git config --global url.https://gitlab-ci-token:${CI_JOB_TOKEN}@${CI_SERVER_HOST}.insteadOf https://${CI_SERVER_HOST} + tags: + - shared-large + diff --git a/ci/rules.yml b/ci/rules.yml new file mode 100644 index 00000000..5cf90bc2 --- /dev/null +++ b/ci/rules.yml @@ -0,0 +1,32 @@ + +--- + +.rules-branch-and-MR-manual: + rules: + - if: $CI_COMMIT_BRANCH || $CI_PIPELINE_SOURCE == "merge_request_event" + when: manual + allow_failure: true + - when: never + +.rules-branch-manual-MR-and-devel-always: + rules: + - if: $CI_COMMIT_BRANCH == "devel" || $CI_PIPELINE_SOURCE == "merge_request_event" + when: always + allow_failure: false + - if: $CI_COMMIT_BRANCH + when: manual + allow_failure: true + - when: never + +.rules-branch-manual-scheduled-and-test-branch-always: + rules: + - if: $CI_PIPELINE_SOURCE == "schedule" + when: always + allow_failure: false + - if: $CI_MERGE_REQUEST_SOURCE_BRANCH_NAME=~ /^test/ + when: always + allow_failure: false + - if: $CI_COMMIT_BRANCH + when: manual + allow_failure: true + - when: never diff --git a/ci/test.yml b/ci/test.yml new file mode 100644 index 00000000..12812d01 --- /dev/null +++ b/ci/test.yml @@ -0,0 +1,109 @@ + +--- + +lint: + stage: test + extends: + - .rules-branch-manual-MR-and-devel-always + script: + - make lint + tags: + - shared-medium + +bug-report-preview: + stage: test + extends: + - .rules-branch-and-MR-manual + script: + - make lint-bug-report-preview + tags: + - shared-medium + +.script-test: + stage: test + extends: + - .rules-branch-manual-MR-and-devel-always + script: + - make test + artifacts: + paths: + - coverage/** + +test-linux: + extends: + - .script-test + tags: + - shared-large + +fuzz-linux: + stage: test + extends: + - .rules-branch-manual-MR-and-devel-always + script: + - make fuzz + tags: + - shared-large + +test-linux-race: + extends: + - test-linux + - .rules-branch-and-MR-manual + script: + - make test-race + +test-integration: + extends: + - test-linux + script: + - make test-integration + +test-integration-race: + extends: + - test-integration + - .rules-branch-and-MR-manual + script: + - make test-integration-race + +test-integration-nightly: + extends: + - test-integration + - .rules-branch-manual-scheduled-and-test-branch-always + needs: + - test-integration + script: + - make test-integration-nightly + +test-windows: + extends: + - .env-windows + - .script-test + +test-darwin: + extends: + - .env-darwin + - .script-test + +test-coverage: + stage: test + extends: + - .rules-branch-manual-scheduled-and-test-branch-always + script: + - ./utils/coverage.sh + coverage: '/total:.*\(statements\).*\d+\.\d+%/' + needs: + - test-linux + - test-windows + - test-darwin + - test-integration + - test-integration-nightly + tags: + - shared-small + artifacts: + paths: + - coverage* + - coverage/** + when: 'always' + reports: + coverage_report: + coverage_format: cobertura + path: coverage.xml