2023-10-25 01:13:32 +08:00
|
|
|
variables:
|
|
|
|
BUILD_DIR: "/data/openpilot"
|
|
|
|
OUTPUT_DIR: "${CI_PROJECT_DIR}/output"
|
|
|
|
CI_DIR: "${CI_PROJECT_DIR}/release/ci"
|
2023-12-10 08:14:14 +08:00
|
|
|
VERSION: 'echo $(date "+%Y.%m.%d")'
|
2023-10-25 01:13:32 +08:00
|
|
|
GIT_SUBMODULE_STRATEGY: recursive
|
|
|
|
GIT_DISCOVERY_ACROSS_FILESYSTEM: 1
|
|
|
|
DEV_C3_SOURCE_BRANCH: "master-dev-c3"
|
2023-12-06 02:19:18 +08:00
|
|
|
GIT_CONFIG_USER_EMAIL: "gitlab@pipeline.com"
|
|
|
|
GIT_CONFIG_USER_NAME: "Gitlab Pipeline"
|
2023-12-09 19:58:25 +08:00
|
|
|
PUBLIC_REPO_URL: "https://github.com/sunnyhaibin/sunnypilot"
|
2024-08-02 22:26:14 +08:00
|
|
|
BASE_BUILD_NUMER: 3000
|
|
|
|
|
|
|
|
EXTRA_VERSION_IDENTIFIER: "${CI_PIPELINE_IID}"
|
|
|
|
NEW_BRANCH: ${CI_COMMIT_REF_NAME}-prebuilt
|
2023-10-25 01:13:32 +08:00
|
|
|
|
|
|
|
stages:
|
|
|
|
- build
|
2024-02-15 01:51:26 +08:00
|
|
|
- sanity
|
2023-10-25 01:13:32 +08:00
|
|
|
- publish
|
2023-12-09 19:58:25 +08:00
|
|
|
- notify
|
2023-10-25 01:13:32 +08:00
|
|
|
|
|
|
|
default:
|
2023-12-07 00:05:58 +08:00
|
|
|
retry: 2
|
2023-10-25 01:13:32 +08:00
|
|
|
tags:
|
|
|
|
- sunnypilot
|
|
|
|
- x86
|
|
|
|
|
|
|
|
.default_before_script: &default_before_script
|
2024-08-02 22:26:14 +08:00
|
|
|
- 'if [ "$EXTRA_VERSION_IDENTIFIER" = "$CI_PIPELINE_IID" ]; then export EXTRA_VERSION_IDENTIFIER=$((CI_PIPELINE_IID + BASE_BUILD_NUMER)); fi'
|
|
|
|
- 'export VERSION=$(eval $VERSION)-${EXTRA_VERSION_IDENTIFIER}'
|
2023-10-25 01:13:32 +08:00
|
|
|
- 'mkdir -p "${BUILD_DIR}/"'
|
2023-12-06 02:19:18 +08:00
|
|
|
- 'git config --global user.email "${GIT_CONFIG_USER_EMAIL}"'
|
|
|
|
- 'git config --global user.name "${GIT_CONFIG_USER_NAME}"'
|
2023-10-25 01:13:32 +08:00
|
|
|
|
|
|
|
|
2024-07-26 17:24:27 +08:00
|
|
|
workflow: # If running on any branch other than main.
|
2023-10-25 01:13:32 +08:00
|
|
|
rules:
|
|
|
|
# We are an MR, but it's a draft, we won't proceed with anything.
|
|
|
|
- if: '$CI_MERGE_REQUEST_TITLE =~ /^wip:/i || $CI_MERGE_REQUEST_TITLE =~ /^draft:/i'
|
|
|
|
when: never
|
|
|
|
|
|
|
|
# Below are the rules when a commit is done (code has been added to the branch)
|
|
|
|
# Commit to master-dev-c3
|
|
|
|
- if: $CI_COMMIT_REF_NAME == $DEV_C3_SOURCE_BRANCH
|
|
|
|
variables:
|
2024-08-02 22:26:14 +08:00
|
|
|
EXTRA_VERSION_IDENTIFIER: "${CI_PIPELINE_IID}"
|
2023-10-25 01:13:32 +08:00
|
|
|
NEW_BRANCH: "dev-c3"
|
2024-08-02 22:26:14 +08:00
|
|
|
AUTO_BUILD: true
|
2023-10-25 01:13:32 +08:00
|
|
|
when: always
|
|
|
|
#commit made to main (master)
|
|
|
|
- if: $CI_COMMIT_REF_NAME == $CI_DEFAULT_BRANCH
|
|
|
|
variables:
|
|
|
|
NEW_BRANCH: "staging-c3"
|
2023-12-10 08:14:14 +08:00
|
|
|
VERSION: 'cat common/version.h | grep COMMA_VERSION | sed -e "s/[^0-9|.]//g"'
|
2024-08-02 22:26:14 +08:00
|
|
|
EXTRA_VERSION_IDENTIFIER: "staging"
|
2024-08-02 00:10:59 +08:00
|
|
|
AUTO_PUBLISH: true
|
2024-08-02 22:26:14 +08:00
|
|
|
AUTO_BUILD: true
|
2023-10-25 01:13:32 +08:00
|
|
|
when: always
|
|
|
|
# if tag
|
|
|
|
- if: $CI_COMMIT_TAG
|
|
|
|
variables:
|
|
|
|
NEW_BRANCH: "release-c3"
|
2023-12-10 08:58:28 +08:00
|
|
|
VERSION: 'cat common/version.h | grep COMMA_VERSION | sed -e "s/[^0-9|.]//g"'
|
2024-08-02 22:26:14 +08:00
|
|
|
EXTRA_VERSION_IDENTIFIER: "release"
|
|
|
|
AUTO_BUILD: true
|
2023-10-25 01:13:32 +08:00
|
|
|
- when: always
|
|
|
|
|
|
|
|
|
|
|
|
build:
|
|
|
|
stage: build
|
|
|
|
cache:
|
|
|
|
key: "${CI_COMMIT_REF_SLUG}"
|
|
|
|
paths:
|
|
|
|
- "${CI_DIR}/scons_cache"
|
|
|
|
before_script:
|
2024-02-15 01:51:26 +08:00
|
|
|
- find $BUILD_DIR/ -mindepth 1 -delete
|
2023-10-25 01:13:32 +08:00
|
|
|
- *default_before_script
|
|
|
|
- "echo Starting build stage..."
|
|
|
|
- "echo BUILD_DIR: ${BUILD_DIR}"
|
|
|
|
- "echo CI_DIR: ${CI_DIR}"
|
|
|
|
- "echo VERSION: ${VERSION}"
|
|
|
|
- "echo CI_COMMIT_REF_NAME: ${CI_COMMIT_REF_NAME}"
|
|
|
|
- git config --global --add safe.directory ${CI_PROJECT_DIR}
|
|
|
|
script:
|
|
|
|
- export PYTHONPATH="$BUILD_DIR"
|
|
|
|
- "echo Building Panda..."
|
|
|
|
- scons -j$(nproc) cache_dir=${CI_DIR}/scons_cache ${CI_PROJECT_DIR}/panda
|
|
|
|
- mkdir -p ${BUILD_DIR}
|
|
|
|
- ls -la ${BUILD_DIR}
|
|
|
|
- "echo Building Rest..."
|
2024-06-13 02:20:30 +08:00
|
|
|
- ./release/release_files.py | sort | uniq | rsync -vrRl --files-from=- . $BUILD_DIR/
|
|
|
|
# - cp -pR --parents $(cat release/files_common release/files_tici | sort | uniq) $BUILD_DIR/ 2> >(grep -v 'warning:' >&2)
|
2023-10-25 01:13:32 +08:00
|
|
|
- cd $BUILD_DIR
|
|
|
|
- sed -i '/from .board.jungle import PandaJungle, PandaJungleDFU/s/^/#/' panda/__init__.py # comment panda jungle when prebuilt
|
2024-06-13 02:20:30 +08:00
|
|
|
- scons -j$(nproc) cache_dir=${CI_DIR}/scons_cache --minimal
|
2023-10-25 01:13:32 +08:00
|
|
|
- touch ${BUILD_DIR}/prebuilt
|
2024-08-02 00:10:59 +08:00
|
|
|
- sudo rm -rf ${OUTPUT_DIR}
|
2023-10-25 01:13:32 +08:00
|
|
|
- mkdir -p ${OUTPUT_DIR}
|
2024-02-15 01:51:26 +08:00
|
|
|
# We first include the paths we want to keep, even if we later will be excluding the other things on those paths
|
2024-06-13 02:20:30 +08:00
|
|
|
- rsync -avm
|
2024-02-15 01:51:26 +08:00
|
|
|
--include='**/panda/board/'
|
|
|
|
--include='**/panda/board/obj'
|
|
|
|
--include='**/panda/board/obj/panda.bin.signed'
|
|
|
|
--include='**/panda/board/obj/panda_h7.bin.signed'
|
|
|
|
--include='**/panda/board/obj/bootstub.panda.bin'
|
|
|
|
--include='**/panda/board/obj/bootstub.panda_h7.bin'
|
|
|
|
--exclude='.sconsign.dblite'
|
|
|
|
--exclude='*.a'
|
|
|
|
--exclude='*.A'
|
|
|
|
--exclude='*.o'
|
|
|
|
--exclude='*.O'
|
|
|
|
--exclude='*.os'
|
|
|
|
--exclude='*.OS'
|
|
|
|
--exclude='*.pyc'
|
|
|
|
--exclude='*.PYC'
|
|
|
|
--exclude='moc_*'
|
|
|
|
--exclude='MOC_*'
|
|
|
|
--exclude='*.cc'
|
|
|
|
--exclude='*.CC'
|
|
|
|
--exclude='Jenkinsfile'
|
|
|
|
--exclude='supercombo.onnx'
|
|
|
|
--exclude='**/panda/board/*'
|
|
|
|
--exclude='**/panda/board/obj/**'
|
|
|
|
--exclude='**/panda/certs/'
|
|
|
|
--exclude='**/panda/crypto/'
|
|
|
|
--exclude='**/release/'
|
|
|
|
--exclude='**/.github/'
|
|
|
|
--exclude='**/selfdrive/ui/replay/'
|
|
|
|
--exclude='**/__pycache__/'
|
2024-02-15 02:40:40 +08:00
|
|
|
--exclude='**/selfdrive/ui/*.h'
|
2024-02-15 01:51:26 +08:00
|
|
|
--exclude='**/selfdrive/ui/**/*.h'
|
|
|
|
--exclude='**/selfdrive/ui/qt/offroad/sunnypilot/'
|
|
|
|
--exclude='**/.git/'
|
2024-07-16 10:59:02 +08:00
|
|
|
--exclude='**/SConstruct'
|
|
|
|
--exclude='**/SConscript'
|
2024-02-15 01:51:26 +08:00
|
|
|
--delete-excluded
|
|
|
|
--chown=comma:comma
|
|
|
|
${BUILD_DIR}/ ${OUTPUT_DIR}/
|
|
|
|
after_script:
|
2024-08-02 00:10:59 +08:00
|
|
|
# cleanup build dir after doing work
|
2024-02-15 01:51:26 +08:00
|
|
|
- find $BUILD_DIR/ -mindepth 1 -delete
|
2023-10-25 01:13:32 +08:00
|
|
|
artifacts:
|
|
|
|
paths:
|
|
|
|
- ${OUTPUT_DIR}/
|
|
|
|
tags: [ 'sunnypilot', 'tici' ]
|
|
|
|
rules:
|
2024-08-02 22:26:14 +08:00
|
|
|
- if: $AUTO_BUILD
|
2023-10-25 01:13:32 +08:00
|
|
|
when: always
|
2024-08-02 22:26:14 +08:00
|
|
|
- when: manual
|
2023-10-25 01:13:32 +08:00
|
|
|
|
2023-12-09 23:12:57 +08:00
|
|
|
.publish_base: &publish_base
|
2024-04-02 00:14:42 +08:00
|
|
|
image: alpine
|
2023-10-25 01:13:32 +08:00
|
|
|
variables:
|
|
|
|
GIT_SUBMODULE_STRATEGY: normal
|
2023-12-09 23:12:57 +08:00
|
|
|
stage: publish
|
2023-12-06 02:19:18 +08:00
|
|
|
needs:
|
|
|
|
- job: build
|
|
|
|
artifacts: true
|
2023-10-25 01:13:32 +08:00
|
|
|
before_script:
|
|
|
|
- 'apk update && apk upgrade'
|
|
|
|
- 'apk add git bash openssh'
|
|
|
|
- 'eval $(ssh-agent -s)'
|
|
|
|
- echo "$SSH_PRIVATE_KEY" | tr -d '\r' | ssh-add -
|
|
|
|
- 'mkdir -p ~/.ssh/'
|
|
|
|
- 'chmod 700 ~/.ssh'
|
2023-12-09 23:12:57 +08:00
|
|
|
- export HOST=$(echo ${GIT_ORIGIN} | cut -d'@' -f2 | cut -d':' -f1)
|
|
|
|
- echo fetching ssh pub keys for ${HOST}
|
|
|
|
- 'ssh-keyscan -H ${HOST} >> ~/.ssh/known_hosts' # Adding gitlab to trusted
|
2023-10-25 01:13:32 +08:00
|
|
|
- 'chmod 644 ~/.ssh/known_hosts'
|
|
|
|
- *default_before_script
|
|
|
|
script:
|
|
|
|
- echo "${GIT_ORIGIN}"
|
|
|
|
- echo "Calling to publish [${CI_DIR}/publish.sh ${CI_PROJECT_DIR} ${OUTPUT_DIR} ${NEW_BRANCH} ${VERSION} ${GIT_ORIGIN}]"
|
|
|
|
- git config --global --add safe.directory ${OUTPUT_DIR}
|
2024-08-02 22:26:14 +08:00
|
|
|
- $CI_DIR/publish.sh "${CI_PROJECT_DIR}" "${OUTPUT_DIR}" "${NEW_BRANCH}" "${VERSION}" "${GIT_ORIGIN}" "-${EXTRA_VERSION_IDENTIFIER}"
|
2024-06-14 23:32:11 +08:00
|
|
|
allow_failure: false
|
2023-12-09 23:12:57 +08:00
|
|
|
|
|
|
|
publish to private gitlab prebuilt:
|
|
|
|
extends: ".publish_base"
|
|
|
|
variables:
|
2024-08-01 07:47:34 +08:00
|
|
|
GIT_ORIGIN: git@gitlab.com:sunnypilot/public/sunnypilot-prebuilts.git
|
2023-10-25 01:13:32 +08:00
|
|
|
rules:
|
2024-08-02 22:26:14 +08:00
|
|
|
- if: $AUTO_BUILD
|
|
|
|
when: on_success
|
|
|
|
- if: $CI_MERGE_REQUEST_IID
|
2023-10-25 01:13:32 +08:00
|
|
|
when: on_success
|
2024-08-02 22:26:14 +08:00
|
|
|
- when: manual
|
2023-12-07 00:05:58 +08:00
|
|
|
|
2023-12-09 23:12:57 +08:00
|
|
|
publish to public github prebuilt:
|
|
|
|
extends: ".publish_base"
|
2023-10-25 01:13:32 +08:00
|
|
|
variables:
|
2023-12-07 01:49:58 +08:00
|
|
|
GIT_ORIGIN: git@github.com:sunnyhaibin/sunnypilot.git
|
2023-12-06 02:19:18 +08:00
|
|
|
GIT_CONFIG_USER_EMAIL: "jason.wen@sunnypilot.ai"
|
|
|
|
GIT_CONFIG_USER_NAME: "Jason Wen"
|
2023-10-25 01:13:32 +08:00
|
|
|
rules:
|
2024-08-02 00:10:59 +08:00
|
|
|
- if: $AUTO_PUBLISH
|
|
|
|
when: on_success
|
2024-08-02 22:26:14 +08:00
|
|
|
- when: manual
|
2023-12-09 19:58:25 +08:00
|
|
|
|
|
|
|
.notify_discord: ¬ify_discord
|
2024-04-02 00:14:42 +08:00
|
|
|
image: alpine
|
2023-12-09 19:58:25 +08:00
|
|
|
stage: notify
|
|
|
|
needs: ["build"]
|
|
|
|
variables:
|
|
|
|
DISCORD_HOOK: "${DISCORD_MANUAL_BUILD_WEBHOOK_URL}" # Default hook if not overriden by children
|
|
|
|
before_script:
|
|
|
|
- 'apk add curl jq envsubst'
|
|
|
|
script:
|
|
|
|
- echo using [${TEMPLATE}]
|
|
|
|
- cat release/ci/${TEMPLATE} | envsubst | tee payload.json
|
|
|
|
- 'curl -X POST -H "Content-Type: application/json" -d "$(cat payload.json)" ${DISCORD_HOOK} | jq .'
|
|
|
|
rules:
|
|
|
|
- if: $NEW_BRANCH
|
|
|
|
when: on_success
|
|
|
|
- when: never
|
|
|
|
allow_failure: true
|
|
|
|
|
|
|
|
notify pending action:
|
|
|
|
extends: ".notify_discord"
|
|
|
|
variables:
|
|
|
|
TEMPLATE: "discord_template_notify_dev_private.json"
|
|
|
|
before_script:
|
|
|
|
- !reference [".notify_discord", "before_script"]
|
|
|
|
- export AVATAR_URL=$(curl -s -X GET "https://gitlab.com/api/v4/avatar?email=${GITLAB_USER_EMAIL}" | jq -r '.avatar_url')
|
|
|
|
|
|
|
|
notify new dev build:
|
|
|
|
extends: ".notify_discord"
|
|
|
|
stage: notify
|
2023-12-09 23:12:57 +08:00
|
|
|
needs: ["publish to public github prebuilt"] # This notify shall only happen after a publish to github public
|
2023-12-09 19:58:25 +08:00
|
|
|
variables:
|
|
|
|
TEMPLATE: "discord_template_notify_dev_public.json"
|
2024-08-02 23:38:25 +08:00
|
|
|
before_script:
|
|
|
|
- !reference [".notify_discord", "before_script"]
|
|
|
|
- export EXTRA_VERSION_IDENTIFIER=$((CI_PIPELINE_IID + BASE_BUILD_NUMER))
|
2023-12-09 19:58:25 +08:00
|
|
|
rules:
|
|
|
|
- if: $NEW_BRANCH == "dev-c3"
|
|
|
|
variables:
|
|
|
|
DISCORD_HOOK: "${DISCORD_NEW_BUILD_WEBHOOK_URL}" # Overriding hook because we know we are dev-c3
|
|
|
|
- !reference [".notify_discord", "rules"]
|