EN VI

.net - How to specify path to build artifacts in github actions to run integration tests?

2024-03-15 02:00:06
.net - How to specify path to build artifacts in github actions to run integration tests

I'm using simple git hub workflow to build .net application and upload artifact but having trouble when I need to reuse build artifact. For example to run integration tests in separate workflow.

Build workflow (part of it):

- name: Upload build artifacts
      uses: actions/[email protected]
      with:
        name: dll-artifacts
        path: '**/bin/Release/**/*.dll'

And in another workflow I'm trying to use this but having trouble figuring out what is correct path to integration tests:

- name: Download build artifacts
      uses: actions/[email protected]
      with:
        name: dll-artifacts
        path: build

- name: Run Integration Tests
      run: dotnet test --configuration Release --no-build ~/build/MyProject.IntegrationTests.dll

I'm getting this error:

The argument /home/runner/build/MyProject.IntegrationTests.dll is invalid. Please use the /help option to check the list of valid arguments.

And this message is shown: The following arguments have been ignored : "--configuration Release --no-build"

What is the proper way to run integration tests in this scenario, which path/argument should I use?

Update:

After @Teemu pointed out to path problem, I was able to fix the path issue but still facing different issue running tests from .dll:

Testhost process for source(s) exited with error: A fatal error was encountered. The library 'libhostpolicy.so' required to execute the application was not found. Failed to run as a self-contained app. - The application was run as a self-contained app because 'testhost.runtimeconfig.json' was not found.

Solution:

From the documentation of Upload Artifact

If a wildcard pattern is used, the path hierarchy will be preserved after the first wildcard pattern:

This means that if you do your artifact pattern like that

**/bin/Release/**/*.dll

it will contain the whole directory structure within the artifact when it is extracted, and contain it under path: build, or in other words, under ${{ github.workspace }}/build/. So the artifact is most likely at

${{ github.workspace }}/build/bin/Release/something/MyProject.IntegrationTests.dll

So in this case you might need to know exactly where to look for the file in the next job.

Your current configuration refers to ~, which is usually the home directory for the user, and not the workspace directory mentioned earlier. On a linux machine at GitHub it would refer to /home/runner, like also mentioned in your error message.

Another option is to not use wildcards in the artifact pattern and specify only that file as the artifact, in which case you can get the single file under build with your current download configuration.

Debug

You can also inspect the build logs to verify the path where the artifacts are downloaded:

Preparing to download the following artifacts:
- test-artifacts (ID: 1327023255, Size: 182)
Redirecting to blob download url: https://productionresultssa5.blob.core.windows.net/actions-results/b5932f67-88d6-47de-ba4c-3cbbd4bad4c3/workflow-job-run-ca395085-040a-526b-2ce8-bdc85f692774/artifacts/85dd29b1610fe96eb6a383c71068588dc87f6db72a8c6119257f4a37eed6604b.zip
Starting download of artifact to: /home/runner/work/so-test/so-test/build
Extracting artifact entry: /home/runner/work/so-test/so-test/build/bin/test/test-artifact.txt
Answer

Login


Forgot Your Password?

Create Account


Lost your password? Please enter your email address. You will receive a link to create a new password.

Reset Password

Back to login