| 
									
										
										
										
											2021-07-12 21:06:03 +00:00
										 |  |  | #!/bin/sh
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-07-31 20:44:53 +00:00
										 |  |  | cacheFolderFull=$1 | 
					
						
							| 
									
										
										
										
											2021-08-02 00:07:25 +00:00
										 |  |  | branch=$2 | 
					
						
							| 
									
										
										
										
											2021-07-31 20:44:53 +00:00
										 |  |  | libraryFolderFull=$3 | 
					
						
							| 
									
										
										
										
											2021-07-31 21:41:55 +00:00
										 |  |  | gitLFSDestinationFolder=$4 | 
					
						
							|  |  |  | purgeRemoteBuilderCache=$5 | 
					
						
							| 
									
										
										
										
											2021-08-01 22:04:09 +00:00
										 |  |  | LFS_ASSETS_HASH=$6 | 
					
						
							| 
									
										
										
										
											2021-07-12 21:06:03 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-08-02 00:07:25 +00:00
										 |  |  | cacheFolderWithBranch="$cacheFolderFull/$branch" | 
					
						
							|  |  |  | lfsCacheFolder="$cacheFolderFull/$branch/lfs" | 
					
						
							|  |  |  | libraryCacheFolder="$cacheFolderFull/$branch/lib" | 
					
						
							| 
									
										
										
										
											2021-07-31 21:19:17 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-08-01 01:04:38 +00:00
										 |  |  | mkdir -p "$lfsCacheFolder" | 
					
						
							|  |  |  | mkdir -p "$libraryCacheFolder" | 
					
						
							| 
									
										
										
										
											2021-07-27 20:45:49 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-08-01 01:04:38 +00:00
										 |  |  | # if the unity git project has included the library delete it and echo a warning | 
					
						
							| 
									
										
										
										
											2021-07-27 22:40:48 +00:00
										 |  |  | if [ -d "$libraryFolderFull" ]; then | 
					
						
							| 
									
										
										
										
											2021-07-31 20:44:53 +00:00
										 |  |  |   rm -r "$libraryFolderFull" | 
					
						
							| 
									
										
										
										
											2021-08-01 01:04:38 +00:00
										 |  |  |   echo "!Warning!: The Unity library was included in the git repository (this isn't usually a good practice)" | 
					
						
							| 
									
										
										
										
											2021-07-27 20:45:49 +00:00
										 |  |  | fi | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-07-12 21:06:03 +00:00
										 |  |  | echo "Checking cache" | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-07-12 22:36:40 +00:00
										 |  |  | # Restore library cache | 
					
						
							| 
									
										
										
										
											2021-08-01 15:49:21 +00:00
										 |  |  | latestLibraryCacheFile=$(ls -t "$libraryCacheFolder" | grep .zip$ | head -1) | 
					
						
							| 
									
										
										
										
											2021-07-31 21:19:17 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-08-01 01:04:38 +00:00
										 |  |  | if [ ! -z "$latestLibraryCacheFile" ]; then | 
					
						
							| 
									
										
										
										
											2021-08-02 00:07:25 +00:00
										 |  |  |   echo "Library cache exists from build $latestLibraryCacheFile from $branch" | 
					
						
							| 
									
										
										
										
											2021-08-01 18:02:43 +00:00
										 |  |  |   mkdir -p "$libraryFolderFull" | 
					
						
							| 
									
										
										
										
											2021-08-01 22:42:06 +00:00
										 |  |  |   unzip "$libraryCacheFolder/$latestLibraryCacheFile" -d "$libraryFolderFull" | 
					
						
							| 
									
										
										
										
											2021-07-12 21:06:03 +00:00
										 |  |  | fi | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-08-01 20:55:27 +00:00
										 |  |  | echo "Checking cache for a cache match based on the combined large files hash ($lfsCacheFolder/$LFS_ASSETS_HASH.zip)" | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-08-02 00:04:42 +00:00
										 |  |  | if [ -f "$lfsCacheFolder/$LFS_ASSETS_HASH.zip" ]; then | 
					
						
							| 
									
										
										
										
											2021-08-01 20:31:59 +00:00
										 |  |  |   echo "Match found: using large file hash match $LFS_ASSETS_HASH.zip" | 
					
						
							| 
									
										
										
										
											2021-08-01 21:02:06 +00:00
										 |  |  |   latestLFSCacheFile="$LFS_ASSETS_HASH" | 
					
						
							| 
									
										
										
										
											2021-08-01 20:31:59 +00:00
										 |  |  | else | 
					
						
							|  |  |  |   latestLFSCacheFile=$(ls -t "$lfsCacheFolder" | grep .zip$ | head -1) | 
					
						
							|  |  |  |   echo "Match not found: using latest large file cache $latestLFSCacheFile" | 
					
						
							| 
									
										
										
										
											2021-08-01 01:04:38 +00:00
										 |  |  | fi | 
					
						
							| 
									
										
										
										
											2021-07-31 21:41:55 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-08-01 20:31:59 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | if [ ! -f "$lfsCacheFolder/$latestLFSCacheFile" ]; then | 
					
						
							| 
									
										
										
										
											2021-08-02 00:07:25 +00:00
										 |  |  |   echo "LFS cache exists from build $latestLFSCacheFile from $branch" | 
					
						
							| 
									
										
										
										
											2021-08-01 01:04:38 +00:00
										 |  |  |   rm -r "$gitLFSDestinationFolder" | 
					
						
							|  |  |  |   mkdir -p "$gitLFSDestinationFolder" | 
					
						
							| 
									
										
										
										
											2021-08-01 22:42:06 +00:00
										 |  |  |   unzip "$lfsCacheFolder/$latestLFSCacheFile" -d "$gitLFSDestinationFolder" | 
					
						
							| 
									
										
										
										
											2021-07-31 21:41:55 +00:00
										 |  |  | fi | 
					
						
							| 
									
										
										
										
											2021-07-12 22:36:40 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-08-02 00:00:37 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-08-02 00:07:25 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | echo ' ' | 
					
						
							|  |  |  | echo "LFS cache for branch: $branch" | 
					
						
							|  |  |  | ls -lh "$lfsCacheFolder" | 
					
						
							|  |  |  | echo ' ' | 
					
						
							|  |  |  | echo "Library cache for branch: $branch" | 
					
						
							|  |  |  | ls -lh "$libraryCacheFolder" | 
					
						
							| 
									
										
										
										
											2021-08-01 01:14:42 +00:00
										 |  |  | echo ' ' | 
					
						
							| 
									
										
										
										
											2021-08-02 00:07:25 +00:00
										 |  |  | echo "Size of LFS cache folder for branch: $branch" | 
					
						
							| 
									
										
										
										
											2021-08-01 21:14:22 +00:00
										 |  |  | du -sch "$lfsCacheFolder" | 
					
						
							| 
									
										
										
										
											2021-08-02 00:00:37 +00:00
										 |  |  | echo ' ' | 
					
						
							| 
									
										
										
										
											2021-08-02 00:07:25 +00:00
										 |  |  | echo "Size of Library cache folder for branch: $branch" | 
					
						
							| 
									
										
										
										
											2021-08-01 21:14:22 +00:00
										 |  |  | du -sch "$libraryCacheFolder" | 
					
						
							| 
									
										
										
										
											2021-08-01 01:14:42 +00:00
										 |  |  | echo ' ' | 
					
						
							| 
									
										
										
										
											2021-08-02 00:07:25 +00:00
										 |  |  | echo "Size of cache folder for branch: $branch" | 
					
						
							| 
									
										
										
										
											2021-07-31 22:27:59 +00:00
										 |  |  | du -sch "$cacheFolderWithBranch" | 
					
						
							| 
									
										
										
										
											2021-08-01 01:14:42 +00:00
										 |  |  | echo ' ' | 
					
						
							| 
									
										
										
										
											2021-08-02 00:00:37 +00:00
										 |  |  | echo 'Size of cache folder' | 
					
						
							| 
									
										
										
										
											2021-07-31 22:27:59 +00:00
										 |  |  | du -sch "$cacheFolderFull" | 
					
						
							| 
									
										
										
										
											2021-08-01 01:14:42 +00:00
										 |  |  | echo ' ' | 
					
						
							| 
									
										
										
										
											2021-08-02 00:00:37 +00:00
										 |  |  | git lfs pull | 
					
						
							|  |  |  | echo 'pulled latest LFS files' | 
					
						
							|  |  |  | zip -r "$LFS_ASSETS_HASH.zip" "$gitLFSDestinationFolder" | 
					
						
							|  |  |  | cp "$LFS_ASSETS_HASH.zip" "$lfsCacheFolder" | 
					
						
							|  |  |  | echo "copied $LFS_ASSETS_HASH to $lfsCacheFolder" | 
					
						
							|  |  |  | echo ' ' | 
					
						
							| 
									
										
										
										
											2021-07-31 22:27:59 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-07-12 21:06:03 +00:00
										 |  |  | # purge cache | 
					
						
							|  |  |  | if [ "$purgeRemoteBuilderCache" == "true" ]; then | 
					
						
							| 
									
										
										
										
											2021-08-01 16:22:11 +00:00
										 |  |  |   echo "purging the entire cache" | 
					
						
							| 
									
										
										
										
											2021-07-31 21:48:02 +00:00
										 |  |  |   rm -r "$cacheFolderFull" | 
					
						
							| 
									
										
										
										
											2021-08-01 16:22:11 +00:00
										 |  |  |   echo ' ' | 
					
						
							| 
									
										
										
										
											2021-07-12 21:06:03 +00:00
										 |  |  | fi | 
					
						
							| 
									
										
										
										
											2021-08-01 01:04:38 +00:00
										 |  |  | 
 |