Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add macOS testing #273

Merged
merged 7 commits into from
Dec 29, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 37 additions & 0 deletions .github/workflows/full-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
27 changes: 0 additions & 27 deletions .github/workflows/macos.yaml

This file was deleted.

32 changes: 32 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
18 changes: 14 additions & 4 deletions cli/build/build_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
psergee marked this conversation as resolved.
Show resolved Hide resolved
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"))
Expand Down Expand Up @@ -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) {
Expand Down
5 changes: 4 additions & 1 deletion cli/configure/configure_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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)
}

Expand Down
2 changes: 1 addition & 1 deletion cli/install/install.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"}}
Expand Down
28 changes: 24 additions & 4 deletions cli/install_ee/install_ee_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"testing"

"github.com/stretchr/testify/assert"
"github.com/tarantool/tt/cli/util"
"github.com/tarantool/tt/cli/version"
)

Expand All @@ -30,9 +31,27 @@ func TestGetVersions(t *testing.T) {
err: fmt.Errorf("no packages for this OS"),
}

inputData1 := []byte(`<a href="/enterprise/tarantool-enterprise-bundle-` +
`1.10.10-52-g0df29b137-r419.tar.gz">tarantool-enterprise-bundle-1.10.10-` +
`52-g0df29b137-r419.tar.gz</a> 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(`<a href="/enterprise/tarantool-enterprise-bundle-` +
`1.10.10-52-g0df29b137-r419` + osName + arch +
`.tar.gz">tarantool-enterprise-bundle-1.10.10-` +
`52-g0df29b137-r419` + osName + arch + `.tar.gz</a>` +
` 2021-08-18 ` +
`15:56:04 260136444`)

testCases[getVersionsInputValue{data: &inputData1}] =
Expand All @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion cli/pack/archive.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
2 changes: 1 addition & 1 deletion cli/pack/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion cli/pack/deb.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
8 changes: 7 additions & 1 deletion cli/pack/docker.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
2 changes: 1 addition & 1 deletion cli/pack/rpm.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
10 changes: 8 additions & 2 deletions cli/util/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
9 changes: 8 additions & 1 deletion test/integration/install/test_install.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import os
import platform
import re
import subprocess
import tempfile
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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)
Expand Down
1 change: 1 addition & 0 deletions test/integration/pack/test_pack.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
6 changes: 6 additions & 0 deletions test/integration/rocks/test_rocks.py
Original file line number Diff line number Diff line change
@@ -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

# ##### #
Expand Down Expand Up @@ -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:
Expand Down