diff --git a/.github/workflows/build_all.yml b/.github/workflows/build_all.yml index 72d01f1..362fdf7 100644 --- a/.github/workflows/build_all.yml +++ b/.github/workflows/build_all.yml @@ -26,6 +26,10 @@ on: type: boolean required: false default: true + send_to_slack: + type: boolean + required: false + default: false jobs: setup-devices: @@ -563,7 +567,7 @@ jobs: python3 scripts/output_scripts/slack.py --input_file full_build_output.json --output_file slack.json --key build --devices ${{ needs.setup-devices.outputs.names }} - name: Send custom JSON data to Slack workflow - if: always() && ${{ github.event_name == 'schedule' }} + if: ${{ github.event_name == 'schedule' || inputs.send_to_slack == true }} id: slack uses: slackapi/slack-github-action@v1.24.0 with: @@ -576,6 +580,7 @@ jobs: python3 scripts/output_scripts/status.py --input_file full_build_output.json --key build - name: Archive output file + if: always() uses: actions/upload-artifact@v3 with: name: full_build_output.json diff --git a/.github/workflows/refresh_inputs.yml b/.github/workflows/refresh_inputs.yml index 56c10ef..b2c4b23 100644 --- a/.github/workflows/refresh_inputs.yml +++ b/.github/workflows/refresh_inputs.yml @@ -7,6 +7,10 @@ on: type: boolean required: false default: false + send_to_slack: + type: boolean + required: false + default: false schedule: - cron: '32 5 * * 3' @@ -46,7 +50,7 @@ jobs: echo "Files are the same!" fi - name: Send custom JSON data to Slack workflow - if: ${{ failure() && github.event_name == 'schedule' }} + if: ${{ failure() && (github.event_name == 'schedule' || inputs.send_to_slack == true) }} id: slack uses: slackapi/slack-github-action@v1.24.0 with: @@ -72,9 +76,10 @@ jobs: git push --set-upstream origin update-input --force - name: Create Pull Request + if: ${{ failure() && (github.event_name == 'schedule' || inputs.create_pr == true) }} run: | apk add github-cli gh pr create --base "test-all-apps" --head "update-input" --title "[BOT] Update input file" --body "Input file has changed ! Please review changes !" env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + GITHUB_TOKEN: ${{ secrets.GH_ACCESS_TOKEN }} diff --git a/.github/workflows/scan_all.yml b/.github/workflows/scan_all.yml index eb7cf65..9fc039c 100644 --- a/.github/workflows/scan_all.yml +++ b/.github/workflows/scan_all.yml @@ -23,6 +23,10 @@ on: type: boolean required: false default: true + send_to_slack: + type: boolean + required: false + default: false jobs: setup-devices: @@ -560,7 +564,7 @@ jobs: python3 scripts/output_scripts/slack.py --input_file full_scan_output.json --output_file slack.json --key scan --devices ${{ needs.setup-devices.outputs.names }} - name: Send custom JSON data to Slack workflow - if: always() && ${{ github.event_name == 'schedule' }} + if: ${{ github.event_name == 'schedule' || inputs.send_to_slack == true }} id: slack uses: slackapi/slack-github-action@v1.24.0 with: @@ -574,6 +578,7 @@ jobs: - name: Archive output file uses: actions/upload-artifact@v3 + if: always() with: name: full_scan_output.json path: full_scan_output.json diff --git a/.github/workflows/test_all.yml b/.github/workflows/test_all.yml index 77f4af1..15989a1 100644 --- a/.github/workflows/test_all.yml +++ b/.github/workflows/test_all.yml @@ -30,6 +30,11 @@ on: required: false default: true + send_to_slack: + type: boolean + required: false + default: false + jobs: split-input-file: name: Split input file @@ -310,6 +315,7 @@ jobs: - name: Archive output file uses: actions/upload-artifact@v3 + if: always() with: name: report.json path: test_output.json @@ -324,7 +330,7 @@ jobs: python scripts/output_scripts/slack.py --input_file test_output.json --output_file slack.json --key test - name: Send custom JSON data to Slack workflow - if: always() && ${{ github.event_name == 'schedule' }} + if: ${{ github.event_name == 'schedule' || inputs.send_to_slack == true }} id: slack uses: slackapi/slack-github-action@v1.24.0 with: diff --git a/scripts/output_scripts/slack.py b/scripts/output_scripts/slack.py index a10aa48..daa761c 100644 --- a/scripts/output_scripts/slack.py +++ b/scripts/output_scripts/slack.py @@ -32,7 +32,7 @@ def count_test_status(json_list): return success_count, fail_count, total_count, fail_list -def count_build_status(json_list): +def count_status(json_list, key): success_count = 0 fail_count = 0 total_count = 0 @@ -41,7 +41,7 @@ def count_build_status(json_list): variant = None # Iterate over each dictionary in the list for json_data in json_list: - app_data = json_data.get("build", {}) + app_data = json_data.get(key, {}) app_name = json_data.get("name", {}) fail_list[app_name] = {} @@ -78,13 +78,11 @@ def count_build_status(json_list): with open(args.input_file) as json_file: json_list = json.load(json_file) - if args.key == "build": - - success_count, fail_count, total_count, fail_list = count_build_status(json_list) - - elif args.key == "test": - + if args.key == "test": success_count, fail_count, total_count, fail_list = count_test_status(json_list) + else: + success_count, fail_count, total_count, fail_list = count_status(json_list, args.key) + title = f"{args.key}"