diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index e66689c7e..ecf16de78 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -60,8 +60,6 @@ jobs: steps: - name: Checkout uses: actions/checkout@v4 - with: - submodules: "recursive" - name: Get version uses: ./.github/actions/get-version @@ -161,8 +159,6 @@ jobs: steps: - name: Checkout uses: actions/checkout@v4 - with: - submodules: "recursive" - name: Get version uses: ./.github/actions/get-version @@ -284,8 +280,6 @@ jobs: steps: - name: Checkout uses: actions/checkout@v4 - with: - submodules: "recursive" - name: Get version uses: ./.github/actions/get-version @@ -355,8 +349,6 @@ jobs: steps: - name: Checkout uses: actions/checkout@v4 - with: - submodules: "recursive" - name: Build on FreeBSD if: ${{ matrix.distro.name == 'freebsd' }} diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml index fdf621eca..0bfa57732 100644 --- a/.github/workflows/codeql-analysis.yml +++ b/.github/workflows/codeql-analysis.yml @@ -28,8 +28,6 @@ jobs: steps: - name: Checkout uses: actions/checkout@v4 - with: - submodules: "recursive" - name: Config Git safe dir run: git config --global --add safe.directory $GITHUB_WORKSPACE diff --git a/.github/workflows/issue-support.yml b/.github/workflows/issue-support.yml index 8fb3423f1..011ceee2c 100644 --- a/.github/workflows/issue-support.yml +++ b/.github/workflows/issue-support.yml @@ -2,45 +2,43 @@ name: Check if tech support issue on: issues: types: [opened] + workflow_dispatch: + inputs: + issue_number: + description: "Issue number" + required: true + issue_body: + description: "Issue body" + required: true jobs: - add-comment: + check-issue-tech-support: runs-on: ubuntu-latest - env: - CUSTOMER_TEXT: "What type of Synergy user are you?[[:space:]]*\bCustomer\b" - MISSING_TICKET_TEXT: "Support ticket number (for customers)[[:space:]]*\b_No response_\b" - COMMENT_BODY: | - Hello, as a customer, you're entitled to tech support which is included in your license. - Please [raise a support ticket](https://symless.com/synergy/contact) if you'd like to take advantage of that. - If that works for you, then please let us know your ticket number so we can continue the discussion there. steps: - - name: Check if customer - id: customer_check - run: | - ISSUE_BODY="${{ github.event.issue.body }}" - IS_CUSTOMER=$(echo "$ISSUE_BODY" | grep -z -q "$CUSTOMER_TEXT" && echo "true" || echo "false") - RESULT="is_customer=${IS_CUSTOMER}" - echo $RESULT - echo $RESULT >> $GITHUB_OUTPUT + - name: Checkout + uses: actions/checkout@v4 - - name: Check for ticket number - id: ticket_check - run: | - ISSUE_BODY="${{ github.event.issue.body }}" - NO_TICKET=$(echo "$ISSUE_BODY" | grep -z -q "$MISSING_TICKET_TEXT" && echo "true" || echo "false") - RESULT="no_ticket=${NO_TICKET}" - echo $RESULT - echo $RESULT >> $GITHUB_OUTPUT + - name: Check if issue requires tech support + id: issue-check + run: ./scripts/github.py --issue-check-tech-support + env: + ISSUE_BODY: ${{ github.event.issue.body || github.event.inputs.issue_body }} - name: Add comment for customer - if: steps.customer_check.outputs.is_customer == 'true' && steps.ticket_check.outputs.no_ticket == 'true' + if: steps.issue-check.outputs.may-need-tech-support == 'true' + env: + COMMENT_BODY: | + Hello, as a customer, you're entitled to tech support which is included in your + license. Please [raise a support ticket](https://symless.com/synergy/contact) + if you'd like to take advantage of that. If that works for you, then please let + us know your ticket number so we can continue the discussion there. uses: actions/github-script@v6 with: script: | github.rest.issues.createComment({ owner: context.repo.owner, repo: context.repo.repo, - issue_number: context.issue.number, + issue_number: context.issue.number || github.event.inputs.issue_number, body: process.env.COMMENT_BODY }); diff --git a/.github/workflows/sonarcloud-analysis.yml b/.github/workflows/sonarcloud-analysis.yml index 739d36389..0afab633f 100644 --- a/.github/workflows/sonarcloud-analysis.yml +++ b/.github/workflows/sonarcloud-analysis.yml @@ -28,8 +28,6 @@ jobs: steps: - name: Checkout uses: actions/checkout@v4 - with: - submodules: "recursive" # Fetch all history for SonarScanner blame data fetch-depth: 0 diff --git a/.github/workflows/valgrind-analysis.yml b/.github/workflows/valgrind-analysis.yml index aca854917..ba6828f09 100644 --- a/.github/workflows/valgrind-analysis.yml +++ b/.github/workflows/valgrind-analysis.yml @@ -18,8 +18,6 @@ jobs: steps: - name: Checkout uses: actions/checkout@v4 - with: - submodules: "recursive" - name: Config Git safe dir run: git config --global --add safe.directory $GITHUB_WORKSPACE diff --git a/scripts/github.py b/scripts/github.py new file mode 100755 index 000000000..4ac340d99 --- /dev/null +++ b/scripts/github.py @@ -0,0 +1,66 @@ +#!/usr/bin/env python3 + +# Synergy -- mouse and keyboard sharing utility +# Copyright (C) 2024 Symless Ltd. +# +# This package is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License +# found in the file LICENSE that should have accompanied this file. +# +# This package is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +import lib.env as env + +env.ensure_in_venv(__file__) + +import argparse +import sys +import re +import lib.github as github + +ISSUE_BODY_ENV = "ISSUE_BODY" + + +def main(): + parser = argparse.ArgumentParser() + parser.add_argument( + "--issue-check-tech-support", + action="store_true", + help="Check if an issue may need tech support", + ) + args = parser.parse_args() + + if args.issue_check_tech_support: + issue_check_tech_support() + else: + print("No command specified", file=sys.stderr) + sys.exit(1) + + +def issue_check_tech_support(): + print("Checking if issue may need tech support") + + issue_body = env.get_env(ISSUE_BODY_ENV) + print(f'Issue body...\n"{issue_body}"\n') + + customer_pattern = r"What type of Synergy user are you\?\s*Customer" + missing_ticket_pattern = r"Support ticket number \(for customers\)\s*_No response_" + + is_customer = re.search(customer_pattern, issue_body, re.DOTALL) + no_ticket = re.search(missing_ticket_pattern, issue_body, re.DOTALL) + + print(f"Is customer: {is_customer}") + print(f"No ticket: {no_ticket}") + + may_need_tech_support = bool(is_customer and no_ticket) + github.set_output("may-need-tech-support", str(may_need_tech_support).lower()) + + +if __name__ == "__main__": + main() diff --git a/scripts/lib/github.py b/scripts/lib/github.py index 2c4a6e137..abc6bda8e 100644 --- a/scripts/lib/github.py +++ b/scripts/lib/github.py @@ -17,6 +17,7 @@ import os github_env_key = "GITHUB_ENV" github_path_key = "GITHUB_PATH" +github_output_key = "GITHUB_OUTPUT" def set_env_var(key, value): @@ -28,7 +29,7 @@ def set_env_var(key, value): raise RuntimeError(f"Env var {github_env_key} not set") if not os.path.exists(env_file): - raise RuntimeError(f"File not found: {env_file}") + raise RuntimeError(f"Env file not found: {env_file}") print(f"Setting GitHub env var: {key}={value}") with open(env_file, "a") as env_file: @@ -44,8 +45,24 @@ def add_to_path(value): raise RuntimeError(f"Env var {github_path_key} not set") if not os.path.exists(path_file): - raise RuntimeError(f"File not found: {path_file}") + raise RuntimeError(f"Path file not found: {path_file}") print(f"Adding to GitHub path: {value}") with open(path_file, "a") as path_file: path_file.write(f"{value}\n") + + +def set_output(name, value): + """ + Sets the output parameter for the GitHub action. + """ + output_file = os.getenv(github_output_key) + if not output_file: + raise RuntimeError(f"Env var {github_output_key} not set") + + if not os.path.exists(output_file): + raise RuntimeError(f"Output file not found: {output_file}") + + print(f"Setting GitHub output: {name}={value}") + with open(output_file, "a") as output_file: + output_file.write(f"{name}={value}\n")