Skip to content

Commit 5458036

Browse files
BalestraPatricktmspzz
authored andcommitted
Add cache prefix to remote framework upload path with engine (#192)
* Add cache prefix to remote framework upload path with engine * Add tests for checking that list command includes cache prefix in engine
1 parent 10e7a05 commit 5458036

File tree

4 files changed

+32
-7
lines changed

4 files changed

+32
-7
lines changed

integration-tests/current-framework-named-engine-yml.bats

+13
Original file line numberDiff line numberDiff line change
@@ -221,3 +221,16 @@ teardown() {
221221
[ -d "Carthage/Build/watchOS/${FRAMEWORK_ARTIFACT_NAME}.framework.dSYM" ]
222222
[ -f "Carthage/Build/watchOS/${WATCHOS_ARMV7K_DWARF_UUID}.bcsymbolmap" ]
223223
}
224+
225+
@test "rome list named artifacts for current framework with engine skipping local cache (dynamic, yaml)" {
226+
227+
# restore server cache
228+
if [ -d "../../_server-cache_bkp" ]; then
229+
echo "# Server cache restored" >&3
230+
cp -R ../../_server-cache_bkp server-cache/
231+
fi
232+
233+
run rome list --cache-prefix travis
234+
235+
[ "$status" -eq 0 ]
236+
}

integration-tests/engine.sh

+7-2
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ STORAGE_DIR="server-cache"
99
if [ "$ACTION" == "upload" ]; then
1010
LOCAL_PATH="$2"
1111
REMOTE_PATH="$3"
12-
# POST request to upload file to remote path
1312
# create directory structure if it doesn't exist yet
1413
mkdir -p $STORAGE_DIR/$(dirname $REMOTE_PATH)
1514
# fake the upload of a file by just copying binary to the storage directory
@@ -28,8 +27,14 @@ elif [ "$ACTION" == "download" ]; then
2827

2928
elif [ "$ACTION" == "list" ]; then
3029
REMOTE_PATH="$2"
30+
31+
# verify that the list command contains the cache prefix
32+
if [[ ! "$REMOTE_PATH" =~ "travis" ]]; then
33+
exit 1
34+
fi
35+
3136
# fake list command by just checking if file exists
32-
if [ ! -f "$STORAGE_DIR/$REMOTE_PATH" ]; then
37+
if [[ ! -f "$STORAGE_DIR/$REMOTE_PATH" ]]; then
3338
exit 1
3439
fi
3540

src/Engine/Probing.hs

+10-5
Original file line numberDiff line numberDiff line change
@@ -9,37 +9,41 @@ import Data.Romefile (_frameworkPlatforms)
99
import Types hiding (version)
1010
import Utils
1111
import qualified Turtle
12+
import System.FilePath ((</>))
1213

1314

1415
-- | Probes a `FilePath` to check if each `FrameworkVersion` exists for each `TargetPlatform`
1516
probeEngineForFrameworks
1617
:: MonadIO m
1718
=> FilePath -- ^ The `FilePath` to the engine
19+
-> CachePrefix -- ^ The top level directory prefix.
1820
-> InvertedRepositoryMap -- ^ The map used to resolve `FrameworkName`s to `GitRepoName`s.
1921
-> [FrameworkVersion] -- ^ A list of `FrameworkVersion` to probe for.
2022
-> [TargetPlatform] -- ^ A list target platforms restricting the scope of this action.
2123
-> m [FrameworkAvailability]
22-
probeEngineForFrameworks lCacheDir reverseRomeMap frameworkVersions
24+
probeEngineForFrameworks lCacheDir cachePrefix reverseRomeMap frameworkVersions
2325
= sequence . probeForEachFramework
2426
where
2527
probeForEachFramework = mapM
26-
(probeEngineForFramework lCacheDir reverseRomeMap)
28+
(probeEngineForFramework lCacheDir cachePrefix reverseRomeMap)
2729
frameworkVersions
2830

2931

3032
-- | Probes the engine at `FilePath` to check if a `FrameworkVersion` exists for each `TargetPlatform`
3133
probeEngineForFramework
3234
:: MonadIO m
3335
=> FilePath -- ^ The `FilePath` to the engine
36+
-> CachePrefix -- ^ The top level directory prefix.
3437
-> InvertedRepositoryMap -- ^ The map used to resolve `FrameworkName`s to `GitRepoName`s.
3538
-> FrameworkVersion -- ^ The `FrameworkVersion` to probe for.
3639
-> [TargetPlatform] -- ^ A list target platforms restricting the scope of this action.
3740
-> m FrameworkAvailability
38-
probeEngineForFramework lCacheDir reverseRomeMap frameworkVersion platforms
41+
probeEngineForFramework lCacheDir cachePrefix reverseRomeMap frameworkVersion platforms
3942
= fmap (FrameworkAvailability frameworkVersion) probeForEachPlatform
4043
where
4144
probeForEachPlatform = mapM
4245
(probeEngineForFrameworkOnPlatform lCacheDir
46+
cachePrefix
4347
reverseRomeMap
4448
frameworkVersion
4549
)
@@ -50,16 +54,17 @@ probeEngineForFramework lCacheDir reverseRomeMap frameworkVersion platforms
5054
probeEngineForFrameworkOnPlatform
5155
:: MonadIO m
5256
=> FilePath -- ^ The `FilePath` to the engine
57+
-> CachePrefix -- ^ The top level directory prefix.
5358
-> InvertedRepositoryMap -- ^ The map used to resolve `FrameworkName`s to `GitRepoName`s.
5459
-> FrameworkVersion -- ^ The `FrameworkVersion` to probe for.
5560
-> TargetPlatform -- ^ A target platforms restricting the scope of this action.
5661
-> m PlatformAvailability
57-
probeEngineForFrameworkOnPlatform enginePath reverseRomeMap (FrameworkVersion fwn version) platform
62+
probeEngineForFrameworkOnPlatform enginePath (CachePrefix prefix) reverseRomeMap (FrameworkVersion fwn version) platform
5863
= do
5964
let cmd = Turtle.fromString enginePath
6065
exitCode <- Turtle.proc
6166
cmd
62-
["list", Turtle.fromString remoteFrameworkUploadPath]
67+
["list", Turtle.fromString (prefix </> remoteFrameworkUploadPath)]
6368
(return $ Turtle.unsafeTextToLine "")
6469
case exitCode of
6570
-- If engine exits with success, we assume the framework exists.

src/Lib.hs

+2
Original file line numberDiff line numberDiff line change
@@ -521,7 +521,9 @@ getProjectAvailabilityFromCaches Nothing (Just lCacheDir) Nothing reverseReposit
521521

522522
getProjectAvailabilityFromCaches Nothing _ (Just ePath) reverseRepositoryMap frameworkVersions platforms
523523
= do
524+
(cachePrefix, _, _) <- ask
524525
availabilities <- probeEngineForFrameworks ePath
526+
cachePrefix
525527
reverseRepositoryMap
526528
frameworkVersions
527529
platforms

0 commit comments

Comments
 (0)