diff --git a/.github/workflows/full-ci.yml b/.github/workflows/full-ci.yml index 9eee2e294..70d77ea4d 100644 --- a/.github/workflows/full-ci.yml +++ b/.github/workflows/full-ci.yml @@ -107,3 +107,40 @@ jobs: - name: Integration tests run: mage integrationfull + + full-ci-macOS: + if: | + (github.event_name == 'push') || + (github.event_name == 'pull_request' && + github.event.action == 'labeled' && + github.event.label.name == 'full-ci') || + (github.event_name == 'pull_request' && + github.event.action == 'synchronize' && + contains(github.event.pull_request.labels.*.name, 'full-ci')) + runs-on: macos-12 + steps: + - uses: actions/checkout@master + with: + fetch-depth: 0 + submodules: recursive + + - name: Install dependencies + run: | + brew install --overwrite go mage + brew install python3 + pip3 install pytest tarantool requests psutil pyyaml netifaces + + - name: Setup Docker + uses: docker-practice/actions-setup-docker@master + + - name: Build tt + run: mage build + + - name: Install tarantool + run: brew install tarantool + + - name: Run unit tests + run: mage unitfull + + - name: Run integration tests + run: mage integrationfull diff --git a/.github/workflows/macos.yaml b/.github/workflows/macos.yaml deleted file mode 100644 index 8655ecfa9..000000000 --- a/.github/workflows/macos.yaml +++ /dev/null @@ -1,27 +0,0 @@ -name: macos - -on: - pull_request: - types: [ opened, reopened, synchronize ] - workflow_dispatch: - branches: [ master ] - push: - branches: [ master ] - -jobs: - macosx_build: - runs-on: macos-12 - - steps: - - name: Get sources - uses: actions/checkout@v3 - with: - fetch-depth: 1 - submodules: recursive - - - name: Install dependencies - run: | - brew install --overwrite go mage - - - name: Build - run: mage build diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 2c34ac671..9a8ca612e 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -102,3 +102,35 @@ jobs: - name: Integration tests run: mage integration + + tests-mac-os-ce: + if: | + (github.event_name == 'push') || + (github.event_name == 'pull_request' && + github.event.pull_request.head.repo.owner.login != 'tarantool' && + !contains(github.event.pull_request.labels.*.name, 'full-ci')) + runs-on: macos-12 + + steps: + - uses: actions/checkout@master + with: + fetch-depth: 0 + submodules: recursive + + - name: Install dependencies + run: | + brew install --overwrite go mage + brew install python3 + pip3 install pytest tarantool requests psutil pyyaml netifaces + + - name: Build tt + run: mage build + + - name: Install tarantool + run: brew install tarantool + + - name: Run unit tests + run: mage unit + + - name: Run integration tests + run: mage integration diff --git a/cli/build/build_test.go b/cli/build/build_test.go index 50918a8e3..c42abcd59 100644 --- a/cli/build/build_test.go +++ b/cli/build/build_test.go @@ -24,17 +24,23 @@ func TestFillCtx(t *testing.T) { require.NoError(t, os.Chdir(workDir)) defer os.Chdir(wd) var buildCtx BuildCtx + + workDir, _ = os.Getwd() + + appDir := filepath.Join(workDir, "app1") + appDir2 := filepath.Join(workDir, "app2") + require.NoError(t, FillCtx(&buildCtx, []string{"app1"})) - assert.Equal(t, buildCtx.BuildDir, filepath.Join(workDir, "app1")) + assert.Equal(t, buildCtx.BuildDir, appDir) require.NoError(t, FillCtx(&buildCtx, []string{"./app1"})) - assert.Equal(t, buildCtx.BuildDir, filepath.Join(workDir, "app1")) + assert.Equal(t, buildCtx.BuildDir, appDir) require.NoError(t, FillCtx(&buildCtx, []string{})) assert.Equal(t, buildCtx.BuildDir, workDir) require.EqualError(t, FillCtx(&buildCtx, []string{"app1", "app2"}), "too many args") require.EqualError(t, FillCtx(&buildCtx, []string{"app2"}), - fmt.Sprintf("stat %s: no such file or directory", filepath.Join(workDir, "app2"))) + fmt.Sprintf("stat %s: no such file or directory", appDir2)) require.NoError(t, FillCtx(&buildCtx, []string{filepath.Join(workDir, "app1")})) assert.Equal(t, buildCtx.BuildDir, filepath.Join(workDir, "app1")) @@ -62,8 +68,12 @@ func TestFillCtxAppPathIsFile(t *testing.T) { require.NoError(t, os.Chdir(workDir)) defer os.Chdir(wd) var buildCtx BuildCtx + workDir, _ = os.Getwd() + + appDir := filepath.Join(workDir, "app1") + require.EqualError(t, FillCtx(&buildCtx, []string{"app1"}), - fmt.Sprintf("%s is not a directory", filepath.Join(workDir, "app1"))) + fmt.Sprintf("%s is not a directory", appDir)) } func TestFillCtxMultipleArgs(t *testing.T) { diff --git a/cli/configure/configure_test.go b/cli/configure/configure_test.go index b0cf7a7db..0259e041b 100644 --- a/cli/configure/configure_test.go +++ b/cli/configure/configure_test.go @@ -262,6 +262,8 @@ func TestGetConfigPath(t *testing.T) { require.NoError(t, os.Chdir(filepath.Join(tempDir, "a", "b"))) defer os.Chdir(wd) } + workdir, _ := os.Getwd() + workdir = strings.TrimSuffix(workdir, "/a/b") configName, err := getConfigPath(ConfigName) assert.Equal(t, "", configName) @@ -270,7 +272,8 @@ func TestGetConfigPath(t *testing.T) { require.NoError(t, os.Remove(filepath.Join(tempDir, "a", "tarantool.yaml"))) configName, err = getConfigPath(ConfigName) - assert.Equal(t, filepath.Join(tempDir, "a", "tarantool.yml"), configName) + + assert.Equal(t, filepath.Join(workdir, "a", "tarantool.yml"), configName) assert.NoError(t, err) } diff --git a/cli/install/install.go b/cli/install/install.go index 2fae86db9..616e4afe1 100644 --- a/cli/install/install.go +++ b/cli/install/install.go @@ -257,7 +257,7 @@ func programDependenciesInstalled(program string) bool { } else if program == "tarantool" { if osName == "darwin" { programs = []Package{{"cmake", "cmake"}, {"git", "git"}, - {"make", "make"}, {"clang", "clang"}} + {"make", "make"}, {"clang", "clang"}, {"openssl", "openssl"}} } else if strings.Contains(osName, "Ubuntu") || strings.Contains(osName, "Debian") { programs = []Package{{"cmake", "cmake"}, {"git", "git"}, {"make", "make"}, {"gcc", " build-essential"}} diff --git a/cli/install_ee/install_ee_test.go b/cli/install_ee/install_ee_test.go index 855d8a8cf..dee97ccc1 100644 --- a/cli/install_ee/install_ee_test.go +++ b/cli/install_ee/install_ee_test.go @@ -5,6 +5,7 @@ import ( "testing" "github.com/stretchr/testify/assert" + "github.com/tarantool/tt/cli/util" "github.com/tarantool/tt/cli/version" ) @@ -30,9 +31,27 @@ func TestGetVersions(t *testing.T) { err: fmt.Errorf("no packages for this OS"), } - inputData1 := []byte(`tarantool-enterprise-bundle-1.10.10-` + - `52-g0df29b137-r419.tar.gz 2021-08-18 ` + + arch, err := util.GetArch() + assert.NoError(err) + + osType, err := util.GetOs() + assert.NoError(err) + inputData1 := []byte(``) + osName := "" + switch osType { + case util.OsLinux: + if arch == "x86_64" { + arch = "" + } + case util.OsMacos: + osName = "-macosx-" + } + + inputData1 = []byte(`tarantool-enterprise-bundle-1.10.10-` + + `52-g0df29b137-r419` + osName + arch + `.tar.gz` + + ` 2021-08-18 ` + `15:56:04 260136444`) testCases[getVersionsInputValue{data: &inputData1}] = @@ -47,7 +66,8 @@ func TestGetVersions(t *testing.T) { Release: version.Release{Type: version.TypeRelease}, Hash: "g0df29b137", Str: "1.10.10-52-g0df29b137-r419", - Tarball: "tarantool-enterprise-bundle-1.10.10-52-g0df29b137-r419.tar.gz", + Tarball: "tarantool-enterprise-bundle-1.10.10-52-g0df29b137-r419" + + osName + arch + ".tar.gz", }, }, err: nil, diff --git a/cli/pack/archive.go b/cli/pack/archive.go index 36f8acd43..5a372e2a1 100644 --- a/cli/pack/archive.go +++ b/cli/pack/archive.go @@ -19,7 +19,7 @@ type archivePacker struct { // Run of ArchivePacker packs the bundle into tarball. func (packer *archivePacker) Run(cmdCtx *cmdcontext.CmdCtx, packCtx *PackCtx, opts *config.CliOpts) error { - bundlePath, err := prepareBundle(cmdCtx, packCtx, opts, true) + bundlePath, err := prepareBundle(cmdCtx, *packCtx, opts, true) if err != nil { return err } diff --git a/cli/pack/common.go b/cli/pack/common.go index cb98609dd..5946b58b9 100644 --- a/cli/pack/common.go +++ b/cli/pack/common.go @@ -65,7 +65,7 @@ var defaultPaths = []string{ // prepareBundle prepares a temporary directory for packing. // Returns a path to the prepared directory or error if it failed. -func prepareBundle(cmdCtx *cmdcontext.CmdCtx, packCtx *PackCtx, +func prepareBundle(cmdCtx *cmdcontext.CmdCtx, packCtx PackCtx, cliOpts *config.CliOpts, buildRocks bool) (string, error) { var err error diff --git a/cli/pack/deb.go b/cli/pack/deb.go index 0ba11d9b7..180e17c5f 100644 --- a/cli/pack/deb.go +++ b/cli/pack/deb.go @@ -73,7 +73,7 @@ func (packer *debPacker) Run(cmdCtx *cmdcontext.CmdCtx, packCtx *PackCtx, log.Debugf("A root for package is located in: %s", packageDir) // Prepare a bundle. - bundlePath, err := prepareBundle(cmdCtx, packCtx, opts, true) + bundlePath, err := prepareBundle(cmdCtx, *packCtx, opts, true) if err != nil { return err } diff --git a/cli/pack/docker.go b/cli/pack/docker.go index b66276835..71091d23b 100644 --- a/cli/pack/docker.go +++ b/cli/pack/docker.go @@ -62,9 +62,15 @@ func PackInDocker(cmdCtx *cmdcontext.CmdCtx, packCtx *PackCtx, fmt.Sprintf("cp $(which tarantool) %s && cp $(which tt) %s && %s", relEnvBinPath, relEnvBinPath, strings.Join(ttPackCommandLine, " "))}) + // Get a pack context for preparing a bundle without binaries. + // All binary files will be taken from the docker image. + dockerPackCtx := *packCtx + dockerPackCtx.WithoutBinaries = true + dockerPackCtx.WithBinaries = false + // Create a temporary directory with environment files for mapping it into container. // That is needed to avoid files mutation and binaries replacing in source directory. - tempEnvDir, err := prepareBundle(cmdCtx, packCtx, &opts, false) + tempEnvDir, err := prepareBundle(cmdCtx, dockerPackCtx, &opts, false) if err != nil { return err } diff --git a/cli/pack/rpm.go b/cli/pack/rpm.go index 3f811da8b..2f2767e51 100644 --- a/cli/pack/rpm.go +++ b/cli/pack/rpm.go @@ -42,7 +42,7 @@ func (packer *rpmPacker) Run(cmdCtx *cmdcontext.CmdCtx, packCtx *PackCtx, log.Debugf("A root for package is located in: %s", packageDir) // Prepare a bundle. - bundlePath, err := prepareBundle(cmdCtx, packCtx, opts, true) + bundlePath, err := prepareBundle(cmdCtx, *packCtx, opts, true) if err != nil { return err } diff --git a/cli/util/util.go b/cli/util/util.go index 7f89c9781..5a7eb27bd 100644 --- a/cli/util/util.go +++ b/cli/util/util.go @@ -680,8 +680,14 @@ func ExecuteCommandStdin(program string, isVerbose bool, logFile *os.File, workD cmd.Stdout = os.Stdout cmd.Stderr = os.Stderr } else { - cmd.Stdout = logFile - cmd.Stderr = logFile + if logFile != nil { + cmd.Stdout = logFile + cmd.Stderr = logFile + } else { + cmd.Stdout = ioutil.Discard + cmd.Stderr = ioutil.Discard + } + } if workDir == "" { workDir, _ = os.Getwd() diff --git a/test/integration/install/test_install.py b/test/integration/install/test_install.py index be5666d58..2165ebd86 100644 --- a/test/integration/install/test_install.py +++ b/test/integration/install/test_install.py @@ -1,4 +1,5 @@ import os +import platform import re import subprocess import tempfile @@ -51,7 +52,7 @@ def test_install_tarantool(tt_cmd, tmpdir): tmpdir_without_config = tempfile.mkdtemp() # Install latest tarantool. - install_cmd = [tt_cmd, "--cfg", config_path, "install", "tarantool", "-f"] + install_cmd = [tt_cmd, "--cfg", config_path, "install", "tarantool=2.10.4", "-f"] instance_process = subprocess.Popen( install_cmd, cwd=tmpdir_without_config, @@ -79,6 +80,9 @@ def test_install_tarantool(tt_cmd, tmpdir): @pytest.mark.slow def test_install_tarantool_in_docker(tt_cmd, tmpdir): + if platform.system() == "Darwin": + pytest.skip("/set platform is unsupported") + config_path = os.path.join(tmpdir, "tarantool.yaml") # Create test config. with open(config_path, "w") as f: @@ -119,6 +123,9 @@ def test_install_tarantool_in_docker(tt_cmd, tmpdir): def test_install_tt_in_docker(tt_cmd, tmpdir): + if platform.system() == "Darwin": + pytest.skip("/set platform is unsupported") + config_path = os.path.join(tmpdir, "tarantool.yaml") with open(config_path, "w") as f: yaml.dump({"tt": {"app": {"bin_dir": "", "inc_dir": "./my_inc"}}}, f) diff --git a/test/integration/pack/test_pack.py b/test/integration/pack/test_pack.py index c9d32a688..3a1c29379 100644 --- a/test/integration/pack/test_pack.py +++ b/test/integration/pack/test_pack.py @@ -674,6 +674,7 @@ def test_pack_rpm_use_docker(tt_cmd, tmpdir): assert rc == 0 +@pytest.mark.slow def test_pack_deb_use_docker(tt_cmd, tmpdir): if shutil.which('docker') is None: pytest.skip("docker is not installed in this system") diff --git a/test/integration/rocks/test_rocks.py b/test/integration/rocks/test_rocks.py index 44fb93d80..9db82d3ab 100644 --- a/test/integration/rocks/test_rocks.py +++ b/test/integration/rocks/test_rocks.py @@ -1,7 +1,10 @@ import os +import platform import re import shutil +import pytest + from utils import create_tt_config, run_command_and_get_output # ##### # @@ -80,6 +83,9 @@ def test_rocks_install_remote(tt_cmd, tmpdir): def test_rocks_install_local(tt_cmd, tmpdir): + if platform.system() == "Darwin": + pytest.skip("/set platform is unsupported") + with open(os.path.join(tmpdir, "tarantool.yaml"), "w") as tnt_env_file: tnt_env_file.write('''tt: repo: