forked from flipperdevices/flipperzero-firmware
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Check FL ticket in PR name after merge (flipperdevices#2076)
* Add base * Add base again * Test reporting * Fix reporting * Fix secrets * Fix arguments in report * Remove depricated actions * Disable reporting on PR Co-authored-by: あく <alleteam@gmail.com>
- Loading branch information
1 parent
7fb1af0
commit 9d728a1
Showing
10 changed files
with
130 additions
and
41 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
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
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 @@ | ||
name: 'Check FL ticket in PR name' | ||
|
||
on: | ||
push: | ||
branches: | ||
- dev | ||
jobs: | ||
merge_report: | ||
runs-on: [self-hosted,FlipperZeroShell] | ||
steps: | ||
- name: 'Decontaminate previous build leftovers' | ||
run: | | ||
if [ -d .git ]; then | ||
git submodule status || git checkout "$(git rev-list --max-parents=0 HEAD | tail -n 1)" | ||
fi | ||
- name: 'Checkout code' | ||
uses: actions/checkout@v3 | ||
with: | ||
fetch-depth: 0 | ||
ref: ${{ github.event.pull_request.head.sha }} | ||
|
||
- name: 'Get commit details' | ||
run: | | ||
if [[ ${{ github.event_name }} == 'pull_request' ]]; then | ||
TYPE="pull" | ||
elif [[ "${{ github.ref }}" == "refs/tags/"* ]]; then | ||
TYPE="tag" | ||
else | ||
TYPE="other" | ||
fi | ||
python3 scripts/get_env.py "--event_file=${{ github.event_path }}" "--type=$TYPE" | ||
- name: 'Check ticket and report' | ||
run: | | ||
FBT_TOOLCHAIN_PATH=/runner/_work source scripts/toolchain/fbtenv.sh | ||
python3 -m pip install slack_sdk | ||
python3 scripts/merge_report_qa.py \ | ||
${{ secrets.QA_REPORT_SLACK_TOKEN }} \ | ||
${{ secrets.QA_REPORT_SLACK_CHANNEL }} | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
#!/usr/bin/env python3 | ||
|
||
import os | ||
import re | ||
import sys | ||
import argparse | ||
from slack_sdk import WebClient | ||
from slack_sdk.errors import SlackApiError | ||
|
||
|
||
def parse_args(): | ||
parser = argparse.ArgumentParser() | ||
parser.add_argument("slack_token") | ||
parser.add_argument("slack_channel") | ||
args = parser.parse_args() | ||
return args | ||
|
||
|
||
def checkCommitMessage(msg): | ||
regex = re.compile(r"^'?\[FL-\d+\]") | ||
if regex.match(msg): | ||
return True | ||
return False | ||
|
||
|
||
def reportSlack(commit_hash, slack_token, slack_channel, message): | ||
client = WebClient(token=slack_token) | ||
try: | ||
client.chat_postMessage(channel="#" + slack_channel, text=message) | ||
except SlackApiError as e: | ||
print(e) | ||
sys.exit(1) | ||
|
||
|
||
def main(): | ||
args = parse_args() | ||
commit_msg = os.getenv("COMMIT_MSG") | ||
commit_hash = os.getenv("COMMIT_HASH") | ||
commit_sha = os.getenv("COMMIT_SHA") | ||
commit_link = ( | ||
"<https://github.com/flipperdevices/flipperzero-firmware/commit/" | ||
+ commit_hash | ||
+ "|" | ||
+ commit_sha | ||
+ ">" | ||
) | ||
message = "Commit " + commit_link + " merged to dev without 'FL' ticket!" | ||
if not checkCommitMessage(commit_msg): | ||
reportSlack(commit_hash, args.slack_token, args.slack_channel, message) | ||
|
||
|
||
if __name__ == "__main__": | ||
main() |