From 6f1f3c5f477081d1e0bedaaa0ab926de0d9009e0 Mon Sep 17 00:00:00 2001 From: alexanderlaw Date: Thu, 22 Jun 2023 06:43:45 +0300 Subject: [PATCH 1/7] Create codeql.yml --- .github/workflows/codeql.yml | 77 ++++++++++++++++++++++++++++++++++++ 1 file changed, 77 insertions(+) create mode 100644 .github/workflows/codeql.yml diff --git a/.github/workflows/codeql.yml b/.github/workflows/codeql.yml new file mode 100644 index 0000000..a22a42a --- /dev/null +++ b/.github/workflows/codeql.yml @@ -0,0 +1,77 @@ +# For most projects, this workflow file will not need changing; you simply need +# to commit it to your repository. +# +# You may wish to alter this file to override the set of languages analyzed, +# or to provide custom queries or build logic. +# +# ******** NOTE ******** +# We have attempted to detect the languages in your repository. Please check +# the `language` matrix defined below to confirm you have the correct set of +# supported CodeQL languages. +# +name: "CodeQL" + +on: + push: + branches: [ "main" ] + pull_request: + # The branches below must be a subset of the branches above + branches: [ "main" ] + schedule: + - cron: '38 21 * * 0' + +jobs: + analyze: + name: Analyze + runs-on: ${{ (matrix.language == 'swift' && 'macos-latest') || 'ubuntu-latest' }} + timeout-minutes: ${{ (matrix.language == 'swift' && 120) || 360 }} + permissions: + actions: read + contents: read + security-events: write + + strategy: + fail-fast: false + matrix: + language: [ 'cpp', 'python' ] + # CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python', 'ruby', 'swift' ] + # Use only 'java' to analyze code written in Java, Kotlin or both + # Use only 'javascript' to analyze code written in JavaScript, TypeScript or both + # Learn more about CodeQL language support at https://aka.ms/codeql-docs/language-support + + steps: + - name: Checkout repository + uses: actions/checkout@v3 + + # Initializes the CodeQL tools for scanning. + - name: Initialize CodeQL + uses: github/codeql-action/init@v2 + with: + languages: ${{ matrix.language }} + # If you wish to specify custom queries, you can do so here or in a config file. + # By default, queries listed here will override any specified in a config file. + # Prefix the list here with "+" to use these queries and those in the config file. + + # For more details on CodeQL's query packs, refer to: https://docs.github.com/en/code-security/code-scanning/automatically-scanning-your-code-for-vulnerabilities-and-errors/configuring-code-scanning#using-queries-in-ql-packs + # queries: security-extended,security-and-quality + + + # Autobuild attempts to build any compiled languages (C/C++, C#, Go, Java, or Swift). + # If this step fails, then you should remove it and run the build manually (see below) + - name: Autobuild + uses: github/codeql-action/autobuild@v2 + + # â„šī¸ Command-line programs to run using the OS shell. + # 📚 See https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsrun + + # If the Autobuild fails above, remove it and uncomment the following three lines. + # modify them (or add more) to build your code if your project, please refer to the EXAMPLE below for guidance. + + # - run: | + # echo "Run, Build Application using script" + # ./location_of_script_within_repo/buildscript.sh + + - name: Perform CodeQL Analysis + uses: github/codeql-action/analyze@v2 + with: + category: "/language:${{matrix.language}}" From dff7f7bd7a598dbb906fb4222f1b1f8267772b23 Mon Sep 17 00:00:00 2001 From: alexanderlaw Date: Thu, 22 Jun 2023 06:49:44 +0300 Subject: [PATCH 2/7] Don't run CodeQL Analyze for cpp --- .github/workflows/codeql.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/codeql.yml b/.github/workflows/codeql.yml index a22a42a..b10c731 100644 --- a/.github/workflows/codeql.yml +++ b/.github/workflows/codeql.yml @@ -33,7 +33,7 @@ jobs: strategy: fail-fast: false matrix: - language: [ 'cpp', 'python' ] + language: [ 'python' ] # CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python', 'ruby', 'swift' ] # Use only 'java' to analyze code written in Java, Kotlin or both # Use only 'javascript' to analyze code written in JavaScript, TypeScript or both From 5f479c3615d7a5aff3458b6d73c173c66d097ad1 Mon Sep 17 00:00:00 2001 From: Alexander Lakhin Date: Thu, 22 Jun 2023 07:17:16 +0300 Subject: [PATCH 3/7] Reformat prepare-instances.py slightly to avoid pylint message R0801 --- prepare-instances.py | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/prepare-instances.py b/prepare-instances.py index 9f8a711..8ea5721 100755 --- a/prepare-instances.py +++ b/prepare-instances.py @@ -193,12 +193,10 @@ def get_repo_url(instance): if __name__ == "__main__": arg_parser = argparse.ArgumentParser() arg_parser.add_argument('-c', '--config', action='store', - default='config.xml', - help='configuration file') + default='config.xml', help='configuration file') arg_parser.add_argument('-i', '--instance', nargs='+', dest='instances', metavar='INSTANCE-ID', - default=[], - help='instance(s) to create') + default=[], help='instance(s) to create') args = arg_parser.parse_args(sys.argv[1:]) sys.exit(main(args.config, args.instances)) From 98b11139f6bf4cbaba2376ca8260e8310d2e740c Mon Sep 17 00:00:00 2001 From: alexanderlaw Date: Thu, 22 Jun 2023 07:23:23 +0300 Subject: [PATCH 4/7] Create pylint.yml --- .github/workflows/pylint.yml | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 .github/workflows/pylint.yml diff --git a/.github/workflows/pylint.yml b/.github/workflows/pylint.yml new file mode 100644 index 0000000..383e65c --- /dev/null +++ b/.github/workflows/pylint.yml @@ -0,0 +1,23 @@ +name: Pylint + +on: [push] + +jobs: + build: + runs-on: ubuntu-latest + strategy: + matrix: + python-version: ["3.8", "3.9", "3.10"] + steps: + - uses: actions/checkout@v3 + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v3 + with: + python-version: ${{ matrix.python-version }} + - name: Install dependencies + run: | + python -m pip install --upgrade pip + pip install pylint + - name: Analysing the code with pylint + run: | + pylint $(git ls-files '*.py') From 93a34343970dd07282e39c5e6c388ae29a43e0d5 Mon Sep 17 00:00:00 2001 From: Alexander Lakhin Date: Thu, 22 Jun 2023 07:33:37 +0300 Subject: [PATCH 5/7] Suppress pylint warning W0719 --- prepare-instances.py | 1 + run-benchmarks.py | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/prepare-instances.py b/prepare-instances.py index 8ea5721..5253559 100755 --- a/prepare-instances.py +++ b/prepare-instances.py @@ -79,6 +79,7 @@ def get_repo_url(instance): # Prepare source directory git_dir = config.find('./settings/default/git').get('path') if not os.path.exists(git_dir): + # pylint: disable=broad-exception-raised raise Exception(f'Git directory ({git_dir}) not found' ' (check settings/default/git in config.xml)!') git_branch = instance.get('git_branch') diff --git a/run-benchmarks.py b/run-benchmarks.py index 4123445..a9583e6 100755 --- a/run-benchmarks.py +++ b/run-benchmarks.py @@ -6,7 +6,7 @@ as specified in a configuration file. """ -# pylint: disable=invalid-name +# pylint: disable=invalid-name,broad-exception-raised # Requirements: docker, bash, wget, git, tar, 7z From 8583ba0f75fcf931f3b3d1de16e3fca5e880329c Mon Sep 17 00:00:00 2001 From: alexanderlaw Date: Thu, 22 Jun 2023 07:40:47 +0300 Subject: [PATCH 6/7] Target pylint to python 3.10 and 3.11 --- .github/workflows/pylint.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/pylint.yml b/.github/workflows/pylint.yml index 383e65c..bffc0b4 100644 --- a/.github/workflows/pylint.yml +++ b/.github/workflows/pylint.yml @@ -7,7 +7,7 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - python-version: ["3.8", "3.9", "3.10"] + python-version: ["3.10", "3.11"] steps: - uses: actions/checkout@v3 - name: Set up Python ${{ matrix.python-version }} From 742df7861692589966e3a9c04156803bd34fda38 Mon Sep 17 00:00:00 2001 From: Alexander Lakhin Date: Thu, 22 Jun 2023 10:23:09 +0300 Subject: [PATCH 7/7] Add extra checks (shellcheck, xmllint) --- .github/workflows/extrachecks.yml | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 .github/workflows/extrachecks.yml diff --git a/.github/workflows/extrachecks.yml b/.github/workflows/extrachecks.yml new file mode 100644 index 0000000..eb80f1c --- /dev/null +++ b/.github/workflows/extrachecks.yml @@ -0,0 +1,17 @@ +name: Extra checks + +on: [push] + +jobs: + build: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - name: Installing requirements + run: sudo apt install shellcheck libxml2-utils + - name: Analyzing scripts with ShellCheck + run: | + shellcheck scripts/*/* + - name: Analyzing config.xml with xmllint + run: | + xmllint --noout config.xml