aboutsummaryrefslogtreecommitdiff
path: root/.github/workflows/auto-merge.yml
diff options
context:
space:
mode:
Diffstat (limited to '.github/workflows/auto-merge.yml')
-rw-r--r--.github/workflows/auto-merge.yml138
1 files changed, 138 insertions, 0 deletions
diff --git a/.github/workflows/auto-merge.yml b/.github/workflows/auto-merge.yml
new file mode 100644
index 00000000..975d4ab0
--- /dev/null
+++ b/.github/workflows/auto-merge.yml
@@ -0,0 +1,138 @@
+# Workflow to cherry-pick changes from main to release branch.
+
+name: auto-merge
+
+on:
+ push:
+ branches: [ main ]
+
+jobs:
+ build-and-test:
+ strategy:
+ fail-fast: false
+ matrix:
+ os: [ ubuntu-latest, macos-latest ]
+
+ # The type of runner that the job will run on
+ runs-on: ${{ matrix.os }}
+
+ steps:
+ # Checkout
+ - uses: actions/checkout@v2
+ with:
+ fetch-depth: 0
+ ref: 1.0.10-release
+
+ - name: merge commits from main to release branch
+ run: |
+ # Cherry pick new changes from main, except for version bumps.
+ # A commit is a version bump IFF it touches third_party/prebuilt/repo
+ DONT_PICK=$(cat <<EOF
+ 76ac8de5cd4769b2cfd7c80ad156309c5f27d52a
+ 9675c5de0f689cb8563a0b6e1142a78747e8675c
+ fc22e8f947fb533e3f728252882c9dbe3f4d810d
+ caa3e0843dd169dcc3486d1ac28d16489324d564
+ 1ed2d3b709adc53450eb1c09fffe33a50459cc88
+ f0647fd2acffa78454700eb4750bf77caab05076
+ EOF
+ )
+ git config --global user.email "kotlin-symbol-processing@google.com"
+ git config --global user.name "KSP Auto Pick"
+ MERGE_BASE=$(git merge-base HEAD origin/main)
+ CANDIDATES=$(git log --pretty=%H $MERGE_BASE..origin/main)
+ PICKED=$(git log $MERGE_BASE..HEAD | sed -n "s/^[ ]*(cherry picked from commit \([a-z0-9]*\))$/\1/p")
+ VERSION_BUMPS=$(git log $MERGE_BASE..origin/main --pretty=%H --grep UPDATE_KOTLIN_VERSION)
+ AA_COMMITS=$(git log $MERGE_BASE..origin/main --pretty=%H kotlin-analysis-api)
+ 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--] }')
+ echo Picking $TO_PICK
+ if [ -n "$TO_PICK" ]; then git cherry-pick -x $TO_PICK; fi
+
+ - name: Setup Java 9
+ uses: actions/setup-java@v1.4.3
+ with:
+ java-version: '9'
+ java-package: jdk
+ architecture: x64
+ - name: set JDK_9 environment variable for kotlin compiler
+ env:
+ ACTIONS_ALLOW_UNSECURE_COMMANDS: true
+ run: echo ::set-env name=JDK_9::$(echo $JAVA_HOME)
+ - name: Setup Java 11
+ uses: actions/setup-java@v1.4.3
+ with:
+ java-version: '11'
+ java-package: jdk
+ architecture: x64
+
+ # Build cache
+ - name: Cache Gradle Cache
+ uses: actions/cache@v2
+ with:
+ path: ~/.gradle/caches
+ key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle.kts') }}-${{ hashFiles('**/gradle.properties') }}
+ # An ordered list of keys to use for restoring the cache if no cache hit occurred for key
+ restore-keys: |
+ ${{ runner.os }}-gradle-
+ - name: Cache gradle wrapper
+ uses: actions/cache@v2
+ with:
+ path: ~/.gradle/wrapper
+ key: ${{ runner.os }}-gradle-wrapper-${{ hashFiles('gradle/wrapper/gradle-wrapper.properties') }}
+
+ # Check API compatibility
+ - name: API compatibility check
+ run: ./gradlew :api:checkApi
+
+ # Run ksp generated tests
+ - name: test
+ run: ./gradlew --stacktrace --info test
+
+ - name: Upload test results
+ if: always()
+ uses: actions/upload-artifact@v3
+ with:
+ name: test-reports
+ path: |
+ compiler-plugin/build/reports
+ integration-tests/build/reports
+ gradle-plugin/build/reports
+ common-util/build/reports
+
+ pick-and-push:
+ needs: build-and-test
+ runs-on: ubuntu-latest
+
+ steps:
+ # Checkout
+ - uses: actions/checkout@v2
+ with:
+ fetch-depth: 0
+ ref: 1.0.9-release
+
+ - name: merge commits from main to release branch
+ run: |
+ # Cherry pick new changes from main, except for version bumps.
+ # A commit is a version bump IFF it touches third_party/prebuilt/repo
+ DONT_PICK=$(cat <<EOF
+ 76ac8de5cd4769b2cfd7c80ad156309c5f27d52a
+ 9675c5de0f689cb8563a0b6e1142a78747e8675c
+ fc22e8f947fb533e3f728252882c9dbe3f4d810d
+ caa3e0843dd169dcc3486d1ac28d16489324d564
+ 1ed2d3b709adc53450eb1c09fffe33a50459cc88
+ f0647fd2acffa78454700eb4750bf77caab05076
+ EOF
+ )
+ git config --global user.email "kotlin-symbol-processing@google.com"
+ git config --global user.name "KSP Auto Pick"
+ MERGE_BASE=$(git merge-base HEAD origin/main)
+ CANDIDATES=$(git log --pretty=%H $MERGE_BASE..origin/main)
+ PICKED=$(git log $MERGE_BASE..HEAD | sed -n "s/^[ ]*(cherry picked from commit \([a-z0-9]*\))$/\1/p")
+ VERSION_BUMPS=$(git log $MERGE_BASE..origin/main --pretty=%H --grep UPDATE_KOTLIN_VERSION)
+ AA_COMMITS=$(git log $MERGE_BASE..origin/main --pretty=%H kotlin-analysis-api)
+ TO_PICK=$(grep -Fxv -f <(echo "$PICKED"; echo "$VERSION_BUMPS"; echo "$DONT_PICK"; echo "$AA_COMMITS") <(echo "$CANDIDATES") | tac)
+ echo Picking $TO_PICK
+ if [ -n "$TO_PICK" ]; then git cherry-pick -x $TO_PICK; fi
+
+ - name: push to release branch
+ run: git push origin
+