Azure / Azure/iotedgedev

How To copy unittest result out of the container without --output argument

Open
#530 2 comments 0 reactions 0 assignees View on GitHub
Dominant language
Python
Stars
166
Forks
76
PR merge metrics
No merged PRs in 30d

Description

I would like to copy out the unit test results from my docker stage. Normaly i would use for this `docker build --target export-test-results --output type=local,dest=testresults .` But the --output parameter in the module.json doesent work.

Do you have any other idea to acomplise this?

- iotedgedev Version: iotedgedev, version 3.3.3

my Dockerfile.amd64
```dockerfile
# Build Context is ./../../../
#@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@#
FROM mcr.microsoft.com/dotnet/aspnet:6.0-bullseye-slim AS base
WORKDIR /app
EXPOSE 80
EXPOSE 443

HEALTHCHECK --interval=30s --timeout=10s --retries=3 CMD curl --fail http://localhost:80/health || exit 1

# Install prerequisites for healthcheck
RUN apt-get update && apt-get install -y \
curl && \
rm -rf /var/lib/apt/lists/*

RUN useradd -ms /bin/bash moduleuser
USER moduleuser

#@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@#
FROM mcr.microsoft.com/dotnet/sdk:6.0-bullseye-slim AS build-stage
WORKDIR /app
COPY . ./
RUN dotnet restore ./IotEdge/modules/MyModule.IntegrationTest
RUN dotnet restore ./IotEdge/modules/MyModule.Test

#@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@#
FROM build-stage AS test-stage
RUN dotnet test ./IotEdge/modules/MyModule.IntegrationTest -c Release --logger "console;verbosity=detailed" --logger "trx" --results-directory testresults
RUN dotnet test ./IotEdge/modules/MyModule.Test -c Release --logger "console;verbosity=detailed" --logger "trx" --results-directory testresults

#@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@#
FROM scratch as export-test-results
# it possible to export the files to dockerhost with: docker build --target export-test-results --output type=local,dest=testresults .
COPY --from=test-stage /app/testresults/*.trx .

#@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@#
FROM test-stage AS publish-stage
# Publish this module
RUN dotnet publish ./IotEdge/modules/MyModule -c Release -o out

#@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@#
FROM base as final
WORKDIR /app
COPY --from=publish-stage /app/out ./

ENTRYPOINT ["dotnet", "MyModule.dll"]
```

my mdoule.json
```json
{
"$schema-version": "0.0.1",
"description": "This module receives beacon telemetry messages and observers the individual beacon and his state for generating state messages.",
"image": {
"repository": "someregistry.azurecr.io/beaconobserverservice",
"tag": {
"version": "22.03.18",
"platforms": {
"amd64": "./Dockerfile.amd64",
"amd64.debug": "./Dockerfile.amd64.debug"
}
},
"buildOptions": [
"--pull"
],
"contextPath": "./../../../"
},
"language": "csharp"
}
```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.