Skip to content

Dataverse API Testing #54

Dataverse API Testing

Dataverse API Testing #54

# This is a GitHub Actions workflow for testing customizations implemented around Dataverse using its API.
# The workflow is triggered on every push only under the "resources/06-CodeItAndShipIt/backend-development/Dataverse.API.Testing" folder to the main branch.
# This workflow need to define the following permissions to be able to publish the test results: permissions: contents: read, actions: read and checks: write
#
# The workflow performs the following steps:
# 0. Enable git long paths: It enables long paths in git to avoid the "Filename too long" error.
# 1. Setup: It sets up the required environment with .NET 8.0 using "actions/setup-dotnet@v3"
# 2. Restore Dependencies: It restores all the dependencies and tools of the .NET solution (.sln) using the 'dotnet restore' command.
# 3. Build and Test: It targets a solution to runs API tests using the 'dotnet test' command leveraging the "TENANT_ID", "CLIENT_ID" and "CLIENT_SECRET" GitHub environment secrets and the "DATAVERSE_ENVIRONMENT_URL" environment variable. To be able to analyse the results of the tests, set also the following parameter: --logger "trx;LogFileName=test-results.trx"
# 5. Publish Test Results: Use the "dorny/test-reporter@main" GitHub action using the trx file generated by the test command and the "dotnet-trx" reporter to get a nice report of the test results. This step should always be run.
name: Dataverse API Testing
on:
workflow_dispatch:
push:
paths:
- 'resources/06-CodeItAndShipIt/backend-development/Dataverse.API.Testing/**'
branches:
- main
permissions:
contents: read
actions: read
checks: write
jobs:
build-and-test:
runs-on: ubuntu-latest
environment:
name: 'Sandbox'
steps:
- name: Enable git long paths
run: git config --global core.longpaths true
- name: Checkout repository
uses: actions/checkout@v2
- name: Restore dependencies
run: dotnet restore resources/06-CodeItAndShipIt/backend-development/Dataverse.API.Testing/Dataverse.API.Testing.sln
- name: Build Solution & Run tests
run: dotnet test resources/06-CodeItAndShipIt/backend-development/Dataverse.API.Testing/Dataverse.API.Testing.sln --logger "trx;LogFileName=test-results.trx"
env:
DATASERVICE_URL: ${{ vars.DATAVERSE_ENVIRONMENT_URL }}
CLIENT_ID: ${{ secrets.CLIENT_ID }}
CLIENT_SECRET: ${{ secrets.CLIENT_SECRET }}
- name: Publish Test Results
if: always()
uses: dorny/test-reporter@main
with:
name: Dataverse API Testing
path: resources/06-CodeItAndShipIt/backend-development/Dataverse.API.Testing/**/*.trx
reporter: dotnet-trx