12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152 |
- name: Sync cmakebuild with main
- on:
- schedule:
- - cron: "0 * * * *" # At minute 0 every hour
- workflow_dispatch:
- concurrency:
- group: ${{ github.workflow }}
- cancel-in-progress: true
- env:
- REPO: ${{ github.repository }}
- TOKEN: ${{ secrets.GH_PERSONAL_ACCESS_TOKEN }}
- jobs:
- sync:
- runs-on: ubuntu-latest
- steps:
- - name: Sync
- run: |
- mainsha=$(curl -s -H "Accept: application/vnd.github.VERSION.sha" https://api.github.com/repos/$REPO/commits/main)
- echo "Main sha: ${mainsha}"
- lastsha=$(curl -s https://raw.githubusercontent.com/$REPO/cmakebuild/ydb/ci/cmakegen.txt)
- echo "Last sha: ${lastsha}"
- if [ "${mainsha}" == "${lastsha}" ];then
- echo "No new commits on the main branch to merge, exiting"
- exit 0
- fi
- git clone -b main --shallow-exclude cmakebuild https://$TOKEN@github.com/$REPO.git ydb
- git config --global user.email "alex@ydb.tech"
- git config --global user.name "Alexander Smirnov"
- cd ydb
- git fetch --depth `expr $(git rev-list --count HEAD) + 1`
- # Depth 10: 1st with cmake generation, 2nd with previous merge, 3rd is common between main and cmakebuild,
- # others for possible commits directly on cmakebuild branch
- git fetch origin cmakebuild:cmakebuild --depth 10
- mainsha=$(git rev-parse HEAD)
- git checkout cmakebuild
- prevsha=$(git rev-parse HEAD)
- git merge main --no-edit
- currsha=$(git rev-parse HEAD)
- if [ ${prevsha} == ${currsha} ];then
- echo "Merge did not bring any changes, exiting"
- exit
- fi
- # Generate ydb/core/base/generate with python codegen under ya
- ./ya make ydb/core/base/generated/
- ydb/core/base/generated/codegen/codegen ydb/core/base/generated/runtime_feature_flags.h.in ydb/core/base/generated/runtime_feature_flags.h
- ydb/core/base/generated/codegen/codegen ydb/core/base/generated/runtime_feature_flags.cpp.in ydb/core/base/generated/runtime_feature_flags.cpp
- # Generate cmakelists using pregenerated ydb/core/base/generated/runtime_feature_flags.*
- ./generate_cmake -k
- echo ${mainsha} > ydb/ci/cmakegen.txt
- git add .
- git commit -m "Generate cmake for ${mainsha}"
- git push --set-upstream origin cmakebuild
|