Skip to content

Commit

Permalink
Merge branch 'main' into dependabot/go_modules/github.com/google/go-l…
Browse files Browse the repository at this point in the history
…icenses-1.6.0
  • Loading branch information
pendo324 authored Jan 26, 2023
2 parents 2904592 + b08f588 commit e9bf65f
Show file tree
Hide file tree
Showing 12 changed files with 81 additions and 26 deletions.
1 change: 1 addition & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ jobs:
# We need to get all the git tags to make version injection work. See VERSION in Makefile for more detail.
fetch-depth: 0
persist-credentials: false
submodules: true
- name: Clean up previous files
run: |
sudo rm -rf /opt/finch
Expand Down
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,5 @@ _vde_output/
**/*.img
tmp/
.vscode/
finch-core/
tools_bin/
test-coverage.*
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[submodule "deps/finch-core"]
path = deps/finch-core
url = https://github.com/runfinch/finch-core.git
24 changes: 24 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,29 @@
# Changelog

## [0.3.0](https://github.com/runfinch/finch/compare/v0.2.0...v0.3.0) (2023-01-18)


### ⚠ BREAKING CHANGES

* changes persistent disk path to prevent collisions

### Features

* add `finch vm status` command ([#83](https://github.com/runfinch/finch/issues/83)) ([37d74d0](https://github.com/runfinch/finch/commit/37d74d0b82c41f439715d0a07e723fd5e5a9a617))


### Bug Fixes

* changes persistent disk path to prevent collisions ([3eb66a2](https://github.com/runfinch/finch/commit/3eb66a21bcbf56dd8e4465bfc3ed840903b069d9))


### Build System or External Dependencies

* **deps:** Bump github.com/onsi/gomega from 1.24.2 to 1.25.0 ([#165](https://github.com/runfinch/finch/issues/165)) ([e4b9e96](https://github.com/runfinch/finch/commit/e4b9e96713feac19bc73dfc2dd788a80c28a064f))
* **deps:** Bump github.com/runfinch/common-tests from 0.2.0 to 0.3.0 ([#151](https://github.com/runfinch/finch/issues/151)) ([79df04e](https://github.com/runfinch/finch/commit/79df04ef62df615c19070e607a060769ab09e7a0))
* **deps:** Bump github.com/runfinch/common-tests version from v0.3.0 to v0.3.1 ([#169](https://github.com/runfinch/finch/issues/169)) ([16157fe](https://github.com/runfinch/finch/commit/16157fe3adfc8be19899700ae3f1cd5c1a848304))
* **deps:** Bump golang.org/x/crypto from 0.4.0 to 0.5.0 ([#144](https://github.com/runfinch/finch/issues/144)) ([603419a](https://github.com/runfinch/finch/commit/603419a703154e8a8eac404da2b9aeb76c5b3333))

## [0.2.0](https://github.com/runfinch/finch/compare/v0.1.1...v0.2.0) (2023-01-11)


Expand Down
21 changes: 18 additions & 3 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -127,9 +127,15 @@ export PATH="/opt/homebrew/opt/libtool/libexec/gnubin:$PATH"

### Build

Clone the repo and make sure to include the submodules by adding `--recurse-submodules`. For example:

```shell
git clone --recurse-submodules https://github.com/runfinch/finch.git
```

After cloning the repo, run `make` to build the binary.

The binary in _output can be directly used. E.g. initializing the vm and display the version
The binary in `_output` can be directly used. E.g. initializing the vm and display the version

```sh
./_output/bin/finch vm init
Expand Down Expand Up @@ -228,15 +234,24 @@ Keeping a good unit test coverage will be part of pull request review. You can r

See `test-e2e` section in [`Makefile`](./Makefile) for more reference.

In this repository, there are two suites of E2E tests: `container` tests and `vm` tests.

If the e2e test scenarios you are going to contribute

- are in generic container development workflow
- can be shared by finch-core by replacing test subject from "finch" to "limactl ..."
- E.g.: pull, push, build, run, etc.

implement them in common-tests repo and then import them in [`./e2e/e2e_test.go`](./e2e/e2e_test.go) in finch CLI and finch-core. The detailed flow can be found [here](https://github.com/runfinch/common-tests#sync-between-tests-and-code).
they belong with the `container` tests. Implement them in common-tests repo and then import them in [`./e2e/container/container_test.go`](./e2e/container/container_test.go) in finch CLI and `./e2e/e2e_test.go` in finch-core. The detailed flow can be found [here](https://github.com/runfinch/common-tests#sync-between-tests-and-code).

Otherwise, it means that the scenarios are specific to finch CLI (e.g., version, VM lifecycle, etc.), and you should implement them under `./e2e/` (e.g., `./e2e/version.go`) and import them in `./e2e/e2e_test.go`.
Otherwise, it means that the scenarios are specific to finch CLI (e.g., version, VM lifecycle, etc.), and belong with the `vm` tests. You should implement them under `./e2e/vm/` (e.g., `./e2e/vm/version_test.go`) and import them in `./e2e/vm/vm_test.go`.

If you want to run just one of the two suites, append the suite name to the end of the Makefile target:

```sh
make test-e2e-container
make test-e2e-vm
```

To save time while developing e2e tests, use the [`Focus`](https://onsi.github.io/ginkgo/#focused-specs) decorator while running tests, but be sure to remove it before PR-ing your changes.

Expand Down
32 changes: 16 additions & 16 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,6 @@ VDE_INSTALL ?= /opt/finch
UNAME := $(shell uname -m)
ARCH ?= $(UNAME)
SUPPORTED_ARCH = false
CORE_URL ?= https://artifact.runfinch.com/finch-core-0.1.1.tar.gz
CORE_FILENAME := finch-core
CORE_OUTDIR := $(CURDIR)/$(CORE_FILENAME)/_output
CORE_VDE_PREFIX ?= $(OUTDIR)/dependencies/vde/opt/finch
LICENSEDIR := $(OUTDIR)/license-files
VERSION := $(shell git describe --match 'v[0-9]*' --dirty='.modified' --always --tags)
Expand All @@ -37,13 +34,13 @@ ifneq (,$(findstring arm64,$(ARCH)))
SUPPORTED_ARCH = true
LIMA_ARCH = aarch64
# From https://dl.fedoraproject.org/pub/fedora/linux/releases/37/Cloud/aarch64/images/
FINCH_OS_BASENAME ?= Fedora-Cloud-Base-37-1.7.aarch64.qcow2
FINCH_OS_BASENAME ?= Fedora-Cloud-Base-37-1.7.aarch64-20230124190350.qcow2
LIMA_URL ?= https://deps.runfinch.com/aarch64/lima-and-qemu.macos-aarch64.1673290784.tar.gz
else ifneq (,$(findstring x86_64,$(ARCH)))
SUPPORTED_ARCH = true
LIMA_ARCH = x86_64
# From https://dl.fedoraproject.org/pub/fedora/linux/releases/37/Cloud/x86_64/images/
FINCH_OS_BASENAME ?= Fedora-Cloud-Base-37-1.7.x86_64.qcow2
FINCH_OS_BASENAME ?= Fedora-Cloud-Base-37-1.7.x86_64-20230124181550.qcow2
LIMA_URL ?= https://deps.runfinch.com/x86-64/lima-and-qemu.macos-x86_64.1673290501.tar.gz
endif

Expand All @@ -61,20 +58,14 @@ all: arch-test finch finch-core finch.yaml networks.yaml config.yaml lima-and-qe

.PHONY: finch-core
finch-core:
mkdir -p $(CURDIR)/$(CORE_FILENAME)
curl -L $(CORE_URL) > "$(CURDIR)/$(CORE_FILENAME).tar.gz"
tar -zvxf $(CURDIR)/finch-core.tar.gz -C $(CORE_FILENAME) --strip-component=1
rm "$(CORE_FILENAME).tar.gz"

cd $(CURDIR)/$(CORE_FILENAME) && \
cd deps/finch-core && \
FINCH_OS_x86_URL="$(FINCH_OS_x86_URL)" \
FINCH_OS_AARCH64_URL="$(FINCH_OS_AARCH64_URL)" \
VDE_TEMP_PREFIX=$(CORE_VDE_PREFIX) \
$(MAKE)

mkdir -p _output
cd $(CORE_FILENAME)/_output && tar c * | tar Cvx $(OUTDIR)
rm -r $(CURDIR)/$(CORE_FILENAME)
cd deps/finch-core/_output && tar c * | tar Cvx $(OUTDIR)
rm -rf $(OUTDIR)/lima-template

.PHONY: lima-and-qemu
Expand Down Expand Up @@ -244,11 +235,21 @@ test-unit:

# test-e2e assumes the VM instance doesn't exist, please make sure to remove it before running.
#
# Container tests have to be run before VM tests according to the current code setup.
# 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: test-e2e-vm-serial

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

.PHONY: test-e2e-container
test-e2e-container:
go test -ldflags $(LDFLAGS) -timeout 30m ./e2e/container -test.v -ginkgo.v --installed="$(INSTALLED)"

.PHONY: test-e2e-vm
test-e2e-vm:
go test -ldflags $(LDFLAGS) -timeout 30m ./e2e/vm -test.v -ginkgo.v --installed="$(INSTALLED)"

.PHONY: gen-code
Expand Down Expand Up @@ -282,7 +283,6 @@ mdlint-ctr:
.PHONY: clean
clean:
-@rm -rf $(OUTDIR) 2>/dev/null || true
-@rm -rf $(CORE_FILENAME) 2>/dev/null || true
-@rm ./*.tar.gz 2>/dev/null || true
-@rm ./*.qcow2 2>/dev/null || true
-@rm ./test-coverage.* 2>/dev/null || true
1 change: 1 addition & 0 deletions deps/finch-core
Submodule finch-core added at 01e616
6 changes: 5 additions & 1 deletion e2e/container/container_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,17 @@ func TestContainer(t *testing.T) {
t.Fatal(err)
}

// The VM should be cleaned up in SynchronizedAfterSuite of e2e/vm.
ginkgo.SynchronizedBeforeSuite(func() []byte {
command.New(o, "vm", "init").WithTimeoutInSeconds(600).Run()
tests.SetupLocalRegistry(o)
return nil
}, func(bytes []byte) {})

ginkgo.SynchronizedAfterSuite(func() {
command.New(o, "vm", "stop").WithTimeoutInSeconds(60).Run()
command.New(o, "vm", "remove").WithTimeoutInSeconds(60).Run()
}, func() {})

ginkgo.Describe(description, func() {
tests.Pull(o)
tests.Rm(o)
Expand Down
6 changes: 5 additions & 1 deletion e2e/vm/vm_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,11 @@ func TestVM(t *testing.T) {
t.Fatal(err)
}

// The VM should be spined up in SynchronizedBeforeSuite of e2e/container.
ginkgo.SynchronizedBeforeSuite(func() []byte {
command.New(o, "vm", "init").WithTimeoutInSeconds(600).Run()
return nil
}, func(bytes []byte) {})

ginkgo.SynchronizedAfterSuite(func() {
command.New(o, "vm", "stop").WithTimeoutInSeconds(60).Run()
command.New(o, "vm", "remove").WithTimeoutInSeconds(60).Run()
Expand Down
6 changes: 5 additions & 1 deletion finch.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,11 @@ provision:
script: |
#!/bin/bash
sudo chown $USER /mnt/lima-finch
sudo mount --bind /mnt/lima-finch ~/.local/share/containerd
mkdir -p /mnt/lima-finch/containerd
mkdir -p /mnt/lima-finch/nerdctl
mkdir -p ~/.local/share/nerdctl
sudo mount --bind /mnt/lima-finch/containerd ~/.local/share/containerd
sudo mount --bind /mnt/lima-finch/nerdctl ~/.local/share/nerdctl
systemctl --user restart containerd.service
# Probe scripts to check readiness.
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ require (
github.com/onsi/gomega v1.25.0
github.com/pelletier/go-toml v1.9.5
github.com/pkg/sftp v1.13.5
github.com/runfinch/common-tests v0.3.0
github.com/runfinch/common-tests v0.3.1
github.com/sirupsen/logrus v1.9.0
github.com/spf13/afero v1.9.3
github.com/spf13/cobra v1.6.1
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -502,8 +502,8 @@ github.com/prometheus/tsdb v0.7.1/go.mod h1:qhTCs0VvXwvX/y3TZrWD7rabWM+ijKTux40T
github.com/rogpeppe/fastuuid v0.0.0-20150106093220-6724a57986af/go.mod h1:XWv6SoW27p1b0cqNHllgS5HIMJraePCO15w5zCzIWYg=
github.com/rogpeppe/fastuuid v1.2.0/go.mod h1:jVj6XXZzXRy/MSR5jhDC/2q6DgLz+nrA6LYCDYWNEvQ=
github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4=
github.com/runfinch/common-tests v0.3.0 h1:/KYy015q9taKZa3asVJ1pQ6Jpel+PP16APmclp6P6L4=
github.com/runfinch/common-tests v0.3.0/go.mod h1:UpmjZJ5nid549Xct3uQfFwkygnA1/XUJydizbZdeKHM=
github.com/runfinch/common-tests v0.3.1 h1:TG2DQZ6HhaCmy/2wCm36kRWrm/p5DSAjH//gcKdfrcA=
github.com/runfinch/common-tests v0.3.1/go.mod h1:UpmjZJ5nid549Xct3uQfFwkygnA1/XUJydizbZdeKHM=
github.com/russross/blackfriday/v2 v2.0.1/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
github.com/sergi/go-diff v1.0.0/go.mod h1:0CfEIISq7TuYL3j771MWULgwwjU+GofnZX9QAmXWZgo=
Expand Down

0 comments on commit e9bf65f

Please sign in to comment.