-
Hi. Apologies if this has already been answered. I have a github action that is setup to run a selenium test in a docker container. The test creates a TestResult.html file on the docker container. I am binding a volume that contains the test dll to “/test” folder on the docker container. The TestResult.html is also created in the “/test” folder on the docker container. When I execute this manually from my local machine, the volume that contains the test dll and the “/test” folder are in sync and the TestResult.html file is saved in the folder on my local machine automatically. However, when I run this through GitHub actions, the test runs successully but nothing is saved in the synced volume on GitHub. Is there a way to copy this result file from the docker container into my github repository? I tried adding the step “docker cp MyContainer:Path/to/file ${{ github.workspace }}/Artifacts” in my action.yml where Artifacts is a folder I have created in my GitHub repository. The step shows as passed but no file is saved in the Artifacts folder. Thanks. |
Beta Was this translation helpful? Give feedback.
Replies: 5 comments
-
The build results on the VM provided by Actions are separate from your repository, unlike on your local file system. The repository is checked out, the workflow runs, and then the VM (including its files) is discarded. The best solution to archive your test results is probably to store them as an artifact (documentation here). You can then download the artifact for each run. |
Beta Was this translation helpful? Give feedback.
-
@tdalvi , When you run the Docker container action in workflow, from the logs for this action execution step, you can see it will run some commands like below:
This will automatically mount volumes on the container and on the runner machine, it can be used to share/sync files between the container and the runner machine. For example, if you create a " test" folder in the " /github/workspace" directory on the container, and add the " TestResult.html" file into the " test" folder. Then these operations will sync to the " /home/runner/work/myRepo/myRepo" directory, it will automatically generate " /home/runner/work/myRepo/myRepo/test/TestResult.html" So after executing the Docker container action to generate the the " TestResult.html" on the specified directory (I recommend you set to generate this file into one of the automatically mount volumes mentioned above), you can add an extra step in the same job to copy the file to another directory on the runner machine. For example, copy " /home/runner/work/myRepo/myRepo/test/TestResult.html" to another directory. You should understand that this only can work on the same job, if you also want to share the " TestResult.html" file between other jobs in the same workflow run, you need to upload it as an artifact , just like @airtower-luna has mentioned. |
Beta Was this translation helpful? Give feedback.
-
@tdalvi , How are things going? Is my above suggestion helpful to you? If you have any question about this ticket, feel free to contact us. |
Beta Was this translation helpful? Give feedback.
-
@brightran @airtower-luna Thank you both for the suggestions. I managed to solve this issue last Sunday. Here is what I did. After the test run was complete and the test file created on the container, I ran the command “docker cp name of container:/path/to/testfile/TestResults.html .”. In case it is not obvious, there is a “.” at the end of that statement. This copied my test file from the container to the location “/home/runner/work/myrepo/myrepo”. Then, in the next step I used the upload artifact as @airtower-luna suggested. For the “Path”, I entered “./TestResults.html”. The file was uploaded as an artifact. |
Beta Was this translation helpful? Give feedback.
-
@tdalvi I am doing a similar functionality but running into issues with generating the test file in docker when I run it from GitHub Actions. It works in local and html gets added to test reports folder. How can I make sure I can generate the report and use volumes to copy to the local folder? Below is what I have in my yaml file.
|
Beta Was this translation helpful? Give feedback.
@brightran @airtower-luna Thank you both for the suggestions. I managed to solve this issue last Sunday. Here is what I did. After the test run was complete and the test file created on the container, I ran the command “docker cp name of container:/path/to/testfile/TestResults.html .”. In case it is not obvious, there is a “.” at the end of that statement. This copied my test file from the container to the location “/home/runner/work/myrepo/myrepo”. Then, in the next step I used the upload artifact as @airtower-luna suggested. For the “Path”, I entered “./TestResults.html”. The file was uploaded as an artifact.