1# Workflow to cherry-pick changes from main to release branch. 2 3name: auto-merge 4 5on: 6 push: 7 branches: [ main ] 8 9jobs: 10 build-and-test: 11 strategy: 12 fail-fast: false 13 matrix: 14 os: [ ubuntu-latest, macos-latest ] 15 16 # The type of runner that the job will run on 17 runs-on: ${{ matrix.os }} 18 19 steps: 20 # Checkout 21 - uses: actions/checkout@v2 22 with: 23 fetch-depth: 0 24 ref: 1.0.10-release 25 26 - name: merge commits from main to release branch 27 run: | 28 # Cherry pick new changes from main, except for version bumps. 29 # A commit is a version bump IFF it touches third_party/prebuilt/repo 30 DONT_PICK=$(cat <<EOF 31 76ac8de5cd4769b2cfd7c80ad156309c5f27d52a 32 9675c5de0f689cb8563a0b6e1142a78747e8675c 33 fc22e8f947fb533e3f728252882c9dbe3f4d810d 34 caa3e0843dd169dcc3486d1ac28d16489324d564 35 1ed2d3b709adc53450eb1c09fffe33a50459cc88 36 f0647fd2acffa78454700eb4750bf77caab05076 37 EOF 38 ) 39 git config --global user.email "kotlin-symbol-processing@google.com" 40 git config --global user.name "KSP Auto Pick" 41 MERGE_BASE=$(git merge-base HEAD origin/main) 42 CANDIDATES=$(git log --pretty=%H $MERGE_BASE..origin/main) 43 PICKED=$(git log $MERGE_BASE..HEAD | sed -n "s/^[ ]*(cherry picked from commit \([a-z0-9]*\))$/\1/p") 44 VERSION_BUMPS=$(git log $MERGE_BASE..origin/main --pretty=%H --grep UPDATE_KOTLIN_VERSION) 45 AA_COMMITS=$(git log $MERGE_BASE..origin/main --pretty=%H kotlin-analysis-api) 46 TO_PICK=$(grep -Fxv -f <(echo "$PICKED"; echo "$VERSION_BUMPS"; echo "$DONT_PICK"; echo "$AA_COMMITS") <(echo "$CANDIDATES") | awk '{a[i++]=$0} END {for (j=i-1; j>=0;) print a[j--] }') 47 echo Picking $TO_PICK 48 if [ -n "$TO_PICK" ]; then git cherry-pick -x $TO_PICK; fi 49 50 - name: Setup Java 9 51 uses: actions/setup-java@v1.4.3 52 with: 53 java-version: '9' 54 java-package: jdk 55 architecture: x64 56 - name: set JDK_9 environment variable for kotlin compiler 57 env: 58 ACTIONS_ALLOW_UNSECURE_COMMANDS: true 59 run: echo ::set-env name=JDK_9::$(echo $JAVA_HOME) 60 - name: Setup Java 11 61 uses: actions/setup-java@v1.4.3 62 with: 63 java-version: '11' 64 java-package: jdk 65 architecture: x64 66 67 # Build cache 68 - name: Cache Gradle Cache 69 uses: actions/cache@v2 70 with: 71 path: ~/.gradle/caches 72 key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle.kts') }}-${{ hashFiles('**/gradle.properties') }} 73 # An ordered list of keys to use for restoring the cache if no cache hit occurred for key 74 restore-keys: | 75 ${{ runner.os }}-gradle- 76 - name: Cache gradle wrapper 77 uses: actions/cache@v2 78 with: 79 path: ~/.gradle/wrapper 80 key: ${{ runner.os }}-gradle-wrapper-${{ hashFiles('gradle/wrapper/gradle-wrapper.properties') }} 81 82 # Check API compatibility 83 - name: API compatibility check 84 run: ./gradlew :api:checkApi 85 86 # Run ksp generated tests 87 - name: test 88 run: ./gradlew --stacktrace --info test 89 90 - name: Upload test results 91 if: always() 92 uses: actions/upload-artifact@v3 93 with: 94 name: test-reports 95 path: | 96 compiler-plugin/build/reports 97 integration-tests/build/reports 98 gradle-plugin/build/reports 99 common-util/build/reports 100 101 pick-and-push: 102 needs: build-and-test 103 runs-on: ubuntu-latest 104 105 steps: 106 # Checkout 107 - uses: actions/checkout@v2 108 with: 109 fetch-depth: 0 110 ref: 1.0.9-release 111 112 - name: merge commits from main to release branch 113 run: | 114 # Cherry pick new changes from main, except for version bumps. 115 # A commit is a version bump IFF it touches third_party/prebuilt/repo 116 DONT_PICK=$(cat <<EOF 117 76ac8de5cd4769b2cfd7c80ad156309c5f27d52a 118 9675c5de0f689cb8563a0b6e1142a78747e8675c 119 fc22e8f947fb533e3f728252882c9dbe3f4d810d 120 caa3e0843dd169dcc3486d1ac28d16489324d564 121 1ed2d3b709adc53450eb1c09fffe33a50459cc88 122 f0647fd2acffa78454700eb4750bf77caab05076 123 EOF 124 ) 125 git config --global user.email "kotlin-symbol-processing@google.com" 126 git config --global user.name "KSP Auto Pick" 127 MERGE_BASE=$(git merge-base HEAD origin/main) 128 CANDIDATES=$(git log --pretty=%H $MERGE_BASE..origin/main) 129 PICKED=$(git log $MERGE_BASE..HEAD | sed -n "s/^[ ]*(cherry picked from commit \([a-z0-9]*\))$/\1/p") 130 VERSION_BUMPS=$(git log $MERGE_BASE..origin/main --pretty=%H --grep UPDATE_KOTLIN_VERSION) 131 AA_COMMITS=$(git log $MERGE_BASE..origin/main --pretty=%H kotlin-analysis-api) 132 TO_PICK=$(grep -Fxv -f <(echo "$PICKED"; echo "$VERSION_BUMPS"; echo "$DONT_PICK"; echo "$AA_COMMITS") <(echo "$CANDIDATES") | tac) 133 echo Picking $TO_PICK 134 if [ -n "$TO_PICK" ]; then git cherry-pick -x $TO_PICK; fi 135 136 - name: push to release branch 137 run: git push origin 138 139