Skip to content

Commit d53d41c

Browse files
author
Christopher-Marcel Böddecker
committed
fix(templates): move Unity .meta files check to CD steps
Moving the Unity `.meta` files check to the CD steps ensures that the check is only done for files that will be used as a Unity package. This allows a project to not having to ship meta files for every single file in the project.
1 parent 84a48c4 commit d53d41c

File tree

5 files changed

+69
-14
lines changed

5 files changed

+69
-14
lines changed

.devops/azure-pipelines.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,5 @@ variables:
33

44
jobs:
55
- template: ../templates/jobs/cd.yml
6+
parameters:
7+
unityProject: false

templates/jobs/cd.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,12 @@
1+
parameters:
2+
unityProject: true
3+
14
jobs:
25
- job: Job
36
displayName: CD
47
pool:
58
vmImage: vs2017-win2016
69
steps:
710
- template: ../steps/cd.yml
11+
parameters:
12+
unityProject: ${{ parameters.unityProject }}

templates/jobs/ci+cd.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,3 +19,5 @@ jobs:
1919
unityProject: ${{ parameters.unityProject }}
2020
unityVersion: ${{ parameters.unityVersion }}
2121
- template: ../steps/cd.yml
22+
parameters:
23+
unityProject: ${{ parameters.unityProject }}

templates/steps/cd.yml

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,65 @@
1+
parameters:
2+
unityProject: true
3+
14
steps:
25
- ${{ if ne(variables['Build.Reason'], 'PullRequest') }}:
6+
- ${{ if parameters.unityProject }}:
7+
- bash: |
8+
npm pack
9+
tarball=$(npm list — depth 0 | sed "s/@/-/g; s/ .*/.tgz/g; 1q;")
10+
tarballFilePaths=$(tar -tf $tarball)
11+
12+
for filePath in $tarballFilePaths
13+
do
14+
case $filePath in
15+
*.meta)
16+
metaFilePath=$filePath
17+
found=false
18+
regularFilePath=${metaFilePath%.meta}
19+
for otherFilePath in $tarballFilePaths
20+
do
21+
case $otherFilePath in
22+
$regularFilePath/* | $regularFilePath*) # folder or file
23+
if [ $metaFilePath != $otherFilePath ]
24+
then
25+
found=true
26+
break
27+
fi;;
28+
esac
29+
done
30+
if [ "$found" = false ]
31+
then
32+
echo "Missing file for Unity meta file '$metaFilePath'." >&2
33+
fi;;
34+
esac
35+
done
36+
37+
for filePath in $tarballFilePaths
38+
do
39+
case $filePath in
40+
*.meta)
41+
;;
42+
*)
43+
regularFilePath=$filePath
44+
found=false
45+
for otherFilePath in $tarballFilePaths
46+
do
47+
case $otherFilePath in
48+
$regularFilePath.meta)
49+
found=true
50+
break;;
51+
esac
52+
done
53+
if [ "$found" = false ]
54+
then
55+
echo "Missing Unity meta file for file '$regularFilePath'." >&2
56+
fi;;
57+
esac
58+
done
59+
60+
rm -f $tarball
61+
displayName: Check Unity .meta files
62+
failOnStderr: true
363
- bash: |
464
mv -f package.json package.json.original
565
cat > package.json <<- "EOF"

templates/steps/ci.yml

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -57,17 +57,3 @@ steps:
5757
msbuildArchitecture: x64
5858
${{ if parameters.unityProject }}:
5959
msbuildArgs: /p:UnityEditorAssembliesPath="$(Unity.Path)Editor/Data/Managed/"
60-
- ${{ if parameters.unityProject }}:
61-
- bash: |
62-
for entry in $(find . -not -path "*/\.*" -not -path . -not -name "*.meta")
63-
do if [ ! -f "$entry.meta" ]
64-
then echo "Missing Unity meta file for '$entry'." >&2
65-
fi
66-
done
67-
for entry in $(find . -not -path "*/\.*" -not -path . -name "*.meta")
68-
do if [ ! -f ${entry::-5} ] && [ ! -d ${entry::-5} ]; then
69-
echo "Missing file for Unity meta file '$entry'." >&2
70-
fi
71-
done
72-
displayName: Check Unity .meta files
73-
failOnStderr: true

0 commit comments

Comments
 (0)