From 037d71e6fa437525e8ce62a944cdfdc0be96efc0 Mon Sep 17 00:00:00 2001 From: Beau Gosse Date: Mon, 26 Jun 2023 19:21:50 -0500 Subject: [PATCH 01/12] Run canary twice a day to prevent false postitive alarm (#29) Since the alarm triggers if a canary isn't run over the period of 1 day, if day 1's canary runs at 12:00 PM and day 2 runs at 12:01 PM, the alarm will trigger. And alarms can't be set to scan more than 1 day. --- .github/workflows/canary.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/canary.yml b/.github/workflows/canary.yml index 4834d7b..8ddffcb 100644 --- a/.github/workflows/canary.yml +++ b/.github/workflows/canary.yml @@ -4,7 +4,7 @@ on: workflow_dispatch: schedule: # Run this once a day to check if everything is still working as expected. - - cron: "0 12 * * *" + - cron: "0 6,12 * * *" permissions: id-token: write From 9c086fbe32a4087f8e8a0883b185f48f87fd9feb Mon Sep 17 00:00:00 2001 From: Santosh K Date: Fri, 4 Aug 2023 03:10:20 +0530 Subject: [PATCH 02/12] fied bug due to which setup-environment.(sh/ps1) wasn't identifying correct version python executable during virtual env creation (#33) --- Setup-Environment.ps1 | 17 +++++++++++++---- setup-environment.sh | 25 +++++++++++++++++-------- 2 files changed, 30 insertions(+), 12 deletions(-) diff --git a/Setup-Environment.ps1 b/Setup-Environment.ps1 index e6e28ff..11b1e15 100644 --- a/Setup-Environment.ps1 +++ b/Setup-Environment.ps1 @@ -4,9 +4,17 @@ Sets up Python Virtual Environment. #> try { - $p = python --version + Get-Command python | ForEach-Object { + $PYTHON_VERSION_MAJOR = [int]($_.FileVersionInfo.ProductVersion -split '\.')[0] + $PYTHON_VERSION_MINOR = [int]($_.FileVersionInfo.ProductVersion -split '\.')[1] + + if ($PYTHON_VERSION_MAJOR -ge 3 -and $PYTHON_VERSION_MINOR -ge 10) { + $PYTHON3 = $_.Name + } + } + $p = & $PYTHON3 "--version" } catch { - throw '**ERROR**: python is missing, please install it before running this build script' + throw '**ERROR**: python3.10+ is missing, please install it before running this build script' } try { @@ -17,7 +25,7 @@ try { if (!(Test-Path -Path .venv)) { Write-Host "πŸ’» Creating Python virtual environment" - python -m venv .venv + & $PYTHON3 "-m" "venv" ".venv" if($LASTEXITCODE -ne 0) { throw "**ERROR**: could not create Python Virtual Environment." } @@ -33,4 +41,5 @@ Write-Host "☁️ Installing requirements" pip install -r requirements-build.txt if($LASTEXITCODE -ne 0) { throw "**ERROR**: error installing required packages" -} \ No newline at end of file +} + diff --git a/setup-environment.sh b/setup-environment.sh index 79ac631..fa1eede 100755 --- a/setup-environment.sh +++ b/setup-environment.sh @@ -1,11 +1,19 @@ #!/bin/bash -# This script sets up the Python Virtual Environment to install dependencies +# This script looks up Python 3.10 or higher in PATH and sets up the Python Virtual Environment to install dependencies -if hash python3 -then - echo "🐍 python3 is installed" +for AVAILABLE_PYTHON in $(compgen -c python | sort -u); do + PYTHON_VERSION_MAJOR=$($AVAILABLE_PYTHON --version 2>/dev/null | awk -F '[ .]' 'BEGIN {OFS="."} {print $(NF-2)}') + PYTHON_VERSION_MINOR=$($AVAILABLE_PYTHON --version 2>/dev/null | awk -F '[ .]' 'BEGIN {OFS="."} {print $(NF-1)}') + if [[ $PYTHON_VERSION_MAJOR -ge 3 ]] && [[ $PYTHON_VERSION_MINOR -ge 10 ]]; then + PYTHON3=$AVAILABLE_PYTHON + echo "🐍 python3.10+ is installed" + break + fi +done +if [[ ! -z $PYTHON3 ]] +then if hash pip3 then echo "πŸ“¦ pip is installed" @@ -15,7 +23,7 @@ then if [ ! -f ".venv/bin/activate" ]; then echo "πŸ’» Creating Python virtual environment" - python3 -m venv .venv + $PYTHON3 -m venv .venv if [ $? -ne 0 ]; then echo "**ERROR**: could not create Python Virtual Environment." && exit 1 fi @@ -28,12 +36,13 @@ then fi echo "☁️ Installing requirements" - python3 -m pip install -r requirements-build.txt + $PYTHON3 -m pip install -r requirements-build.txt if [ $? -ne 0 ]; then echo "**ERROR**: error installing required packages" && exit 1 fi exit 0 else - echo "**ERROR**: python3 is missing, please install it before running this build script" + echo "**ERROR**: python3.10+ is missing, please install it before running this build script" exit 1 -fi \ No newline at end of file +fi + From ab8e3af03bce17ab72fa8cce0ee165bdf5fb4178 Mon Sep 17 00:00:00 2001 From: Arturo Molina Date: Thu, 3 Aug 2023 22:54:02 +0000 Subject: [PATCH 03/12] Updates dockerfile to copy only what we need to build the image --- Dockerfile | 3 ++- container-test.sh | 8 -------- 2 files changed, 2 insertions(+), 9 deletions(-) diff --git a/Dockerfile b/Dockerfile index 5f9a15b..b14d95c 100644 --- a/Dockerfile +++ b/Dockerfile @@ -6,7 +6,8 @@ RUN yum install java-17-amazon-corretto python3.11 python3.11-pip maven binutils ENV JAVA_HOME=/usr/lib/jvm/java ENV MAVEN_HOME=/usr/share/maven -COPY . . +COPY src src/ +COPY build.sh setup-environment.sh getBinaryName.sh requirements-build.txt ./ RUN /usr/bin/python3.11 -m venv .venv && \ source .venv/bin/activate && \ python3 -m pip install -r requirements-build.txt && \ diff --git a/container-test.sh b/container-test.sh index 63e97f3..633b63c 100755 --- a/container-test.sh +++ b/container-test.sh @@ -5,10 +5,6 @@ source ./test-helpers.sh # This script tests container image build and runs a couple of # tests against the generated image. -if [ -d ".venv" ]; then - mv .venv .venv_temp -fi - docker build -t porting-advisor . if [ $? -ne 0 ]; then echo "**ERROR**: building container image" && exit 1 @@ -30,8 +26,4 @@ if [ $? -ne 0 ]; then fi rm -f test.html -if [ -d ".venv_temp" ]; then - mv .venv_temp .venv -fi - exit 0 From eb77b34bfda2cc6169928bae79e22b22e2ad1b24 Mon Sep 17 00:00:00 2001 From: Arturo Molina Date: Thu, 3 Aug 2023 23:22:03 +0000 Subject: [PATCH 04/12] Bumping up version number. Update dependencies. Adds note on readme. --- README.md | 2 ++ requirements-build.txt | 22 +++++++++++----------- requirements.txt | 10 +++++----- src/advisor/__init__.py | 2 +- 4 files changed, 19 insertions(+), 17 deletions(-) diff --git a/README.md b/README.md index 03f30ee..362bfc1 100644 --- a/README.md +++ b/README.md @@ -5,6 +5,8 @@ This is a fork of [Porting advisor](https://github.com/arm-hpc/porting-advisor), It is a command line tool that analyzes source code for known code patterns and dependency libraries. It then generates a report with any incompatibilities with our Graviton processors. This tool provides suggestions of minimal required and/or recommended versions to run on Graviton instances for both language runtime and dependency libraries. It can run on non-ARM based machines (no Graviton processor needed). This tool does not work on binaries, just source code. It does not make any code modifications, it doesn’t make API level recommendations, nor does it send data back to AWS. +**PLEASE NOTE: Even though we do our best to find known incompatibilities, we still recommend to perform the appropriate tests to your application on a Graviton instance before going to Production.** + This tool scans all files in a source tree, regardless of whether they are included by the build system or not. As such it may erroneously report issues in files that appear in the source tree but are excluded by the build system. Currently, the tool supports the following languages/dependencies: * Python 3+ diff --git a/requirements-build.txt b/requirements-build.txt index 64a51be..b3ef880 100644 --- a/requirements-build.txt +++ b/requirements-build.txt @@ -1,15 +1,15 @@ -altgraph==0.17.2 -certifi==2022.12.7 -charset-normalizer==2.1.1 -coverage==7.0.1 +altgraph==0.17.3 +certifi==2023.7.22 +charset-normalizer==3.2.0 +coverage==7.2.7 idna==3.4 Jinja2==3.1.2 -MarkupSafe==2.1.1 -packaging==21.3 +MarkupSafe==2.1.3 +packaging==23.1 progressbar33==2.4 -pyinstaller==5.5 -pyinstaller-hooks-contrib==2022.4 -pyparsing==3.0.9 +pyinstaller==5.13.0 +pyinstaller-hooks-contrib==2023.6 +pyparsing==3.1.1 requests==2.31.0 -urllib3==1.26.13 -XlsxWriter==3.0.3 +urllib3==2.0.4 +XlsxWriter==3.1.2 diff --git a/requirements.txt b/requirements.txt index 6f0a250..d832497 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,7 +1,7 @@ -altgraph==0.17.2 +altgraph==0.17.3 Jinja2==3.1.2 -MarkupSafe==2.1.1 -packaging==21.3 +MarkupSafe==2.1.3 +packaging==23.1 progressbar33==2.4 -pyparsing==3.0.9 -XlsxWriter==3.0.3 +pyparsing==3.1.1 +XlsxWriter==3.1.2 diff --git a/src/advisor/__init__.py b/src/advisor/__init__.py index 190e7b2..593f2f0 100644 --- a/src/advisor/__init__.py +++ b/src/advisor/__init__.py @@ -17,7 +17,7 @@ """ __project__ = 'porting-advisor' -__version__ = '1.0.2' +__version__ = '1.1.0' __summary__ = 'Produces an aarch64 porting readiness report.' __webpage__ = 'http://www.gitlab.com/arm-hpc/porting-advisor' From 544eba75c7c079a99bbe331335f59c14ef126926 Mon Sep 17 00:00:00 2001 From: Daniel Kleinstein Date: Thu, 7 Mar 2024 01:00:42 +0200 Subject: [PATCH 05/12] rules: Update go.json with ArgoCD minVersion (#42) See https://github.com/argoproj/argo-cd/releases/tag/v2.4.0 --- src/advisor/rules/go.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/advisor/rules/go.json b/src/advisor/rules/go.json index 62becfa..4a2a4ed 100644 --- a/src/advisor/rules/go.json +++ b/src/advisor/rules/go.json @@ -8,6 +8,7 @@ "recommendedVersion": "1.18" }, "libraryRules": [ - { "name": "github.com/golang/snappy", "minVersion": "0.0.2" } + { "name": "github.com/golang/snappy", "minVersion": "0.0.2" }, + { "name": "github.com/argoproj/argo-cd/v2", "minVersion": "2.4.0" } ] -} \ No newline at end of file +} From 5746aa8c3ddb1dac7263f8e85e071c7da9b2190b Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 20 Mar 2024 22:34:54 +0000 Subject: [PATCH 06/12] Bump pyinstaller from 5.13.0 to 5.13.1 Bumps [pyinstaller](https://github.com/pyinstaller/pyinstaller) from 5.13.0 to 5.13.1. - [Release notes](https://github.com/pyinstaller/pyinstaller/releases) - [Changelog](https://github.com/pyinstaller/pyinstaller/blob/develop/doc/CHANGES.rst) - [Commits](https://github.com/pyinstaller/pyinstaller/compare/v5.13.0...v5.13.1) --- updated-dependencies: - dependency-name: pyinstaller dependency-type: direct:production ... Signed-off-by: dependabot[bot] --- requirements-build.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements-build.txt b/requirements-build.txt index b3ef880..c31d92f 100644 --- a/requirements-build.txt +++ b/requirements-build.txt @@ -7,7 +7,7 @@ Jinja2==3.1.2 MarkupSafe==2.1.3 packaging==23.1 progressbar33==2.4 -pyinstaller==5.13.0 +pyinstaller==5.13.1 pyinstaller-hooks-contrib==2023.6 pyparsing==3.1.1 requests==2.31.0 From 2218359c9244562e3cfb4a11c585ecedd74cc1f0 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 20 Mar 2024 22:38:43 +0000 Subject: [PATCH 07/12] Bump urllib3 from 2.0.4 to 2.0.7 Bumps [urllib3](https://github.com/urllib3/urllib3) from 2.0.4 to 2.0.7. - [Release notes](https://github.com/urllib3/urllib3/releases) - [Changelog](https://github.com/urllib3/urllib3/blob/main/CHANGES.rst) - [Commits](https://github.com/urllib3/urllib3/compare/2.0.4...2.0.7) --- updated-dependencies: - dependency-name: urllib3 dependency-type: direct:production ... Signed-off-by: dependabot[bot] --- requirements-build.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements-build.txt b/requirements-build.txt index c31d92f..0631557 100644 --- a/requirements-build.txt +++ b/requirements-build.txt @@ -11,5 +11,5 @@ pyinstaller==5.13.1 pyinstaller-hooks-contrib==2023.6 pyparsing==3.1.1 requests==2.31.0 -urllib3==2.0.4 +urllib3==2.0.7 XlsxWriter==3.1.2 From d8c4e12a415c9a8917bda0ba3c1ae7931301fc6e Mon Sep 17 00:00:00 2001 From: Nati Cohen Date: Tue, 2 Apr 2024 23:56:11 +0300 Subject: [PATCH 08/12] add a Python version check when running as a script (#49) --- src/porting-advisor.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/porting-advisor.py b/src/porting-advisor.py index df7f719..fc14ba2 100644 --- a/src/porting-advisor.py +++ b/src/porting-advisor.py @@ -16,8 +16,12 @@ SPDX-License-Identifier: Apache-2.0 """ +import sys from advisor import main if __name__ == '__main__': + if sys.version_info < (3, 10): + print("Python 3.10 or newer is required to run this application.") + sys.exit(1) main() From 7c258e8ecb4a63990378e20d9de22fcae0d1a49a Mon Sep 17 00:00:00 2001 From: Beau Gosse Date: Mon, 8 Apr 2024 17:32:48 -0500 Subject: [PATCH 09/12] Removing FakeDependency --- Integration-Test.ps1 | 1 - integration-test.sh | 1 - sample-projects/python-samples/incompatible/requirements.txt | 3 +-- 3 files changed, 1 insertion(+), 4 deletions(-) diff --git a/Integration-Test.ps1 b/Integration-Test.ps1 index 9f76f07..8e1d2fe 100644 --- a/Integration-Test.ps1 +++ b/Integration-Test.ps1 @@ -64,7 +64,6 @@ $Dependencies = @( "coverlet.collector1.2.0" "SciPy" "NumPy" - "FakeDependency1.2.3" "cors2.8.5" "express4.18.1" "rxjs7.5.6" diff --git a/integration-test.sh b/integration-test.sh index 55e4173..a7e9be5 100755 --- a/integration-test.sh +++ b/integration-test.sh @@ -35,7 +35,6 @@ declare -a dependencies=("componentversioncoverlet.collector1.2.0" "SciPy" "NumPy" - "FakeDependency1.2.3" "cors2.8.5" "express4.18.1" "rxjs7.5.6" diff --git a/sample-projects/python-samples/incompatible/requirements.txt b/sample-projects/python-samples/incompatible/requirements.txt index 7a2fc04..c5efc47 100644 --- a/sample-projects/python-samples/incompatible/requirements.txt +++ b/sample-projects/python-samples/incompatible/requirements.txt @@ -1,5 +1,4 @@ # Porting Advisor for Graviton test file SciPy>=1.7.1 -NumPy -FakeDependency>=1.2.3 \ No newline at end of file +NumPy \ No newline at end of file From 2a3436f0a4a7dbfeffc72244a69afebb5dcd4c7c Mon Sep 17 00:00:00 2001 From: Beau Gosse Date: Mon, 8 Apr 2024 18:30:22 -0500 Subject: [PATCH 10/12] Updaing version for release 1.1.1 --- src/advisor/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/advisor/__init__.py b/src/advisor/__init__.py index 593f2f0..7385c74 100644 --- a/src/advisor/__init__.py +++ b/src/advisor/__init__.py @@ -17,7 +17,7 @@ """ __project__ = 'porting-advisor' -__version__ = '1.1.0' +__version__ = '1.1.1' __summary__ = 'Produces an aarch64 porting readiness report.' __webpage__ = 'http://www.gitlab.com/arm-hpc/porting-advisor' From 6a9cad7d7af88858fd867c4baba3b8890ea5ad6a Mon Sep 17 00:00:00 2001 From: "binh.ampere" <138732269+binh-ampere@users.noreply.github.com> Date: Mon, 15 Apr 2024 11:38:14 +0800 Subject: [PATCH 11/12] Delete .github/workflows/canary.yml --- .github/workflows/canary.yml | 113 ----------------------------------- 1 file changed, 113 deletions(-) delete mode 100644 .github/workflows/canary.yml diff --git a/.github/workflows/canary.yml b/.github/workflows/canary.yml deleted file mode 100644 index 8ddffcb..0000000 --- a/.github/workflows/canary.yml +++ /dev/null @@ -1,113 +0,0 @@ -name: Canary - -on: - workflow_dispatch: - schedule: - # Run this once a day to check if everything is still working as expected. - - cron: "0 6,12 * * *" - -permissions: - id-token: write - contents: read - -jobs: - build: - - runs-on: ${{ matrix.os }} - strategy: - fail-fast: false - matrix: - os: ["ubuntu-latest", "macos-latest"] - - steps: - - uses: actions/checkout@v3 - - - name: configure aws credentials - uses: aws-actions/configure-aws-credentials@v2 - with: - role-to-assume: ${{ secrets.ROLE }} - role-session-name: PAGravitonCanary - aws-region: ${{ secrets.AWS_REGION }} - - - name: Set up Python ${{ matrix.python-version }} - uses: actions/setup-python@v3 - with: - python-version: "3.10" - - - name: Set up JDK 11 - uses: actions/setup-java@v3 - with: - java-version: '11' - distribution: 'adopt' - - - name: Run build and tests - run: | - ./test.sh - - - name: Code coverage - run: | - ./.venv/bin/python -m coverage report - - - name: Send metric success - if: success() - run: | - aws cloudwatch put-metric-data --namespace TuxNetOps --metric-name porting-advisor-canary --value 1 --dimensions OS=${{ matrix.os }} - - - name: Send metric failure - if: failure() - run: | - aws cloudwatch put-metric-data --namespace TuxNetOps --metric-name porting-advisor-canary --value 0 --dimensions OS=${{ matrix.os }} - - build-windows: - - runs-on: "windows-latest" - - steps: - - uses: actions/checkout@v3 - - - name: configure aws credentials - uses: aws-actions/configure-aws-credentials@v2 - with: - role-to-assume: ${{ secrets.ROLE }} - role-session-name: PAGravitonCanary - aws-region: ${{ secrets.AWS_REGION }} - - - name: Prevent adding secrets to repo - run: | - git clone https://github.com/awslabs/git-secrets.git target - cd target - ./install.ps1 - echo "Git-secrets installation completed" - git secrets --register-aws --global - echo "Added aws secret templates" - git secrets --scan -r ../ - echo "Repository scan completed" - - - name: Set up Python ${{ matrix.python-version }} - uses: actions/setup-python@v3 - with: - python-version: "3.10" - - - name: Set up JDK 11 - uses: actions/setup-java@v3 - with: - java-version: '11' - distribution: 'adopt' - - - name: Run build and tests - run: | - .\Test.ps1 - - - name: Code coverage - run: | - .\.venv\Scripts\coverage report - - - name: Send metrics success - if: success() - run: | - aws cloudwatch put-metric-data --namespace TuxNetOps --metric-name porting-advisor-canary --value 1 --dimensions OS=windows-latest - - - name: Send metric failure - if: failure() - run: | - aws cloudwatch put-metric-data --namespace TuxNetOps --metric-name porting-advisor-canary --value 0 --dimensions OS=windows-latest From ab22b5998834e36b76f0995fc056a870e052c6d6 Mon Sep 17 00:00:00 2001 From: "bin.huang" Date: Mon, 15 Apr 2024 10:13:12 +0000 Subject: [PATCH 12/12] change to repo.maven.apache.org url --- unittest/test_java_tool_invoker.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/unittest/test_java_tool_invoker.py b/unittest/test_java_tool_invoker.py index 46044ea..4e3678e 100644 --- a/unittest/test_java_tool_invoker.py +++ b/unittest/test_java_tool_invoker.py @@ -12,7 +12,7 @@ def test_can_run_checks_java_is_installed(self): self.assertTrue(self.tool_invoker.can_run()) def test_ampere_ready_assessor_for_jars_with_native_methods(self): - download_url = 'https://repo1.maven.org/maven2/io/netty/netty-transport-native-unix-common/4.1.73.Final/netty-transport-native-unix-common-4.1.73.Final.jar' + download_url = 'https://repo.maven.apache.org/maven2/io/netty/netty-transport-native-unix-common/4.1.73.Final/netty-transport-native-unix-common-4.1.73.Final.jar' path = os.path.join('sample-projects', 'java-samples', 'netty-transport-native-unix-common-4.1.73.Final.jar') urllib.request.urlretrieve(download_url, path) result, message = self.tool_invoker.ampere_ready_assessor(path) @@ -21,7 +21,7 @@ def test_ampere_ready_assessor_for_jars_with_native_methods(self): self.assertTrue(message.startswith('Native methods:')) def test_ampere_ready_assessor_for_jars_with_non_native_methods(self): - download_url = 'https://search.maven.org/remotecontent?filepath=javax/activation/activation/1.1.1/activation-1.1.1.jar' + download_url = 'https://repo.maven.apache.org/maven2/javax/activation/activation/1.1.1/activation-1.1.1.jar' path = os.path.join('sample-projects', 'java-samples', 'activation-1.1.1.jar') urllib.request.urlretrieve(download_url, path) result, message = self.tool_invoker.ampere_ready_assessor(path)