Skip to content

Commit

Permalink
Merge branch 'main' into dependabot/go_modules/github.com/onsi/gomega…
Browse files Browse the repository at this point in the history
…-1.31.1
  • Loading branch information
pendo324 authored Jan 30, 2024
2 parents 244ab28 + 7f0c86e commit 2518b11
Show file tree
Hide file tree
Showing 32 changed files with 188 additions and 86 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/benchmark.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ jobs:
echo "OS_VERSION=$(sw_vers -productVersion | cut -d '.' -f 1)" >> $GITHUB_ENV
echo "ARCH=$(uname -m)" >> $GITHUB_ENV
- name: Store benchmark result
uses: benchmark-action/github-action-benchmark@70405016b032d44f409e4b1b451c40215cbe2393 # v1.18.0
uses: benchmark-action/github-action-benchmark@315072f079db10e96004ffb95b9b7263bf3a547e # v1.19.2
with:
name: Finch Benchmark
tool: 'go'
Expand Down
20 changes: 14 additions & 6 deletions .github/workflows/ci-docs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -48,14 +48,22 @@ jobs:
e2e-tests:
strategy:
matrix:
os:
os:
[
[self-hosted, macos, amd64, 13, test],
[self-hosted, macos, amd64, 14, test],
[self-hosted, macos, arm64, 13, test],
[self-hosted, macos, arm64, 14, test]
[self-hosted, macos, amd64, 13, test],
[self-hosted, macos, amd64, 14, test],
[self-hosted, macos, arm64, 13, test],
[self-hosted, macos, arm64, 14, test],
]
runs-on: ${{ matrix.os }}
runs-on: ${{ matrix.os }}
steps:
- run: echo "Skipping CI for docs & contrib files"
windows-e2e-tests:
strategy:
matrix:
os: [[self-hosted, windows, amd64, test]]
test-command: ['test-e2e-vm-serial', 'test-e2e-container']
runs-on: ${{ matrix.os }}
steps:
- run: echo "Skipping CI for docs & contrib files"
mdlint:
Expand Down
20 changes: 11 additions & 9 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@ permissions:
id-token: write
contents: write

env:
DEBUG: ${{ secrets.ACTIONS_STEP_DEBUG }}

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
Expand Down Expand Up @@ -97,7 +100,7 @@ jobs:
- name: Run ShellCheck
uses: ludeeus/action-shellcheck@00cae500b08a931fb5698e11e79bfbd38e612a38 # 2.0.0
with:
version: v0.9.0
version: v0.9.0
continue-on-error: true
go-mod-tidy-check:
runs-on: ubuntu-latest
Expand Down Expand Up @@ -128,8 +131,9 @@ jobs:
[self-hosted, macos, amd64, 13, test],
[self-hosted, macos, amd64, 14, test],
[self-hosted, macos, arm64, 13, test],
[self-hosted, macos, arm64, 14, test]
[self-hosted, macos, arm64, 14, test],
]
test-command: ['test-e2e-vm-serial', 'test-e2e-container']
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
Expand Down Expand Up @@ -173,16 +177,14 @@ jobs:
- run: |
git status
git clean -f -d
REGISTRY=${{ steps.vars.outputs.has_creds == true && env.REGISTRY || '' }} make test-e2e
REGISTRY=${{ steps.vars.outputs.has_creds == true && env.REGISTRY || '' }} make ${{ matrix.test-command }}
shell: zsh {0}
windows-e2e-tests:
strategy:
fail-fast: false
matrix:
os:
[
[self-hosted, windows, amd64, test],
]
os: [[self-hosted, windows, amd64, test]]
test-command: ['test-e2e-vm-serial', 'test-e2e-container']
runs-on: ${{ matrix.os }}
timeout-minutes: 180
steps:
Expand Down Expand Up @@ -236,10 +238,10 @@ jobs:
# set networking config option to allow for VM/container -> host communication
echo "[experimental]`nnetworkingMode=mirrored`nhostAddressLoopback=true" > C:\Users\Administrator\.wslconfig
git status
git clean -f -d
make test-e2e
make ${{ matrix.test-command }}
- name: Remove Finch VM and Clean Up Previous Environment
if: ${{ always() }}
run: |
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/release-automation.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:
fetch-depth: 0
- name: 'Get the latest tag'
id: latest-tag
uses: "WyriHaximus/github-action-get-previous-tag@385a2a0b6abf6c2efeb95adfac83d96d6f968e0c" # v1.3.0
uses: "WyriHaximus/github-action-get-previous-tag@04e8485ecb6487243907e330d522ff60f02283ce" # v1.4.0

build-and-test-finch-pkg:
needs: get-latest-tag
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/release-homebrew.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:
fetch-depth: 0
- name: 'Get the latest tag'
id: latesttag
uses: "WyriHaximus/github-action-get-previous-tag@385a2a0b6abf6c2efeb95adfac83d96d6f968e0c" # v1.3.0
uses: "WyriHaximus/github-action-get-previous-tag@04e8485ecb6487243907e330d522ff60f02283ce" # v1.4.0
- name: 'Convert tag to version'
id: latestversion
run: |
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/upload-build-to-S3.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ jobs:
shell: zsh {0}

- name: Upload macos aarch64 build
uses: actions/upload-artifact@1eb3cb2b3e0f29609092a73eb033bb759a334595 # v4.1.0
uses: actions/upload-artifact@26f96dfa697d77e81fd5907df203aa23a56210a8 # v4.3.0
with:
name: finch.macos-aarch64
path: finch.*.aarch64.tar.gz
Expand Down Expand Up @@ -66,7 +66,7 @@ jobs:
shell: zsh {0}

- name: Upload macos x86_64 build
uses: actions/upload-artifact@1eb3cb2b3e0f29609092a73eb033bb759a334595 # v4.1.0
uses: actions/upload-artifact@26f96dfa697d77e81fd5907df203aa23a56210a8 # v4.3.0
with:
name: finch.macos-x86_64
path: finch.*.x86_64.tar.gz
Expand Down
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -328,10 +328,10 @@ test-unit:
# Container tests and VM tests can be run in any order, but they must be run sequentially.
# For more details, see the package-level comment of the e2e package.
.PHONY: test-e2e
test-e2e: test-e2e-vm-serial
test-e2e: test-e2e-vm-serial test-e2e-container

.PHONY: test-e2e-vm-serial
test-e2e-vm-serial: test-e2e-container
test-e2e-vm-serial:
go test -ldflags $(LDFLAGS) -timeout 2h ./e2e/vm -test.v -ginkgo.v -ginkgo.timeout=2h --installed="$(INSTALLED)"

.PHONY: test-e2e-container
Expand Down
2 changes: 2 additions & 0 deletions cmd/finch/virtual_machine_init.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,9 @@ func (iva *initVMAction) run() error {
iva.logger.Info("Initializing and starting Finch virtual machine...")
logs, err := limaCmd.CombinedOutput()
if err != nil {
iva.logger.SetFormatter(flog.TextWithoutTruncation)
iva.logger.Errorf("Finch virtual machine failed to start, debug logs:\n%s", logs)
iva.logger.SetFormatter(flog.Text)
// ignore error, this is to ensure that the disk mount doesn't linger after the VM fails to start
_ = iva.diskManager.DetachUserDataDisk()
return err
Expand Down
3 changes: 3 additions & 0 deletions cmd/finch/virtual_machine_init_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
"testing"

"github.com/runfinch/finch/pkg/dependency"
"github.com/runfinch/finch/pkg/flog"
"github.com/runfinch/finch/pkg/mocks"

"github.com/golang/mock/gomock"
Expand Down Expand Up @@ -292,7 +293,9 @@ func TestInitVMAction_run(t *testing.T) {
mockBaseYamlFilePath, "--tty=false").Return(command)

logger.EXPECT().Info("Initializing and starting Finch virtual machine...")
logger.EXPECT().SetFormatter(flog.TextWithoutTruncation)
logger.EXPECT().Errorf("Finch virtual machine failed to start, debug logs:\n%s", logs)
logger.EXPECT().SetFormatter(flog.Text)
dm.EXPECT().DetachUserDataDisk().Return(nil)
},
},
Expand Down
2 changes: 2 additions & 0 deletions cmd/finch/virtual_machine_start.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,9 @@ func (sva *startVMAction) run() error {
sva.logger.Info("Starting existing Finch virtual machine...")
logs, err := limaCmd.CombinedOutput()
if err != nil {
sva.logger.SetFormatter(flog.TextWithoutTruncation)
sva.logger.Errorf("Finch virtual machine failed to start, debug logs:\n%s", logs)
sva.logger.SetFormatter(flog.Text)
return err
}
sva.logger.Info("Finch virtual machine started successfully")
Expand Down
3 changes: 3 additions & 0 deletions cmd/finch/virtual_machine_start_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
"testing"

"github.com/runfinch/finch/pkg/dependency"
"github.com/runfinch/finch/pkg/flog"
"github.com/runfinch/finch/pkg/mocks"

"github.com/golang/mock/gomock"
Expand Down Expand Up @@ -305,7 +306,9 @@ func TestStartVMAction_run(t *testing.T) {
lcc.EXPECT().CreateWithoutStdio("start", limaInstanceName).Return(command)

logger.EXPECT().Info("Starting existing Finch virtual machine...")
logger.EXPECT().SetFormatter(flog.TextWithoutTruncation)
logger.EXPECT().Errorf("Finch virtual machine failed to start, debug logs:\n%s", logs)
logger.EXPECT().SetFormatter(flog.Text)
},
},
}
Expand Down
13 changes: 10 additions & 3 deletions e2e/container/container_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
"regexp"
"runtime"
"testing"
"time"

"github.com/onsi/ginkgo/v2"
"github.com/onsi/gomega"
Expand All @@ -28,14 +29,20 @@ func TestContainer(t *testing.T) {
}

ginkgo.SynchronizedBeforeSuite(func() []byte {
command.New(o, "vm", "init").WithTimeoutInSeconds(600).Run()
command.New(o, "vm", "stop", "-f").WithoutCheckingExitCode().WithTimeoutInSeconds(30).Run()
time.Sleep(1 * time.Second)
command.New(o, "vm", "remove", "-f").WithoutCheckingExitCode().WithTimeoutInSeconds(20).Run()
time.Sleep(1 * time.Second)
command.New(o, "vm", "init").WithoutCheckingExitCode().WithTimeoutInSeconds(160).Run()
tests.SetupLocalRegistry(o)
return nil
}, func(bytes []byte) {})

ginkgo.SynchronizedAfterSuite(func() {
command.New(o, "vm", "stop").WithTimeoutInSeconds(90).Run()
command.New(o, "vm", "remove").WithTimeoutInSeconds(60).Run()
command.New(o, "vm", "stop", "-f").WithoutCheckingExitCode().WithTimeoutInSeconds(30).Run()
time.Sleep(1 * time.Second)
command.New(o, "vm", "remove", "-f").WithoutCheckingExitCode().WithTimeoutInSeconds(20).Run()
time.Sleep(1 * time.Second)
}, func() {})

ginkgo.Describe(description, func() {
Expand Down
8 changes: 7 additions & 1 deletion e2e/e2e.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,13 @@ func CreateOption() (*option.Option, error) {
subject = InstalledTestSubject
}

o, err := option.New([]string{subject})
args := []string{subject}
debug := os.Getenv("DEBUG")
if len(debug) != 0 {
args = append(args, "--debug")
}

o, err := option.New(args)
if err != nil {
return nil, fmt.Errorf("failed to initialize a testing option: %w", err)
}
Expand Down
16 changes: 9 additions & 7 deletions e2e/vm/additional_disk_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ var testAdditionalDisk = func(o *option.Option, installed bool) {
ginkgo.It("Retains container user data after the VM is deleted", func() {
resetVM(o, installed)
resetDisks(o, installed)
command.New(o, virtualMachineRootCmd, "init").WithTimeoutInSeconds(600).Run()
command.New(o, virtualMachineRootCmd, "init").WithoutCheckingExitCode().WithTimeoutInSeconds(160).Run()
command.Run(o, "volume", "create", volumeName)
ginkgo.DeferCleanup(command.Run, o, "volume", "rm", volumeName)
command.Run(o, "network", "create", networkName)
Expand All @@ -38,12 +38,12 @@ var testAdditionalDisk = func(o *option.Option, installed bool) {
ginkgo.DeferCleanup(command.Run, o, "rm", "-f", containerName)

command.New(o, "stop", containerName).WithTimeoutInSeconds(30).Run()

time.Sleep(20 * time.Second)

command.New(o, virtualMachineRootCmd, "stop").WithTimeoutInSeconds(90).Run()
command.Run(o, virtualMachineRootCmd, "remove")
command.New(o, virtualMachineRootCmd, "init").WithTimeoutInSeconds(240).Run()
command.New(o, virtualMachineRootCmd, "stop").WithoutCheckingExitCode().WithTimeoutInSeconds(30).Run()
time.Sleep(1 * time.Second)
command.New(o, virtualMachineRootCmd, "remove").WithoutCheckingExitCode().WithTimeoutInSeconds(20).Run()
time.Sleep(1 * time.Second)
command.New(o, virtualMachineRootCmd, "init").WithoutCheckingExitCode().WithTimeoutInSeconds(160).Run()

imageOutput := command.StdoutAsLines(o, "images", "--format", "{{.Name}}")
gomega.Expect(imageOutput).Should(gomega.ContainElement(savedImage))
Expand All @@ -60,7 +60,9 @@ var testAdditionalDisk = func(o *option.Option, installed bool) {
gomega.Expect(networkOutput).Should(gomega.ContainElement(networkName))

command.Run(o, "start", containerName)
gomega.Expect(command.StdoutStr(o, "exec", containerName, "cat", "/tmp/test.txt")).
gomega.Eventually(command.StdoutStr(o, "exec", containerName, "cat", "/tmp/test.txt")).
WithTimeout(15 * time.Second).
WithPolling(1 * time.Second).
Should(gomega.Equal("foo"))
})
})
Expand Down
6 changes: 3 additions & 3 deletions e2e/vm/config_darwin_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import (
"github.com/lima-vm/lima/pkg/limayaml"
"github.com/onsi/ginkgo/v2"
"github.com/onsi/gomega"
"github.com/onsi/gomega/gexec"
"github.com/runfinch/common-tests/command"
"github.com/runfinch/common-tests/option"
"gopkg.in/yaml.v3"
Expand All @@ -33,9 +32,10 @@ var testConfig = func(o *option.Option, installed bool) {
}

limaConfigFilePath := resetVM(o, installed)
resetDisks(o, installed)
writeFile(finchConfigFilePath, []byte("memory: 4GiB\ncpus: 6\nvmType: vz\nrosetta: false"))
initCmdSession := command.New(o, virtualMachineRootCmd, "init").WithTimeoutInSeconds(600).Run()
gomega.Expect(initCmdSession).Should(gexec.Exit(0))
// vm init with VZ set sometimes takes 2 minutes just to convert the disk to raw
command.New(o, "vm", "init").WithoutCheckingExitCode().WithTimeoutInSeconds(240).Run()

gomega.Expect(limaConfigFilePath).Should(gomega.BeARegularFile())
cfgBuf, err := os.ReadFile(filepath.Clean(limaConfigFilePath))
Expand Down
3 changes: 3 additions & 0 deletions e2e/vm/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
"os"
"os/exec"
"path/filepath"
"time"

"github.com/lima-vm/lima/pkg/limayaml"
"github.com/onsi/ginkgo/v2"
Expand Down Expand Up @@ -42,6 +43,7 @@ func updateAndApplyConfig(o *option.Option, configBytes []byte) *gexec.Session {
writeFile(finchConfigFilePath, configBytes)

command.New(o, virtualMachineRootCmd, "stop").WithoutCheckingExitCode().WithTimeoutInSeconds(90).Run()
time.Sleep(1 * time.Second)
return command.New(o, virtualMachineRootCmd, "start").WithoutCheckingExitCode().WithTimeoutInSeconds(240).Run()
}

Expand Down Expand Up @@ -78,6 +80,7 @@ var _ = func(o *option.Option, installed bool) {
writeFile(limaConfigFilePath, origLimaCfg)

command.New(o, virtualMachineRootCmd, "stop").WithoutCheckingExitCode().WithTimeoutInSeconds(90).Run()
time.Sleep(1 * time.Second)
command.New(o, virtualMachineRootCmd, "start").WithTimeoutInSeconds(240).Run()
})
})
Expand Down
4 changes: 1 addition & 3 deletions e2e/vm/cred_helper_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import (

"github.com/onsi/ginkgo/v2"
"github.com/onsi/gomega"
"github.com/onsi/gomega/gexec"
"github.com/runfinch/common-tests/command"
"github.com/runfinch/common-tests/option"
)
Expand All @@ -33,8 +32,7 @@ var testCredHelper = func(o *option.Option, installed bool, registry string) {
resetDisks(o, installed)
writeFile(finchConfigFilePath, []byte(fmt.Sprintf("cpus: 6\nmemory: 4GiB\ncreds_helpers:\n "+
"- ecr-login\nvmType: %s\nrosetta: true", vmType)))
initCmdSession := command.New(o, virtualMachineRootCmd, "init").WithTimeoutInSeconds(600).Run()
gomega.Expect(initCmdSession).Should(gexec.Exit(0))
command.New(o, virtualMachineRootCmd, "init").WithoutCheckingExitCode().WithTimeoutInSeconds(160).Run()
command.New(o, "pull", registry).WithTimeoutInSeconds(600).Run()
gomega.Expect(command.Stdout(o, "images", "-q", registry)).NotTo(gomega.BeEmpty())
})
Expand Down
Loading

0 comments on commit 2518b11

Please sign in to comment.