Skip to content

Commit 1ef9fa5

Browse files
authored
feat: replace docker cp with a mounted volume in test (#48)
1 parent 08538a8 commit 1ef9fa5

File tree

2 files changed

+12
-11
lines changed

2 files changed

+12
-11
lines changed

src/scripts/windows/prepare-env.sh

+4-2
Original file line numberDiff line numberDiff line change
@@ -93,8 +93,9 @@ if ! resolve_unity_serial; then
9393
exit 1
9494
fi
9595

96-
# Create folder to store the build artifacts.
97-
mkdir -p "$base_dir/build" || { echo "Unable to create the build directory"; exit 1; }
96+
# Create folders to store artifacts.
97+
mkdir -p "$base_dir/build" || { printf '%s\n' "Unable to create the build directory"; exit 1; }
98+
mkdir -p "$base_dir/test" || { printf '%s\n' "Unable to create the test directory"; exit 1; }
9899

99100
set -x
100101

@@ -109,6 +110,7 @@ docker run -dit \
109110
--volume "$unity_project_full_path":C:/unity_project \
110111
--volume "$base_dir"/regkeys:"C:/regkeys" \
111112
--volume "$base_dir"/build:"C:/build" \
113+
--volume "$base_dir"/test:"C:/test" \
112114
--volume "C:/Program Files (x86)/Microsoft Visual Studio":"C:/Program Files (x86)/Microsoft Visual Studio" \
113115
--volume "C:/Program Files (x86)/Windows Kits":"C:/Program Files (x86)/Windows Kits" \
114116
--volume "C:/ProgramData/Microsoft/VisualStudio":"C:/ProgramData/Microsoft/VisualStudio" \

src/scripts/windows/test.sh

+8-9
Original file line numberDiff line numberDiff line change
@@ -20,25 +20,24 @@ trap trap_exit EXIT
2020
docker exec "$CONTAINER_NAME" powershell "[System.Environment]::SetEnvironmentVariable('TEST_PLATFORM','$PARAM_TEST_PLATFORM', [System.EnvironmentVariableTarget]::Machine)"
2121

2222
# Run the tests.
23-
docker exec "$CONTAINER_NAME" powershell '& "C:\Program Files\Unity\Hub\Editor\*\Editor\Unity.exe" -batchmode -nographics -projectPath $Env:PROJECT_PATH -runTests -testPlatform $Env:TEST_PLATFORM -testResults "C:/results.xml" -logfile | Out-Host'
23+
docker exec "$CONTAINER_NAME" powershell '& "C:\Program Files\Unity\Hub\Editor\*\Editor\Unity.exe" -batchmode -nographics -projectPath $Env:PROJECT_PATH -runTests -testPlatform $Env:TEST_PLATFORM -testResults "C:/test/results.xml" -logfile | Out-Host'
2424

2525
# Install JDK to run Saxon.
2626
docker exec "$CONTAINER_NAME" powershell 'choco upgrade jdk8 --no-progress -y'
2727

2828
# Download and extract Saxon-B.
29-
docker exec "$CONTAINER_NAME" powershell 'Invoke-WebRequest -Uri "https://versaweb.dl.sourceforge.net/project/saxon/Saxon-B/9.1.0.8/saxonb9-1-0-8j.zip" -Method "GET" -OutFile "C:/saxonb.zip"'
30-
docker exec "$CONTAINER_NAME" powershell "Expand-Archive -Force C:/saxonb.zip C:/saxonb"
29+
docker exec "$CONTAINER_NAME" powershell 'Invoke-WebRequest -Uri "https://versaweb.dl.sourceforge.net/project/saxon/Saxon-B/9.1.0.8/saxonb9-1-0-8j.zip" -Method "GET" -OutFile "C:/test/saxonb.zip"'
30+
docker exec "$CONTAINER_NAME" powershell "Expand-Archive -Force C:/test/saxonb.zip C:/test/saxonb"
3131

3232
# Copy the Saxon-B template to the container.
33-
printf '%s\n' "$DEPENDENCY_NUNIT_TRANSFORM" > "$base_dir/nunit3-junit.xslt"
34-
docker cp "$base_dir"/nunit3-junit.xslt "$CONTAINER_NAME":C:/nunit3-junit.xslt
33+
printf '%s\n' "$DEPENDENCY_NUNIT_TRANSFORM" > "$base_dir/test/nunit3-junit.xslt"
3534

3635
# Parse Unity's results xml to JUnit format.
37-
docker exec "$CONTAINER_NAME" powershell 'java -jar C:/saxonb/saxon9.jar -s C:/results.xml -xsl C:/nunit3-junit.xslt > C:/$Env:TEST_PLATFORM-junit-results.xml'
36+
docker exec "$CONTAINER_NAME" powershell 'java -jar C:/test/saxonb/saxon9.jar -s C:/test/results.xml -xsl C:/test/nunit3-junit.xslt > C:/test/junit-results.xml'
3837

3938
# Convert CRLF to LF otherwise CircleCI won't be able to read the results.
4039
# https://stackoverflow.com/a/48919146
41-
docker exec "$CONTAINER_NAME" powershell '((Get-Content C:/playmode-junit-results.xml) -join "`n") + "`n" | Set-Content -NoNewline -Encoding utf8 C:/playmode-junit-results-lf.xml'
40+
docker exec "$CONTAINER_NAME" powershell '((Get-Content C:/test/junit-results.xml) -join "`n") + "`n" | Set-Content -NoNewline -Encoding utf8 C:/test/junit-results-lf.xml'
4241

43-
# Copy test results to the host.
44-
docker cp "$CONTAINER_NAME":"$PARAM_TEST_PLATFORM"-junit-results-lf.xml "$unity_project_full_path"/"$PARAM_TEST_PLATFORM"-junit-results.xml
42+
# Move test results to project folder for upload.
43+
mv "$base_dir"/test/junit-results-lf.xml "$unity_project_full_path"/"$PARAM_TEST_PLATFORM"-junit-results.xml

0 commit comments

Comments
 (0)