From a4aa3abd564275fa346442ce1825273e181c6db3 Mon Sep 17 00:00:00 2001 From: Sean Pollock Date: Tue, 22 Oct 2024 16:17:59 -0400 Subject: [PATCH] [RSDK-9086] Move from git lfs to artifact (#23) * Initial artifact impl * Point to new storage dir * Use artifact clean to delete tmp storage files * Remove git lfs files * Config fix * Add const for artifact path * Use artifactStoragePath in config tests --- .artifact/config.json | 12 ++++++++++ .artifact/tree.json | 26 +++++++++++++++++++++ .gitattributes | 1 - Makefile | 6 ++++- tests/config_test.go | 5 ++-- tests/fetch_test.go | 3 +-- tests/save_test.go | 3 +-- 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 13 files changed, 48 insertions(+), 23 deletions(-) create mode 100644 .artifact/config.json create mode 100644 .artifact/tree.json delete mode 100644 .gitattributes 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/.artifact/config.json b/.artifact/config.json new file mode 100644 index 0000000..d08650f --- /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" + ] +} 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/.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 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/config_test.go b/tests/config_test.go index 7898b24..d079e80 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) { @@ -57,13 +58,13 @@ func cleanVideoStoreDir() error { if err != nil { return err } - videoStoreDir := filepath.Join(currentDir, "video-storage") + videoStoreDir := filepath.Join(currentDir, artifactStoragePath) err = os.Chdir(videoStoreDir) if err != nil { 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() diff --git a/tests/fetch_test.go b/tests/fetch_test.go index 4a303ea..53b029f 100644 --- a/tests/fetch_test.go +++ b/tests/fetch_test.go @@ -12,8 +12,7 @@ import ( ) func TestFetchDoCommand(t *testing.T) { - storageRelativePath := "./video-storage" - 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 4c6e064..7f65644 100644 --- a/tests/save_test.go +++ b/tests/save_test.go @@ -13,8 +13,7 @@ import ( ) func TestSaveDoCommand(t *testing.T) { - storageRelativePath := "./video-storage" - 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/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