From 79106cbdc37e0281f64f90154a7f119b0fcbf03a Mon Sep 17 00:00:00 2001 From: seanavery Date: Mon, 21 Oct 2024 14:16:42 -0400 Subject: [PATCH 1/7] Initial artifact impl --- .artifact/config.json | 12 ++++++++++++ .artifact/tree.json | 26 ++++++++++++++++++++++++++ Makefile | 6 +++++- tests/fetch_test.go | 2 +- tests/save_test.go | 2 +- 5 files changed, 45 insertions(+), 3 deletions(-) create mode 100644 .artifact/config.json create mode 100644 .artifact/tree.json diff --git a/.artifact/config.json b/.artifact/config.json new file mode 100644 index 0000000..6eadf18 --- /dev/null +++ b/.artifact/config.json @@ -0,0 +1,12 @@ +{ + "cache": "cache", + "root": "data", + "source_store": + { + "type": "google_storage", + "bucket": "viam-artifacts" + }, + "ignore": [ + ".DS_Store" + ] +} \ No newline at end of file diff --git a/.artifact/tree.json b/.artifact/tree.json new file mode 100644 index 0000000..dad8829 --- /dev/null +++ b/.artifact/tree.json @@ -0,0 +1,26 @@ +{ + "2024-09-06_15-00-03.mp4": { + "hash": "51ddfed2c6edf7068d4baafa424d2d13", + "size": 3797453 + }, + "2024-09-06_15-00-33.mp4": { + "hash": "d96670498a068faa95a407e8a57ca864", + "size": 3778888 + }, + "2024-09-06_15-01-03.mp4": { + "hash": "a4a27063cdab70eb928c975a1ade9365", + "size": 3786918 + }, + "2024-09-06_15-01-33.mp4": { + "hash": "dfcf4f6acfb42ea15abf08d8264f5a5d", + "size": 3798806 + }, + "2024-09-06_15-02-03.mp4": { + "hash": "f49319e1bb705f6db371888b3300888c", + "size": 3779515 + }, + "malformed_file_name.mp4": { + "hash": "6c62272e07bb014262b821756295c58d", + "size": 0 + } +} diff --git a/Makefile b/Makefile index 4fd9e8a..c7bc425 100644 --- a/Makefile +++ b/Makefile @@ -45,6 +45,7 @@ endif CGO_CFLAGS := -I$(FFMPEG_BUILD)/include GOFLAGS := -buildvcs=false export PKG_CONFIG_PATH=$(FFMPEG_BUILD)/lib/pkgconfig +export PATH := $(PATH):$(shell go env GOPATH)/bin .PHONY: lint tool-install test clean module @@ -91,7 +92,10 @@ ifeq ($(SOURCE_OS),darwin) brew update && brew install ffmpeg endif endif - git lfs pull +ifeq ($(shell which artifact > /dev/null 2>&1; echo $$?), 1) + go install go.viam.com/utils/artifact/cmd/artifact@latest +endif + artifact pull cp $(BIN_OUTPUT_PATH)/video-store bin/video-store go test -v ./tests/ rm bin/video-store diff --git a/tests/fetch_test.go b/tests/fetch_test.go index 4a303ea..4eb8fea 100644 --- a/tests/fetch_test.go +++ b/tests/fetch_test.go @@ -12,7 +12,7 @@ import ( ) func TestFetchDoCommand(t *testing.T) { - storageRelativePath := "./video-storage" + storageRelativePath := "../.artifact/data" storagePath, err := filepath.Abs(storageRelativePath) test.That(t, err, test.ShouldBeNil) fullModuleBinPath, err := getModuleBinPath() diff --git a/tests/save_test.go b/tests/save_test.go index 4c6e064..c91f468 100644 --- a/tests/save_test.go +++ b/tests/save_test.go @@ -13,7 +13,7 @@ import ( ) func TestSaveDoCommand(t *testing.T) { - storageRelativePath := "./video-storage" + storageRelativePath := "../.artifact/data" storagePath, err := filepath.Abs(storageRelativePath) test.That(t, err, test.ShouldBeNil) fullModuleBinPath, err := getModuleBinPath() From d37f989eecdd58f861a357df16c5396f37aca815 Mon Sep 17 00:00:00 2001 From: seanavery Date: Mon, 21 Oct 2024 15:51:08 -0400 Subject: [PATCH 2/7] Point to new storage dir --- tests/config_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/config_test.go b/tests/config_test.go index 7898b24..9a80774 100644 --- a/tests/config_test.go +++ b/tests/config_test.go @@ -57,7 +57,7 @@ func cleanVideoStoreDir() error { if err != nil { return err } - videoStoreDir := filepath.Join(currentDir, "video-storage") + videoStoreDir := filepath.Join(currentDir, "../.artifact/data") err = os.Chdir(videoStoreDir) if err != nil { return err From dfac5187e1b14f6b420d7370ebe3a7d3c8821f63 Mon Sep 17 00:00:00 2001 From: seanavery Date: Mon, 21 Oct 2024 16:17:44 -0400 Subject: [PATCH 3/7] Use artifact clean to delete tmp storage files --- tests/config_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/config_test.go b/tests/config_test.go index 9a80774..286bef5 100644 --- a/tests/config_test.go +++ b/tests/config_test.go @@ -63,7 +63,7 @@ func cleanVideoStoreDir() error { return err } defer os.Chdir(currentDir) // Ensure we change back to the original directory - cmd := exec.Command("git", "clean", "-fdx") + cmd := exec.Command("artifact", "clean") cmd.Stdout = os.Stdout cmd.Stderr = os.Stderr return cmd.Run() From dafba9a61eff680aa6fe153a9821b7f00cbd5bee Mon Sep 17 00:00:00 2001 From: seanavery Date: Mon, 21 Oct 2024 16:21:10 -0400 Subject: [PATCH 4/7] Remove git lfs files --- tests/video-storage/2024-09-06_15-00-03.mp4 | 3 --- tests/video-storage/2024-09-06_15-00-33.mp4 | 3 --- tests/video-storage/2024-09-06_15-01-03.mp4 | 3 --- tests/video-storage/2024-09-06_15-01-33.mp4 | 3 --- tests/video-storage/2024-09-06_15-02-03.mp4 | 3 --- tests/video-storage/malformed_file_name.mp4 | 0 6 files changed, 15 deletions(-) delete mode 100644 tests/video-storage/2024-09-06_15-00-03.mp4 delete mode 100644 tests/video-storage/2024-09-06_15-00-33.mp4 delete mode 100644 tests/video-storage/2024-09-06_15-01-03.mp4 delete mode 100644 tests/video-storage/2024-09-06_15-01-33.mp4 delete mode 100644 tests/video-storage/2024-09-06_15-02-03.mp4 delete mode 100644 tests/video-storage/malformed_file_name.mp4 diff --git a/tests/video-storage/2024-09-06_15-00-03.mp4 b/tests/video-storage/2024-09-06_15-00-03.mp4 deleted file mode 100644 index e3b44ee..0000000 --- a/tests/video-storage/2024-09-06_15-00-03.mp4 +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:fc12cc7f6bc0738bd952e994c987f7b7cced255ed5911d9391a84cee3b2227f8 -size 3797453 diff --git a/tests/video-storage/2024-09-06_15-00-33.mp4 b/tests/video-storage/2024-09-06_15-00-33.mp4 deleted file mode 100644 index 994198f..0000000 --- a/tests/video-storage/2024-09-06_15-00-33.mp4 +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:038db2091a304a8f4a31892385fd31f85a415f6f6cdb7960b79c6fcfcc68e9a4 -size 3778888 diff --git a/tests/video-storage/2024-09-06_15-01-03.mp4 b/tests/video-storage/2024-09-06_15-01-03.mp4 deleted file mode 100644 index 4f23e81..0000000 --- a/tests/video-storage/2024-09-06_15-01-03.mp4 +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:09f1b376d13ebd79842cbf8f922a099dc66db8b6447c80298cb8971344cfef4b -size 3786918 diff --git a/tests/video-storage/2024-09-06_15-01-33.mp4 b/tests/video-storage/2024-09-06_15-01-33.mp4 deleted file mode 100644 index 44ce7d1..0000000 --- a/tests/video-storage/2024-09-06_15-01-33.mp4 +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:369c44d8c0f8036586d00ef50eed9a7570e0089f7cbfe4ba0a5636586fa42c8c -size 3798806 diff --git a/tests/video-storage/2024-09-06_15-02-03.mp4 b/tests/video-storage/2024-09-06_15-02-03.mp4 deleted file mode 100644 index 5157187..0000000 --- a/tests/video-storage/2024-09-06_15-02-03.mp4 +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:8af6f7b1e8dbc0cb844244ce3fc17cd26bd4d51998ac057160f3d23d9a279bac -size 3779515 diff --git a/tests/video-storage/malformed_file_name.mp4 b/tests/video-storage/malformed_file_name.mp4 deleted file mode 100644 index e69de29..0000000 From 1ee88a5ce7516183fe2d31255a6f04d4d436149b Mon Sep 17 00:00:00 2001 From: seanavery Date: Mon, 21 Oct 2024 16:24:19 -0400 Subject: [PATCH 5/7] Config fix --- .artifact/config.json | 2 +- .gitattributes | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) delete mode 100644 .gitattributes diff --git a/.artifact/config.json b/.artifact/config.json index 6eadf18..d08650f 100644 --- a/.artifact/config.json +++ b/.artifact/config.json @@ -9,4 +9,4 @@ "ignore": [ ".DS_Store" ] -} \ No newline at end of file +} diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index f8ff2b5..0000000 --- a/.gitattributes +++ /dev/null @@ -1 +0,0 @@ -*.mp4 filter=lfs diff=lfs merge=lfs -text From e6ebbbbbeb834c4f4cf6638a7b2a563c85021fac Mon Sep 17 00:00:00 2001 From: seanavery Date: Mon, 21 Oct 2024 16:32:12 -0400 Subject: [PATCH 6/7] Add const for artifact path --- tests/config_test.go | 1 + tests/fetch_test.go | 3 +-- tests/save_test.go | 3 +-- 3 files changed, 3 insertions(+), 4 deletions(-) diff --git a/tests/config_test.go b/tests/config_test.go index 286bef5..c19b257 100644 --- a/tests/config_test.go +++ b/tests/config_test.go @@ -25,6 +25,7 @@ const ( videoStoreComponentName = "video-store-1" testStoragePath = "/tmp/video-storage" testUploadPath = "/tmp/video-upload" + artifactStoragePath = "../.artifact/data" ) func setupViamServer(ctx context.Context, configStr string) (robot.Robot, error) { diff --git a/tests/fetch_test.go b/tests/fetch_test.go index 4eb8fea..53b029f 100644 --- a/tests/fetch_test.go +++ b/tests/fetch_test.go @@ -12,8 +12,7 @@ import ( ) func TestFetchDoCommand(t *testing.T) { - storageRelativePath := "../.artifact/data" - storagePath, err := filepath.Abs(storageRelativePath) + storagePath, err := filepath.Abs(artifactStoragePath) test.That(t, err, test.ShouldBeNil) fullModuleBinPath, err := getModuleBinPath() test.That(t, err, test.ShouldBeNil) diff --git a/tests/save_test.go b/tests/save_test.go index c91f468..7f65644 100644 --- a/tests/save_test.go +++ b/tests/save_test.go @@ -13,8 +13,7 @@ import ( ) func TestSaveDoCommand(t *testing.T) { - storageRelativePath := "../.artifact/data" - storagePath, err := filepath.Abs(storageRelativePath) + storagePath, err := filepath.Abs(artifactStoragePath) test.That(t, err, test.ShouldBeNil) fullModuleBinPath, err := getModuleBinPath() test.That(t, err, test.ShouldBeNil) From 8f7226af43d6228baf156440de8d7bf6cafd7543 Mon Sep 17 00:00:00 2001 From: seanavery Date: Tue, 22 Oct 2024 15:15:41 -0400 Subject: [PATCH 7/7] Use artifactStoragePath in config tests --- tests/config_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/config_test.go b/tests/config_test.go index c19b257..d079e80 100644 --- a/tests/config_test.go +++ b/tests/config_test.go @@ -58,7 +58,7 @@ func cleanVideoStoreDir() error { if err != nil { return err } - videoStoreDir := filepath.Join(currentDir, "../.artifact/data") + videoStoreDir := filepath.Join(currentDir, artifactStoragePath) err = os.Chdir(videoStoreDir) if err != nil { return err