Skip to content

A peer-to-peer stack for code collaboration

Setup upstream when initialising a project (#484)

Merle Breitkreuz5a25d54f668b
diff --git a/README.md b/README.md
index b5da238..d18da88 100644
--- a/README.md
+++ b/README.md
@@ -63,8 +63,11 @@ into version control.
### End-to-end Tests
-The end-to-end test suite is run with `stack test :e2e`. It requires you to
-start up an IPFS test network and the Raicle daemon.
+The end-to-end test suite is run with
+
+ RAD_IPFS_API_URL=http://localhost:19301 stack test :e2e
+
+It requires you to start up an IPFS test network and the Raicle daemon.
docker-compose -f test/docker-compose.yaml up -d ipfs-test-network
RAD_IPFS_API_URL=http://localhost:19301 stack exec -- \
diff --git a/bin/rad-project b/bin/rad-project
index b33ee4b..659e181 100755
--- a/bin/rad-project
+++ b/bin/rad-project
@@ -98,6 +98,23 @@
_ (do (put-str! "You must select either 1 or 2.")
(exit! 1)))))
+(def setup-upstream!
+ "Creates a commit to set the upstream to master, if master does not exist yet"
+ (fn []
+ (match (process-with-stdout! "git" ["show-ref" "refs/heads/master"] "")
+ [] (do
+ (process-git-with-exit!
+ ["commit" "--allow-empty" "--message" "Radicle Setup"]
+ (string-append
+ "Error: git --allow-empty --message \"Radicle Setup\" failed.\n"
+ "Make sure that git was initialized correctly and rerun 'rad project init'"))
+ (process-git-with-exit!
+ ["push" "-u" "origin" "master"]
+ (string-append
+ "Error: git -u origin master failed.\n"
+ "Set the upstream branch manually and rerun 'rad project init'")))
+ _ :ok)))
+
(def new-project!
"Create a new project."
(fn []
@@ -113,6 +130,7 @@
(put-str! "=> Assembled rad-diff machine")
(put-str! (string-append "=> project id: " project))
(process! "git" ["remote" "add" "origin" repo] "")
+ (setup-upstream!)
(add-rsm! project { :id repo :type :rad-repo })
(add-rsm! project { :id issues :type :rad-issue })
(add-rsm! project { :id diff :type :rad-diff })
diff --git a/ci/Dockerfile b/ci/Dockerfile
index 9fbc664..9568a39 100644
--- a/ci/Dockerfile
+++ b/ci/Dockerfile
@@ -32,3 +32,9 @@ RUN \
# Install `docker-compose`
ADD https://github.com/docker/compose/releases/download/1.23.2/docker-compose-Linux-x86_64 /usr/local/bin/docker-compose
RUN chmod +x /usr/local/bin/docker-compose
+
+# Install `ipfs`
+ADD https://dist.ipfs.io/go-ipfs/v0.4.18/go-ipfs_v0.4.18_linux-amd64.tar.gz ipfs.tgz
+RUN \
+ tar --extract --file ipfs.tgz --strip-components=1 -C /usr/bin go-ipfs/ipfs && \
+ rm ipfs.tgz
diff --git a/cloudbuild.yaml b/cloudbuild.yaml
index 5939a71..d805751 100644
--- a/cloudbuild.yaml
+++ b/cloudbuild.yaml
@@ -1,7 +1,7 @@
timeout: 3600s # Cache misses are slow to rebuild
substitutions:
# Bump the version if you make changes to `ci/Dockerfile
- _BUILD_IMAGE: eu.gcr.io/opensourcecoin/radicle-ci:v1
+ _BUILD_IMAGE: eu.gcr.io/opensourcecoin/radicle-ci:v2
options:
machineType: N1_HIGHCPU_8
steps:
diff --git a/snapshot.yaml b/snapshot.yaml
index 7059376..6023424 100644
--- a/snapshot.yaml
+++ b/snapshot.yaml
@@ -16,7 +16,7 @@ packages:
- sandi-0.4.3@sha256:2ada9c759424f243095ab28b55687cdec4e9d16bac3589f9d200280207c50216
- serialise-0.2.1.0
- git: https://github.com/oscoin/ipfs.git
- commit: 19b25fa4d0003b5c2027c8cc1b8a3c36ac2f9f60
+ commit: 421c5fc975b8ef030ba5e631af424be6c7fdd2bb
subdirs:
- ipfs-api
- ipld-cid
diff --git a/test/e2e/DiffAppTest.hs b/test/e2e/DiffAppTest.hs
index bda2bd4..ce714c7 100644
--- a/test/e2e/DiffAppTest.hs
+++ b/test/e2e/DiffAppTest.hs
@@ -14,6 +14,7 @@ test_diff_propose = testCaseSteps "diff propose" $ \step -> do
_ <- runTestCommand "git" ["config", "--global", "user.name", "Alice"]
_ <- runTestCommand "git" ["config", "--global", "user.email", "[email protected]"]
_ <- runTestCommand' "rad-project" ["init"] ["project-name", "project desc", "1"]
+ _ <- runTestCommand "git" ["checkout", "-b", "f/test"]
_ <- runTestCommand "touch" ["test"]
_ <- runTestCommand "git" ["add", "test"]
_ <- runTestCommand "git" ["commit", "--message", "first commit"]
@@ -23,10 +24,20 @@ test_diff_propose = testCaseSteps "diff propose" $ \step -> do
_ <- runTestCommand "rad-diff" ["propose", "HEAD"]
listOutput <- runTestCommand "rad-diff" ["list"]
- assertContains listOutput $ "state #"
- assertContains listOutput $ "pending 0"
+ assertContains listOutput "state #"
+ assertContains listOutput "pending 0"
showOutput <- runTestCommand "rad-diff" ["show", "0"]
- assertContains showOutput $ "pending 0"
+ assertContains showOutput "pending 0"
assertContains showOutput $ "From " <> commitSha
- assertContains showOutput $ "Comments\n---"
+ assertContains showOutput "Comments\n---"
+
+ step "rad diff accept"
+ _ <- runTestCommand "git" ["checkout", "master"]
+ _ <- runTestCommand "rad-diff" ["accept", "0"]
+
+ showAcceptedOutput <- runTestCommand "rad-diff" ["show", "0"]
+ assertContains showAcceptedOutput "accepted 0"
+
+ logOutput <- runTestCommand "git" ["log", "master"]
+ assertContains logOutput "first commit"
diff --git a/test/e2e/Test/E2ESupport.hs b/test/e2e/Test/E2ESupport.hs
index 96e6d32..af9e7d3 100644
--- a/test/e2e/Test/E2ESupport.hs
+++ b/test/e2e/Test/E2ESupport.hs
@@ -110,7 +110,8 @@ runTestCommand' :: (HasCallStack) => FilePath -> [Text] -> [Text] -> TestM Text
runTestCommand' bin args inputLines = do
TestEnv {..} <- ask
searchPath <- liftIO $ getEnv "PATH"
- let env = [("PATH", searchPath), ("HOME", homeDir), ("RADPATH", projectDir </> "rad")]
+ radIpfsApiUrl <- liftIO $ getEnv "RAD_IPFS_API_URL"
+ let env = [("PATH", searchPath), ("HOME", homeDir), ("RADPATH", projectDir </> "rad"), ("RAD_IPFS_API_URL", radIpfsApiUrl)]
let argsString = map toS args
let procSpec = (proc bin argsString) { env = Just env }
let input = T.unpack $ T.intercalate "\n" inputLines