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-node.yml b/.github/workflows/workflow-node.yml new file mode 100644 index 00000000..dec6af92 --- /dev/null +++ b/.github/workflows/workflow-node.yml @@ -0,0 +1,69 @@ +name: NODE BUILDS +on: + push: + pull_request: + workflow_dispatch: +env: + CLIENT_FOLDER: 'cybersource-rest-client-node' + SAMPLE_FOLDER: 'cybersource-rest-samples-node' + NPM_CLIENT_FOLDER : 'npm-client-sdk' +jobs: + workflow-job: + defaults: + run: + shell: bash + strategy: + fail-fast: false + matrix: + operating-system: [ubuntu-latest,macos-latest,windows-latest] + node-ver: [14.x,16.x,17.x,18.x,19.x,20.x,21.x,22.x] # Axios Doesn't support node version 15 + exclude: + - operating-system: macos-latest # No Node 14 image is there for the arm64 architecture of mac + node-ver: 14.x + include: + - operating-system: macos-13 # No Node 14 image is there for the arm64 architecture of mac + node-ver: 14.x + runs-on: ${{matrix.operating-system}} + steps: + - 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-node repo + uses: actions/checkout@v4 + with: + path: ${{env.CLIENT_FOLDER}} + - name: Checkout cybersource-rest-samples-node repo + uses: actions/checkout@v4 + with: + repository: 'CyberSource/${{env.SAMPLE_FOLDER}}' + ref: 'master' + path: ${{env.SAMPLE_FOLDER}} + - name: Install Node + uses: actions/setup-node@v4 + with: + node-version: ${{matrix.node-ver}} + - name: Building the projects and running the Test Cases + run: | + cd $CLIENT_FOLDER + npm install + npm pack + PACKAGE_VERSION=$(grep '"version"' package.json | cut -d '"' -f 4 | head -n 1) + cd ../$SAMPLE_FOLDER + npm install file:../$CLIENT_FOLDER/cybersource-rest-client-$PACKAGE_VERSION.tgz + npm install + bash ./sample_code_runner.sh + - name: Using Report Generation Action + id: report-generation + uses: ./cybersource-rest-client-node/.github/actions/generate-report + with: + lang: node + 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}}-node-ver-${{matrix.node-ver}} + path: | + ${{env.SAMPLE_FOLDER}}/${{steps.report-generation.outputs.result-pdf-name}} diff --git a/.gitignore b/.gitignore index 0713f637..961ae1e5 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,6 @@ /node_modules .swagger-codegen-ignore .swagger-codegen + +#adding for mac ds file +.DS_Store \ No newline at end of file diff --git a/README.md b/README.md index e785a826..c701602b 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,8 @@ # Node.JS Client SDK for the CyberSource REST API +[![NODE BUILDS](https://github.com/CyberSource/cybersource-rest-client-node/actions/workflows/workflow-node.yml/badge.svg)](https://github.com/CyberSource/cybersource-rest-client-node/actions/workflows/workflow-node.yml) + ## Description The CyberSource Node client provides convenient access to the [CyberSource REST API](https://developer.cybersource.com/api/reference/api-reference.html) from your Node application.