diff --git a/.github/actions/generate-report/action.yml b/.github/actions/generate-report/action.yml new file mode 100644 index 00000000..b3787523 --- /dev/null +++ b/.github/actions/generate-report/action.yml @@ -0,0 +1,58 @@ +name: 'Generate the Report' +description: 'Generates the report using the log-file-name file present just inside the sample folder path provided , given Validation Folder is there inside the sample folder as well' +inputs: + lang: + description: 'The language or framework in which SDK is written needs to be given as an input' + required: true + sample-folder-name: + description: 'The name of the sample folder' + required: true + log-file-name: + description: 'The name of the generated log file' + required: true +outputs: + result-pdf-name: + description: 'the name of the final generated pdf report' + value: ${{steps.generate.outputs.pdfname}} +runs: + using: 'composite' + steps: + - name: Setup Python v3.12 for report generation only + uses: actions/setup-python@v5 + with: + python-version: 3.12 + - name: Installing required python libraries and running the python programs to generate pdf report + id: generate + run : | + export EXPECTED_RES_LANG=${{inputs.lang}} + if [[ "${{inputs.lang}}" == "dotnet" ]] || [[ "${{inputs.lang}}" == "dotnetstandard" ]]; then + export EXPECTED_RES_LANG=csharp + fi + echo $EXPECTED_RES_LANG + python --version + echo "Before Running Report Generation" + cd ${{inputs.sample-folder-name}} + python -m pip install --upgrade pip + python -m venv newve + if [[ "$(uname -s)" == "Linux" ]]; then + echo "In LINUX" + source newve/bin/activate + elif [[ "$(uname -s)" == "Darwin" ]]; then + echo "In MAC" + source newve/bin/activate + else + echo "In Windows" + source newve/Scripts/activate + fi + echo $VIRTUAL_ENV + pip install json2html + pip install xhtml2pdf + pip install bs4 + cd Validation + python sample_code_log_processor.py -l ../../${{inputs.sample-folder-name}}/${{inputs.log-file-name}} -o ../../${{inputs.sample-folder-name}}/${{inputs.lang}}_actual_results.json + python response_code_validator.py -e ExpectedResults/${EXPECTED_RES_LANG}_expected_results.json -a ../../${{inputs.sample-folder-name}}/${{inputs.lang}}_actual_results.json -o ${{inputs.lang}}_validation_results.json + python json_to_prettified_html.py -i ${{inputs.lang}}_validation_results.json -o ${{inputs.lang}}_validation_results.html + cp ${{inputs.lang}}_validation_results.pdf ../ #copying the file to flaatten the directory of the upload artifact,Github Actions doesn't support that as of jun 2024 + echo "pdfname=${{inputs.lang}}_validation_results.pdf" >> $GITHUB_OUTPUT + shell: bash + diff --git a/.github/workflows/python-workflow.yml b/.github/workflows/python-workflow.yml new file mode 100644 index 00000000..8e42cdc5 --- /dev/null +++ b/.github/workflows/python-workflow.yml @@ -0,0 +1,95 @@ +name: PYTHON BUILDS +on: + push: + pull_request: + workflow_dispatch: +env: + CLIENT_FOLDER: 'cybersource-rest-client-python' + SAMPLE_FOLDER: 'cybersource-rest-samples-python' +jobs: + workflow-job: + defaults: + run: + shell: bash + strategy: + fail-fast: false + matrix: + operating-system: [ubuntu-latest,macos-latest,windows-latest] + pyth-version: ['3.6','3.7','3.8','3.9','3.10','3.11','3.12'] + include: + - operating-system: ubuntu-20.04 # Checking support for ubuntu os with python 3.6 + pyth-version: '3.6' + - operating-system: macos-13 # Checking support for mac os with python 3.6 + pyth-version: '3.6' + - operating-system: macos-13 # Checking support for mac os with python 3.7 + pyth-version: '3.7' + exclude: + - operating-system: ubuntu-latest #arm 64 doesn't support python ver 3.7 + pyth-version: '3.6' + - operating-system: macos-latest #arm 64 doesn't support python ver 3.6 + pyth-version: '3.6' + - operating-system: macos-latest #arm 64 doesn't support python ver 3.7 + pyth-version: '3.7' + runs-on: ${{matrix.operating-system}} + steps: + - run: echo "VCPKG_ROOT=$env:VCPKG_INSTALLATION_ROOT" | Out-File -FilePath $env:GITHUB_ENV -Append + if: runner.os == 'Windows' + shell: pwsh + - run: vcpkg install openssl:x64-windows-static-md + if: runner.os == 'Windows' + shell: pwsh + - name: Creating separate folders for checkout repos + run: | + rm -rf $CLIENT_FOLDER + rm -rf $SAMPLE_FOLDER + mkdir $CLIENT_FOLDER $SAMPLE_FOLDER + - name: Checkout cybersource-rest-client-python repo + uses: actions/checkout@v4 + with: + path: ${{env.CLIENT_FOLDER}} + - name: Checkout cybersource-rest-samples-python repo + uses: actions/checkout@v4 + with: + repository: 'CyberSource/cybersource-rest-samples-python' + ref: 'master' # this is used for checking out a particular branch in repo + path: ${{env.SAMPLE_FOLDER}} + - name: Install Python + uses: actions/setup-python@v5 + with: + python-version: ${{matrix.pyth-version}} + - name: Building the projects and running the Test Cases + run: | + python --version + python -m pip install --upgrade pip + python -m venv ve + if [[ "$(uname -s)" == "Linux" ]]; then + echo "In LINUX" + source ve/bin/activate + elif [[ "$(uname -s)" == "Darwin" ]]; then + echo "In MAC" + source ve/bin/activate + else + echo "In Windows" + source ve/Scripts/activate + fi + echo $VIRTUAL_ENV + cd $CLIENT_FOLDER + pip install -e . + cd .. + echo $VIRTUAL_ENV + cd $SAMPLE_FOLDER + pip install -e . + bash ./sample_code_runner.sh + - name: Using Report Generation Action + id: report-generation + uses: ./cybersource-rest-client-python/.github/actions/generate-report + with: + lang: python + sample-folder-name: ${{env.SAMPLE_FOLDER}} + log-file-name: output.log + - name: Upload Test Reports + uses: actions/upload-artifact@v4 + with: + name: sample-run-report-${{matrix.operating-system}}-python-ver-${{matrix.pyth-version}} + path: | + ${{env.SAMPLE_FOLDER}}/${{steps.report-generation.outputs.result-pdf-name}} diff --git a/README.md b/README.md index ab41117e..778adad4 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,8 @@ # Python Client SDK for the CyberSource REST API +[![BUILD](https://github.com/CyberSource/cybersource-rest-client-python/actions/workflows/python-workflow.yml/badge.svg?branch=adding-workflows)](https://github.com/CyberSource/cybersource-rest-client-python/actions/workflows/python-workflow.yml) + ## Description The CyberSource Python client provides convenient access to the [CyberSource REST API](https://developer.cybersource.com/api/reference/api-reference.html) from your Python application. diff --git a/requirements.txt b/requirements.txt index 2d85d360..0a4264db 100644 --- a/requirements.txt +++ b/requirements.txt @@ -6,5 +6,7 @@ DateTime setuptools six urllib3 -jwcrypto -cryptography +jwcrypto==1.5.1;python_version<="3.7" +jwcrypto>=1.5.6;python_version>"3.7" +cryptography==40.0.2;python_version<="3.6" +cryptography<41.1.0;python_version>"3.6" diff --git a/setup.py b/setup.py index af041edf..d49c5b08 100644 --- a/setup.py +++ b/setup.py @@ -28,8 +28,10 @@ "setuptools", "six", "urllib3", - "jwcrypto", - "cryptography", + "jwcrypto==1.5.1;python_version<='3.7'", + "jwcrypto>=1.5.6;python_version>'3.7'", + "cryptography==40.0.2;python_version<='3.6'", + "cryptography<41.1.0;python_version>'3.6'" ], packages=find_packages(), include_package_data=True,