This is an automated email from the ASF dual-hosted git repository.

msciabarra pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/openserverless-cli.git

commit 8ba20b6c4bc3ed0b9a49bb0c3be2f708ff8ced0e
Author: Michele Sciabarra <[email protected]>
AuthorDate: Fri Jul 26 15:18:45 2024 +0200

    fixed some tests - still need to review update
---
 .gitignore            |  1 -
 Taskfile.yml          | 15 ++++++++++-----
 branch.txt            |  1 +
 common.go             | 15 ++++++++++++---
 main.go               |  5 ++---
 prepare_test.go       |  8 ++++----
 shell.nix             |  7 -------
 tests/auto_setup.bats |  4 ++--
 tests/plugin.bats     |  2 +-
 tests/prereq.bats     | 10 ++++------
 tests/update.bats     |  4 ++--
 version.txt           |  1 +
 12 files changed, 39 insertions(+), 34 deletions(-)

diff --git a/.gitignore b/.gitignore
index 1683916..56e600b 100644
--- a/.gitignore
+++ b/.gitignore
@@ -31,7 +31,6 @@ bin/*/arm64/*
 *.rpm
 *.msi
 *.pkg
-version.txt
 .latestcheck
 bin/unzip.exe
 bin/*/LICENSE
diff --git a/Taskfile.yml b/Taskfile.yml
index 4c7559f..233cbd1 100644
--- a/Taskfile.yml
+++ b/Taskfile.yml
@@ -18,8 +18,8 @@
 version: "3"
 
 vars:
-  BRANCH: main
-  BASEVER: "v1.3.0-snapshot"
+  BRANCH: "0.1.0-testing"
+  BASEVER: "0.1.0-testing"
   VERSION:
     sh: git describe --tags --abbrev=0 2>/dev/null || git rev-parse --short 
HEAD
   DEBUG: ""
@@ -33,7 +33,10 @@ tasks:
     desc: tag the cli to generate the build
     cmds:
     - git tag -d $(git tag)
-    - git tag -f {{.BASEVER}}.$(date +%y%m%d%H%M)
+    - echo "{{.BASEVER}}.$(date +%y%m%d%H%M)" >version.txt
+    - git tag -f "v$(cat version.txt)"
+    - echo "{{.BRANCH}}" >branch.txt
+    - git add version.txt branch.txt
     - git tag
 
 
@@ -45,10 +48,12 @@ tasks:
     desc: build ops locally
     cmds:
       - echo building {{.VERSION}}
-      - go build  {{.DEBUG}} -ldflags "-X main.NuvVersion={{.VERSION}} -X 
main.NuvBranch={{.BASEVER}}" cmd/ops/ops.go
+      - go build  {{.DEBUG}} cmd/ops/ops.go
     sources:
       - "*.go"
-      - "tools/*.go"
+      - "*/*.go"
+      - version.txt
+      - branch.txt
     generates:
       - ops
 
diff --git a/branch.txt b/branch.txt
new file mode 100644
index 0000000..19f64bc
--- /dev/null
+++ b/branch.txt
@@ -0,0 +1 @@
+0.1.0-testing
diff --git a/common.go b/common.go
index bdfd470..f1cb9fe 100644
--- a/common.go
+++ b/common.go
@@ -24,6 +24,8 @@ import (
        "os"
        "path/filepath"
        "strings"
+
+       _ "embed"
 )
 
 // default files
@@ -38,8 +40,15 @@ const NUVREPO = 
"http://github.com/apache/openserverless-task";
 
 // branch where download tasks
 // defaults to test - will be changed in compilation
-var NuvVersion = "main"
-var NuvBranch = "main"
+
+//go:embed version.txt
+var NuvVersion string
+
+//go:embed branch.txt
+var NuvBranch string
+
+//go:embed runtimes.json
+var WSK_RUNTIMES_JSON string
 
 // Represents nuvroot.json. It is used to parse the file.
 type NuvRootJSON struct {
@@ -90,7 +99,7 @@ func getNuvRepo() string {
 func getNuvBranch() string {
        branch := os.Getenv("NUV_BRANCH")
        if branch == "" {
-               branch = NuvBranch
+               branch = strings.TrimSpace(NuvBranch)
        }
        //nolint:errcheck
        os.Setenv("NUV_BRANCH", branch)
diff --git a/main.go b/main.go
index 36c1deb..ea82eb2 100644
--- a/main.go
+++ b/main.go
@@ -97,9 +97,6 @@ func info() {
        fmt.Println("NUV_OLARIS:", os.Getenv("NUV_OLARIS"))
 }
 
-//go:embed runtimes.json
-var WSK_RUNTIMES_JSON string
-
 func Main() {
        // set runtime version as environment variable
        if os.Getenv("WSK_RUNTIMES_JSON") == "" {
@@ -110,6 +107,8 @@ func Main() {
        // set version
        if os.Getenv("NUV_VERSION") != "" {
                NuvVersion = os.Getenv("NUV_VERSION")
+       } else {
+               NuvVersion = strings.TrimSpace(NuvVersion)
        }
 
        // disable log prefix
diff --git a/prepare_test.go b/prepare_test.go
index d178ed9..6b5e424 100644
--- a/prepare_test.go
+++ b/prepare_test.go
@@ -40,7 +40,7 @@ func Example_locate() {
 
 func Example_locate_git() {
        _ = os.Chdir(workDir)
-       NuvBranch = "3.0.0-testing"
+       NuvBranch = "0.1.0-testing"
        nuvdir, _ := homedir.Expand("~/.nuv")
        _ = os.RemoveAll(nuvdir)
        _ = os.Setenv("NUV_BIN", "")
@@ -61,15 +61,15 @@ func Example_locate_git() {
        // 2 <nil> /work/tests/olaris
        // Cloning tasks...
        // Nuvfiles downloaded successfully
-       // 3 <nil> /home/.nuv/3.0.0-testing/olaris
+       // 3 <nil> /home/.nuv/0.1.0-testing/olaris
        // Updating tasks...
        // Tasks are already up to date!
-       // 4 <nil> /home/.nuv/3.0.0-testing/olaris
+       // 4 <nil> /home/.nuv/0.1.0-testing/olaris
 }
 
 func Test_setNuvOlarisHash(t *testing.T) {
        _ = os.Chdir(workDir)
-       NuvBranch = "3.0.0-testing"
+       NuvBranch = "0.1.0-testing"
        nuvdir, _ := homedir.Expand("~/.nuv")
        _ = os.RemoveAll(nuvdir)
        _ = os.Setenv("NUV_BIN", workDir)
diff --git a/shell.nix b/shell.nix
index 50f8dc8..9e0ebbd 100644
--- a/shell.nix
+++ b/shell.nix
@@ -24,13 +24,6 @@ in
 pkgs.mkShellNoCC {
   packages = with pkgs; [
     go
-    gotools
-    gopls
-    go-outline
-    gopkgs
-    gocode-gomod
-    godef
-    golint
     delve
     silver-searcher
     jq
diff --git a/tests/auto_setup.bats b/tests/auto_setup.bats
index a585c96..b30e795 100644
--- a/tests/auto_setup.bats
+++ b/tests/auto_setup.bats
@@ -41,11 +41,11 @@ setup() {
 
 @test "correct branch setups" {
     run rm -rf ~/.nuv
-    export NUV_BRANCH=3.0.0-testing
+    export NUV_BRANCH=0.1.0-testing
     run nuv
     assert_success
     assert_output --partial "Welcome to nuv! Setting up..."
     run ls ~/.nuv
     assert_success
-    assert_output --partial "3.0.0-testing"
+    assert_output --partial "0.1.0-testing"
 }
diff --git a/tests/plugin.bats b/tests/plugin.bats
index 408b5ac..4796a83 100644
--- a/tests/plugin.bats
+++ b/tests/plugin.bats
@@ -19,7 +19,7 @@ setup() {
     load 'test_helper/bats-support/load'
     load 'test_helper/bats-assert/load'
     export NO_COLOR=1
-    export NUV_BRANCH="0.3.0"
+    export NUV_BRANCH="0.1.0"
 }
 
 @test "nuv prints 'Plugins:'" {
diff --git a/tests/prereq.bats b/tests/prereq.bats
index 11eade6..b6d9df8 100644
--- a/tests/prereq.bats
+++ b/tests/prereq.bats
@@ -23,9 +23,7 @@ setup() {
   
 }
 
-@test "ops prereq" {
-    rm -Rvf ~/.nuv/bin
-    TRACE=1 ops
-
-
-}
+#@test "ops prereq" {
+#    #rm -Rvf ~/.nuv/bin
+#    #TRACE=1 ops
+#}
diff --git a/tests/update.bats b/tests/update.bats
index 4053c32..5301f9a 100644
--- a/tests/update.bats
+++ b/tests/update.bats
@@ -29,7 +29,7 @@ setup() {
 }
 
 @test "nuv -update with old version warns" {
-    NUV_VERSION=0.2.0 run nuv -update
+    NUV_VERSION=0.0.0 run nuv -update
     assert_line --partial "Your nuv version (0.2.0) is older than the required 
version in nuvroot.json"
     assert_line "Attempting to update nuv..."
     assert_success
@@ -49,7 +49,7 @@ setup() {
 
 @test "nuv -update on branch" {
     run rm -rf ~/.nuv
-    export NUV_BRANCH=3.0.0-testing
+    export NUV_BRANCH=0.1.0-testing
     run nuv -update
     assert_line "Nuvfiles downloaded successfully"
     assert_success
diff --git a/version.txt b/version.txt
new file mode 100644
index 0000000..4611165
--- /dev/null
+++ b/version.txt
@@ -0,0 +1 @@
+0.1.0-testing.2407261504

Reply via email to