-
Notifications
You must be signed in to change notification settings - Fork 30
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #62 from NvTimLiu/release-tmp
Change version and dependency jars to v22.02.0
- Loading branch information
Showing
14 changed files
with
404 additions
and
439 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
# Copyright (c) 2022, NVIDIA CORPORATION. | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
# A workflow to keep BASE branch up-to-date from HEAD branch | ||
name: auto-merge HEAD to BASE | ||
|
||
on: | ||
pull_request_target: | ||
branches: | ||
- branch-22.02 | ||
types: [closed] | ||
|
||
jobs: | ||
auto-merge: | ||
if: github.event.pull_request.merged == true | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- uses: actions/checkout@v2 | ||
with: | ||
ref: branch-22.02 # force to fetch from latest upstream instead of PR ref | ||
|
||
- name: auto-merge job | ||
uses: ./.github/workflows/auto-merge | ||
env: | ||
OWNER: NVIDIA | ||
REPO_NAME: spark-rapids-ml | ||
HEAD: branch-22.02 | ||
BASE: branch-22.04 | ||
AUTOMERGE_TOKEN: ${{ secrets.AUTOMERGE_TOKEN }} # use to merge PR |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
# Copyright (c) 2022, NVIDIA CORPORATION. | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
FROM python:alpine | ||
|
||
WORKDIR / | ||
COPY automerge . | ||
RUN pip install requests && chmod +x /automerge | ||
|
||
# require envs: OWNER,REPO_NAME,HEAD,BASE,GITHUB_TOKEN | ||
ENTRYPOINT ["/automerge"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
# Copyright (c) 2022, NVIDIA CORPORATION. | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
name: 'auto-merge action' | ||
description: 'auto-merge HEAD to BASE' | ||
runs: | ||
using: 'docker' | ||
image: 'Dockerfile' | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,137 @@ | ||
#!/usr/bin/env python | ||
|
||
# Copyright (c) 2022, NVIDIA CORPORATION. | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
"""A auto-merge tool | ||
Create a PR to merge HEAD to BASE branch. | ||
NOTE: | ||
The generated PR should be automatically merged if no conflict. Otherwise, manual operation will be required. | ||
""" | ||
|
||
import os | ||
import sys | ||
import time | ||
|
||
import requests | ||
|
||
# ENV | ||
OWNER = os.environ.get('OWNER') | ||
assert OWNER, 'env OWNER should not be empty' | ||
REPO_NAME = os.environ.get('REPO_NAME') | ||
assert REPO_NAME, 'env REPO_NAME should not be empty' | ||
HEAD = os.environ.get('HEAD') | ||
assert HEAD, 'env HEAD should not be empty' | ||
BASE = os.environ.get('BASE') | ||
assert BASE, 'env BASE should not be empty' | ||
AUTOMERGE_TOKEN = os.environ.get('AUTOMERGE_TOKEN') | ||
assert AUTOMERGE_TOKEN, 'env AUTOMERGE_TOKEN should not be empty' | ||
# static | ||
API_URL = 'https://api.github.com' | ||
AUTH_HEADERS = { | ||
'Authorization': 'token ' + AUTOMERGE_TOKEN | ||
} | ||
|
||
|
||
def create(): | ||
url = f'{API_URL}/repos/{OWNER}/{REPO_NAME}/pulls' | ||
params = { | ||
'title': f'[auto-merge] {HEAD} to {BASE} [skip ci] [bot]', | ||
'head': HEAD, | ||
'base': BASE, | ||
'body': f'auto-merge triggered by github actions on `{HEAD}` to create a PR keeping `{BASE}` up-to-date. If ' | ||
'this PR is unable to be merged due to conflicts, it will remain open until manually fix.', | ||
'maintainer_can_modify': True | ||
} | ||
r = requests.post(url, headers=AUTH_HEADERS, json=params) | ||
if r.status_code == 201: | ||
print('SUCCESS - create PR') | ||
pull = r.json() | ||
number = str(pull['number']) | ||
sha = str(pull['head']['sha']) | ||
return number, sha, False | ||
if r.status_code == 422: # early-terminate if no commits between HEAD and BASE | ||
print('SUCCESS - No commits') | ||
print(r.json()) | ||
return '', '', True | ||
# FAILURE | ||
print('FAILURE - create PR') | ||
print(f'status code: {r.status_code}') | ||
print(r.json()) | ||
sys.exit(1) | ||
|
||
|
||
def auto_merge(number, sha): | ||
url = f'{API_URL}/repos/{OWNER}/{REPO_NAME}/pulls/{number}/merge' | ||
params = { | ||
'sha': sha, | ||
'merge_method': 'merge' | ||
} | ||
r = requests.put(url, headers=AUTH_HEADERS, json=params) | ||
if r.status_code == 200: | ||
comment(number, '**SUCCESS** - auto-merge') | ||
print('SUCCESS - auto-merge') | ||
sys.exit(0) | ||
else: | ||
print('FAILURE - auto-merge') | ||
comment(number=number, content=f"""**FAILURE** - Unable to auto-merge. Manual operation is required. | ||
``` | ||
{r.json()} | ||
``` | ||
Please use the following steps to fix the merge conflicts manually: | ||
``` | ||
# Assume upstream is NVIDIA/spark-rapids-ml remote | ||
git fetch upstream {HEAD} {BASE} | ||
git checkout -b fix-auto-merge-conflict-{number} upstream/{BASE} | ||
git merge upstream/{HEAD} | ||
# Fix any merge conflicts caused by this merge | ||
git commit -am "Merge {HEAD} into {BASE}" | ||
git push <personal fork> fix-auto-merge-conflict-{number} | ||
# Open a PR targets NVIDIA/spark-rapids-ml {BASE} | ||
``` | ||
**IMPORTANT:** Before merging this PR, be sure to change the merging strategy to `Create a merge commit` (repo admin only). | ||
Once this PR is merged, the auto-merge PR should automatically be closed since it contains the same commit hashes | ||
""") | ||
print(f'status code: {r.status_code}') | ||
print(r.json()) | ||
sys.exit(1) | ||
|
||
|
||
def comment(number, content): | ||
url = f'{API_URL}/repos/{OWNER}/{REPO_NAME}/issues/{number}/comments' | ||
params = { | ||
'body': content | ||
} | ||
r = requests.post(url, headers=AUTH_HEADERS, json=params) | ||
if r.status_code == 201: | ||
print('SUCCESS - create comment') | ||
else: | ||
print('FAILURE - create comment') | ||
print(f'status code: {r.status_code}') | ||
print(r.json()) | ||
|
||
|
||
def main(): | ||
number, sha, term = create() | ||
if term: | ||
sys.exit(0) | ||
|
||
auto_merge(number, sha) | ||
|
||
|
||
if __name__ == '__main__': | ||
main() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.