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/workflow.yml b/.github/workflows/workflow.yml new file mode 100644 index 00000000..2b12bb61 --- /dev/null +++ b/.github/workflows/workflow.yml @@ -0,0 +1,94 @@ +name: DOTNET-STANDARD BUILDS +on: + push: + pull_request: + workflow_dispatch: +env: + CLIENT_FOLDER: 'cybersource-rest-client-dotnetstandard' + SAMPLE_FOLDER: 'cybersource-rest-samples-csharp' +jobs: + workflow-job: + defaults: + run: + shell: bash + strategy: + fail-fast: false + matrix: + operating-system: [windows-latest,windows-2019,ubuntu-latest,ubuntu-20.04,macos-latest,macos-13] + dotnet-ver: ['3.1.x','5.0','6.0','7.0','8.0'] + exclude: + - operating-system: macos-latest #macos 14 arm64 image is being used and it doesn't support .NET Core 3.1 + dotnet-ver: '3.1.x' + - operating-system: macos-latest #macos 14 arm64 image is being used and it doesn't support .NET 5.0 + dotnet-ver: '5.0' + runs-on: ${{matrix.operating-system}} + env: + NET_VER: ${{matrix.dotnet-ver}} + steps: + - name: Setup Git Config for windows to allow path lengths greater than 260 characters + if: runner.os == 'Windows' + run: | + git config --global core.longpaths true + - name: Checkout the cybersource-rest-client-dotnetstandard repo + uses: actions/checkout@v4 + with: + path: ${{env.CLIENT_FOLDER}} + - name: Checkout cybersource-rest-samples-csharp repo + uses: actions/checkout@v4 + with: + repository: 'CyberSource/cybersource-rest-samples-csharp' + ref: 'master' + path: ${{env.SAMPLE_FOLDER}} + - name: SetUp DotNet + id: setdotnet + uses: actions/setup-dotnet@v4 + with: + dotnet-version: ${{matrix.dotnet-ver}} + - name: Changing the csproj files to reference the locally built Authorization and Client dll file + run: | + if [[ (${{matrix.dotnet-ver}} == '3.1.x' && "$(uname -s)" == "Darwin") || + (${{matrix.dotnet-ver}} == '5.0' && "$(uname -s)" == "Darwin") ]]; then + echo "Microsoft .NET SDK version ${{matrix.dotnet-ver}} has issues for Mac OS, latest Microsoft .NET SDK will be used for building the projects." + else + dotnet new globaljson --sdk-version ${{steps.setdotnet.outputs.dotnet-version}} + cat global.json + fi + sed -i -e 's||\n ../../cybersource-rest-auth-netstandard/AuthenticationSdk/AuthenticationSdk/bin/Release/netstandard2.1/Cybersource.Authentication.NetStandard.dll\n true\n|g' cybersource-rest-client-dotnetstandard/cybersource-rest-client-netstandard/cybersource-rest-client-netstandard/cybersource-rest-client-netstandard.csproj + sed -i -e 's||\n ../cybersource-rest-client-dotnetstandard/cybersource-rest-auth-netstandard/AuthenticationSdk/AuthenticationSdk/bin/Release/netstandard2.1/Cybersource.Authentication.NetStandard.dll\n true\n|g' cybersource-rest-samples-csharp/cybersource-rest-samples-netcore.csproj + sed -i -e 's||\n ../cybersource-rest-client-dotnetstandard/cybersource-rest-client-netstandard/cybersource-rest-client-netstandard/bin/Release/netstandard2.1/cybersource-rest-client-netstandard.dll\n true\n|g' cybersource-rest-samples-csharp/cybersource-rest-samples-netcore.csproj + cat cybersource-rest-client-dotnetstandard/cybersource-rest-client-netstandard/cybersource-rest-client-netstandard/cybersource-rest-client-netstandard.csproj + - name: Build the Authentication and Client projects + run: | + dotnet --version + dotnet build $CLIENT_FOLDER/cybersource-rest-auth-netstandard/AuthenticationSdk/AuthenticationSdk/AuthenticationSdk.csproj -c release + dotnet build $CLIENT_FOLDER/cybersource-rest-client-netstandard/cybersource-rest-client-netstandard/cybersource-rest-client-netstandard.csproj -c release + - name: Build the Samples project and Run Tests + env: + TARGET_FR: netcoreapp3.1 + run: | + if [ $NET_VER != '3.1.x' ]; then + export TARGET_FR=net${NET_VER} + sed -i -e "s|.*|${TARGET_FR}|g" cybersource-rest-samples-csharp/cybersource-rest-samples-netcore.csproj + fi + cat cybersource-rest-samples-csharp/cybersource-rest-samples-netcore.csproj + #changing the target framework for samples application + dotnet --version + echo "Target Framework : ${TARGET_FR}" + dotnet build $SAMPLE_FOLDER/cybersource-rest-samples-netcore.csproj -c release + cd $SAMPLE_FOLDER/bin/Release/$TARGET_FR + echo "Running Samples" + ./SampleCodeNetCore -RunAll > output.log + cp output.log ../../../ + - name: Using Report Generation Action + id: report-generation + uses: ./cybersource-rest-client-dotnetstandard/.github/actions/generate-report + with: + lang: dotnetstandard + 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}}-dotnet-core-ver-${{matrix.dotnet-ver}} + path: | + ${{env.SAMPLE_FOLDER}}/${{steps.report-generation.outputs.result-pdf-name}} diff --git a/.gitignore b/.gitignore index d99a6f06..e6351c6c 100644 --- a/.gitignore +++ b/.gitignore @@ -355,3 +355,5 @@ MigrationBackup/ /cybersource-rest-client-netstandard/cybersource-rest-client-netstandard/build.sh /cybersource-rest-client-netstandard/cybersource-rest-client-netstandard/git_push.sh /cybersource-rest-client-netstandard/cybersource-rest-client-netstandard/mono_nunit_test.sh + +.DS_Store diff --git a/README.md b/README.md index b46dace6..0800ab68 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,5 @@ # .NET Standard Client SDK for the CyberSource REST API +[![DOTNET-STANDARD BUILDS](https://github.com/CyberSource/cybersource-rest-client-dotnetstandard/actions/workflows/workflow.yml/badge.svg)](https://github.com/CyberSource/cybersource-rest-client-dotnetstandard/actions/workflows/workflow.yml) The CyberSource .NET Standard client provides convenient access to the [CyberSource REST API](https://developer.cybersource.com/api/reference/api-reference.html) from your .NET application.