Skip to content

Commit

Permalink
feat: Shape feat for test (#32)
Browse files Browse the repository at this point in the history
* Add workflow to sync finch
submodules

Signed-off-by: Vishwas Siravara <siravara@amazon.com>

* fix: print debug logs when lima disk command fails (runfinch#270)

## Before

```sh
➜  finch git:(main) ✗ ./_output/bin/finch vm init
FATA[0000] exit status 1
```

## After

```sh
➜  finch git:(disk-combined-output) ✗ ./_output/bin/finch vm init
FATA[0000] failed to create disk, debug logs:
time="2023-03-07T13:35:02-08:00" level=fatal msg="disk \"finch\" already exists (\"/Users/davidhyc/dev/runfinch/finch/_output/lima/data/_disks/finch\")"
```

## Notes

The concept behind this PR is from:
/~https://github.com/runfinch/finch/blob/674b3794fe5f5902c264d5327024fb92e147e60f/cmd/finch/virtual_machine_init.go#L97-L101

## License Acceptance

By submitting this pull request, I confirm that my contribution is made
under the terms of the Apache 2.0 license.

Signed-off-by: Hsing-Yu (David) Chen <davidhsingyuchen@gmail.com>

* fix: print debug logs after newline (runfinch#273)

## Why

It increases readability because debug logs can be multi-line.

## Before

```sh
➜  finch git:(main) ./_output/bin/finch vm init
INFO[0000] Initializing and starting Finch virtual machine...
ERRO[0000] Finch virtual machine failed to start, debug logs: time="2023-03-07T14:50:40-08:00" level=info msg="Terminal is not available, proceeding without opening an editor"
time="2023-03-07T14:50:40-08:00" level=fatal msg="field `images[0].digest` is invalid: sha256:156de3fd8a0c7e80dea9054aa9a0873e111efc16e5d8519929f913a1ca5ae9: invalid checksum digest length"
FATA[0000] exit status 1
```

## After

```sh
➜  finch git:(debug-logs-newline) ✗ ./_output/bin/finch vm init
INFO[0000] Initializing and starting Finch virtual machine...
ERRO[0000] Finch virtual machine failed to start, debug logs:
time="2023-03-07T14:49:45-08:00" level=info msg="Terminal is not available, proceeding without opening an editor"
time="2023-03-07T14:49:45-08:00" level=fatal msg="field `images[0].digest` is invalid: sha256:156de3fd8a0c7e80dea9054aa9a0873e111efc16e5d8519929f913a1ca5ae9: invalid checksum digest length"
FATA[0000] exit status 1
```

## License Acceptance

By submitting this pull request, I confirm that my contribution is made
under the terms of the Apache 2.0 license.

Signed-off-by: Hsing-Yu (David) Chen <davidhsingyuchen@gmail.com>

* ci: use the Go version in go.mod instead of a hard-coded one (runfinch#276)

## Summary

PR is a follow-up of runfinch#257.

## License Acceptance

By submitting this pull request, I confirm that my contribution is made
under the terms of the Apache 2.0 license.

Signed-off-by: Hsing-Yu (David) Chen <davidhsingyuchen@gmail.com>

* docs: make 'git pull' automatically update submodules (runfinch#274)

## Why

Before this PR, if the pinned commit of any submodule is updated in the
remote tracking branch, folks need to explicitly add `--recurse` when
running `git pull` to also update the submodule to the updated commit.
Regarding our usage of submodules, since we only consume upstream
updates (i.e., not modifying them), and there're not many submodules,
which means that recursively updating them won't take a lot of time,
it's likely that we always want to recursively update all the submodules
when running `git pull`.

## Steps to Reproduce

Setup:

```sh
git clone --recurse-submodules --branch v0.4.0 /~https://github.com/runfinch/finch.git
cd finch
git checkout -b demo
git branch --set-upstream-to origin/main
git pull
```

Submodules are not updated:

```sh
➜  finch git:(demo) ✗ git --no-pager diff
diff --git a/deps/finch-core b/deps/finch-core
index eef2102..01e6162 160000
--- a/deps/finch-core
+++ b/deps/finch-core
@@ -1 +1 @@
-Subproject commit eef21029b89d7db00bddc6e426e4405c920b13ed
+Subproject commit 01e6162d6fd76fddb9d8ef59845c782a0b6ebafd
```

Fix it:

```sh
➜  finch git:(demo) ✗ git config submodule.recurse true
➜  finch git:(demo) ✗ git pull
Fetching submodule deps/finch-core
Fetching submodule deps/finch-core/src/lima
Fetching submodule deps/finch-core/src/socket_vmnet
Already up to date.
Submodule path 'deps/finch-core': checked out 'eef21029b89d7db00bddc6e426e4405c920b13ed'
Submodule path 'deps/finch-core/src/socket_vmnet': checked out 'ee27d206872fc861c2993264be93d2ccc2740f9c'
➜  finch git:(demo) git --no-pager diff
➜  finch git:(demo) echo $?
0
```

## Notes

If `submodule.stickyRecursiveClone` is set, and the repository is cloned
with `--recurse-submodules`, it'd also work, but it does not account for
the case when the repository is already cloned without
`--recurse-submodules`, so setting `git config submodule.recurse true`
seems to be the simplest way that works for all scenarios.

## License Acceptance

By submitting this pull request, I confirm that my contribution is made
under the terms of the Apache 2.0 license.

Signed-off-by: Hsing-Yu (David) Chen <davidhsingyuchen@gmail.com>

* ci: Add workflow to sync finch submodules (runfinch#271)

Issue #, if available: N/A

*Description of changes:*
Add workflow to update submodules in `finch`. 

#### Details
1. Workflow runs daily at 9am UTC. 
2. Has a `workflow_dispatch` trigger for manually running the workflow
in addition to the regular daily cadence.
*Testing done:*
Yes. See #2
Test with updating `FINCH_OS_BASENAME` :
/~https://github.com/vsiravar/finch-public/pull/4/files#diff-76ed074a9305c04054cdebb9e9aad2d818052b07091de1f20cad0bbac34ffb52


- [X] I've reviewed the guidance in CONTRIBUTING.md


#### License Acceptance

By submitting this pull request, I confirm that my contribution is made
under the terms of the Apache 2.0 license.

---------

Signed-off-by: Vishwas Siravara <siravara@amazon.com>
Signed-off-by: Vishwas Siravara <vsiravara@gmail.com>

* PR 1 with a new interface for testing reverting a PR

* PR 2 which uses previoulsy created interface in PR1

* build(deps): Bump submodules (runfinch#281)

Automated changes by
[create-pull-request](/~https://github.com/peter-evans/create-pull-request)
GitHub action

Signed-off-by: GitHub <noreply@github.com>
Co-authored-by: vsiravar <vsiravar@users.noreply.github.com>

* test: Improve test coverage for additional disk feature (runfinch#280)

Issue #, if available:
Improving the e2e test coverage for additional disk.
*Description of changes:*
Adding test to retaining volume, network, and restart the container
after the VM is removed
*Testing done:*



- [x] I've reviewed the guidance in CONTRIBUTING.md


#### License Acceptance

By submitting this pull request, I confirm that my contribution is made
under the terms of the Apache 2.0 license.

---------

Signed-off-by: Ang Zhou <angzh@amazon.com>

* ci: add sanity test for running multiple VM instances in release test (runfinch#278)

Issue #, if available:

*Description of changes:*

*Testing done:*
/~https://github.com/runfinch/finch/actions/runs/4368693657/workflow
/~https://github.com/runfinch/finch/actions/runs/4367945800


- [x] I've reviewed the guidance in CONTRIBUTING.md


#### License Acceptance

By submitting this pull request, I confirm that my contribution is made
under the terms of the Apache 2.0 license.

---------

Signed-off-by: Anqi Pang <anqipans@amazon.com>

* ci: Add schedule to update-deps workflow (runfinch#292)

Issue #, if available:

*Description of changes:*
Schedule [update
dependencies](/~https://github.com/runfinch/finch/blob/main/.github/workflows/update-deps.yaml)
workflow which is currently triggered only by `workflow_dispatch`. This
workflow will run after dependencies are built in `finch-core` by
/~https://github.com/runfinch/finch-core/blob/main/.github/workflows/release.yaml(runs
at 9 am UTC on Tuesday) at 11 am UTC on Tuesday.
*Testing done:*
Yes. 
runfinch#291

- [X] I've reviewed the guidance in CONTRIBUTING.md


#### License Acceptance

By submitting this pull request, I confirm that my contribution is made
under the terms of the Apache 2.0 license.

Signed-off-by: Vishwas Siravara <siravara@amazon.com>

* build(deps): bump github.com/onsi/ginkgo/v2 from 2.9.0 to 2.9.1 (runfinch#285)

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* build(deps): bump github.com/runfinch/common-tests from 0.6.1 to 0.6.2 (runfinch#300)

Bumps
[github.com/runfinch/common-tests](/~https://github.com/runfinch/common-tests)
from 0.6.1 to 0.6.2.
<details>
<summary>Release notes</summary>
<p><em>Sourced from <a
href="/~https://github.com/runfinch/common-tests/releases">github.com/runfinch/common-tests's
releases</a>.</em></p>
<blockquote>
<h2>v0.6.2</h2>
<h2><a
href="/~https://github.com/runfinch/common-tests/compare/v0.6.1...v0.6.2">0.6.2</a>
(2023-03-16)</h2>
<h3>Bug Fixes</h3>
<ul>
<li>Fix tests to match nerdctl 1.2.1 outputs (<a
href="https://redirect.github.com/runfinch/common-tests/issues/50">#50</a>)
(<a
href="/~https://github.com/runfinch/common-tests/commit/3d9b4f4794d8df965dd2d611b2bed59aabff7dc2">3d9b4f4</a>)</li>
</ul>
<h3>Build System or External Dependencies</h3>
<ul>
<li><strong>deps:</strong> bump github.com/onsi/ginkgo/v2 from 2.8.3 to
2.8.4 (<a
href="https://redirect.github.com/runfinch/common-tests/issues/41">#41</a>)
(<a
href="/~https://github.com/runfinch/common-tests/commit/a9476c13bc4febd40a4f98cc8e6f8eebc04cfb5e">a9476c1</a>)</li>
<li><strong>deps:</strong> bump github.com/onsi/gomega from 1.27.1 to
1.27.2 (<a
href="https://redirect.github.com/runfinch/common-tests/issues/40">#40</a>)
(<a
href="/~https://github.com/runfinch/common-tests/commit/e8fc71a9c94afe2084bfdb129de5f5828adfa8b8">e8fc71a</a>)</li>
</ul>
</blockquote>
</details>
<details>
<summary>Changelog</summary>
<p><em>Sourced from <a
href="/~https://github.com/runfinch/common-tests/blob/main/CHANGELOG.md">github.com/runfinch/common-tests's
changelog</a>.</em></p>
<blockquote>
<h2><a
href="/~https://github.com/runfinch/common-tests/compare/v0.6.1...v0.6.2">0.6.2</a>
(2023-03-16)</h2>
<h3>Bug Fixes</h3>
<ul>
<li>Fix tests to match nerdctl 1.2.1 outputs (<a
href="https://redirect.github.com/runfinch/common-tests/issues/50">#50</a>)
(<a
href="/~https://github.com/runfinch/common-tests/commit/3d9b4f4794d8df965dd2d611b2bed59aabff7dc2">3d9b4f4</a>)</li>
</ul>
<h3>Build System or External Dependencies</h3>
<ul>
<li><strong>deps:</strong> bump github.com/onsi/ginkgo/v2 from 2.8.3 to
2.8.4 (<a
href="https://redirect.github.com/runfinch/common-tests/issues/41">#41</a>)
(<a
href="/~https://github.com/runfinch/common-tests/commit/a9476c13bc4febd40a4f98cc8e6f8eebc04cfb5e">a9476c1</a>)</li>
<li><strong>deps:</strong> bump github.com/onsi/gomega from 1.27.1 to
1.27.2 (<a
href="https://redirect.github.com/runfinch/common-tests/issues/40">#40</a>)
(<a
href="/~https://github.com/runfinch/common-tests/commit/e8fc71a9c94afe2084bfdb129de5f5828adfa8b8">e8fc71a</a>)</li>
</ul>
</blockquote>
</details>
<details>
<summary>Commits</summary>
<ul>
<li><a
href="/~https://github.com/runfinch/common-tests/commit/da6f643de4f9b9e1e2345c8195d968da9281a936"><code>da6f643</code></a>
chore(main): release 0.6.2 (<a
href="https://redirect.github.com/runfinch/common-tests/issues/44">#44</a>)</li>
<li><a
href="/~https://github.com/runfinch/common-tests/commit/3d9b4f4794d8df965dd2d611b2bed59aabff7dc2"><code>3d9b4f4</code></a>
fix: Fix tests to match nerdctl 1.2.1 outputs (<a
href="https://redirect.github.com/runfinch/common-tests/issues/50">#50</a>)</li>
<li><a
href="/~https://github.com/runfinch/common-tests/commit/e8fc71a9c94afe2084bfdb129de5f5828adfa8b8"><code>e8fc71a</code></a>
build(deps): bump github.com/onsi/gomega from 1.27.1 to 1.27.2 (<a
href="https://redirect.github.com/runfinch/common-tests/issues/40">#40</a>)</li>
<li><a
href="/~https://github.com/runfinch/common-tests/commit/a9476c13bc4febd40a4f98cc8e6f8eebc04cfb5e"><code>a9476c1</code></a>
build(deps): bump github.com/onsi/ginkgo/v2 from 2.8.3 to 2.8.4 (<a
href="https://redirect.github.com/runfinch/common-tests/issues/41">#41</a>)</li>
<li>See full diff in <a
href="/~https://github.com/runfinch/common-tests/compare/v0.6.1...v0.6.2">compare
view</a></li>
</ul>
</details>
<br />


[![Dependabot compatibility
score](https://dependabot-badges.githubapp.com/badges/compatibility_score?dependency-name=github.com/runfinch/common-tests&package-manager=go_modules&previous-version=0.6.1&new-version=0.6.2)](https://docs.github.com/en/github/managing-security-vulnerabilities/about-dependabot-security-updates#about-compatibility-scores)

Dependabot will resolve any conflicts with this PR as long as you don't
alter it yourself. You can also trigger a rebase manually by commenting
`@dependabot rebase`.

[//]: # (dependabot-automerge-start)
[//]: # (dependabot-automerge-end)

---

<details>
<summary>Dependabot commands and options</summary>
<br />

You can trigger Dependabot actions by commenting on this PR:
- `@dependabot rebase` will rebase this PR
- `@dependabot recreate` will recreate this PR, overwriting any edits
that have been made to it
- `@dependabot merge` will merge this PR after your CI passes on it
- `@dependabot squash and merge` will squash and merge this PR after
your CI passes on it
- `@dependabot cancel merge` will cancel a previously requested merge
and block automerging
- `@dependabot reopen` will reopen this PR if it is closed
- `@dependabot close` will close this PR and stop Dependabot recreating
it. You can achieve the same result by closing it manually
- `@dependabot ignore this major version` will close this PR and stop
Dependabot creating any more for this major version (unless you reopen
the PR or upgrade to it yourself)
- `@dependabot ignore this minor version` will close this PR and stop
Dependabot creating any more for this minor version (unless you reopen
the PR or upgrade to it yourself)
- `@dependabot ignore this dependency` will close this PR and stop
Dependabot creating any more for this dependency (unless you reopen the
PR or upgrade to it yourself)


</details>

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* build(deps): Bump lima version (runfinch#302)

Automated changes by
[create-pull-request](/~https://github.com/peter-evans/create-pull-request)
GitHub action

Signed-off-by: GitHub <noreply@github.com>
Co-authored-by: vsiravar <vsiravar@users.noreply.github.com>

* build(deps): Bump submodules (runfinch#304)

Automated changes by
[create-pull-request](/~https://github.com/peter-evans/create-pull-request)
GitHub action

Signed-off-by: GitHub <noreply@github.com>
Co-authored-by: ahsan-z-khan <ahsan-z-khan@users.noreply.github.com>

---------

Signed-off-by: Vishwas Siravara <siravara@amazon.com>
Signed-off-by: Hsing-Yu (David) Chen <davidhsingyuchen@gmail.com>
Signed-off-by: Vishwas Siravara <vsiravara@gmail.com>
Signed-off-by: GitHub <noreply@github.com>
Signed-off-by: Ang Zhou <angzh@amazon.com>
Signed-off-by: Anqi Pang <anqipans@amazon.com>
Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: Hsing-Yu (David) Chen <davidhsingyuchen@gmail.com>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: vsiravar <vsiravar@users.noreply.github.com>
Co-authored-by: Ang Zhou <40868185+azhouwd@users.noreply.github.com>
Co-authored-by: Anqi Pang <55934700+AnqiPang@users.noreply.github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: ahsan-z-khan <ahsan-z-khan@users.noreply.github.com>
  • Loading branch information
8 people authored Mar 19, 2023
1 parent 674b379 commit 0f11984
Show file tree
Hide file tree
Showing 22 changed files with 303 additions and 49 deletions.
24 changes: 24 additions & 0 deletions .github/bin/update-os-image.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#!/bin/bash
set -euxo pipefail
# Set OS hash directory in finch-core as base directory for searching latest OS images.
OS_BASE_IMAGE_HASH_DIR="./deps/finch-core/hashes/"

OS_AARCH64_FILENAME_PATTERN="Fedora-Cloud-Base-.*-.*.aarch64-.*.qcow2"

OS_X86_64_FILENAME_PATTERN="Fedora-Cloud-Base-.*-.*.x86_64-.*.qcow2"


# Use wildcard patterns to search for the two files and assign their paths to variables
AARCH64_FILEPATH=$(find "$OS_BASE_IMAGE_HASH_DIR" -name "Fedora-Cloud-Base-*-*.aarch64-*.qcow2.sha512" -print -quit)
X86_64_FILEPATH=$(find "$OS_BASE_IMAGE_HASH_DIR" -name "Fedora-Cloud-Base-*-*.x86_64-*.qcow2.sha512" -print -quit)

# Extract the file names without the path and remove the ".sha512" extension
AARCH64_OS_BASE_IMAGE=$(basename "$AARCH64_FILEPATH" .sha512)
X86_64_OS_BASE_IMAGE=$(basename "$X86_64_FILEPATH" .sha512)

echo "AARCH64 base image: ${AARCH64_OS_BASE_IMAGE}"
echo "X86_64 base image: ${X86_64_OS_BASE_IMAGE}"

# Replace occurrences of FINCH_OS_BASENAME in the Makefile with the file names
sed -E -i.bak 's|^([[:blank:]]*FINCH_OS_BASENAME[[:blank:]]*\?=[[:blank:]]*)('"${OS_AARCH64_FILENAME_PATTERN}"')|\1'"$AARCH64_OS_BASE_IMAGE"'|' Makefile
sed -E -i.bak 's|^([[:blank:]]*FINCH_OS_BASENAME[[:blank:]]*\?=[[:blank:]]*)('"${OS_X86_64_FILENAME_PATTERN}"')|\1'"$X86_64_OS_BASE_IMAGE"'|' Makefile
61 changes: 60 additions & 1 deletion .github/workflows/release-homebrew.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,9 @@ jobs:
- uses: actions/checkout@v3
with:
ref: ${{ env.FINCH_TAG }}
fetch-depth: 0
persist-credentials: false
submodules: true
- name: Clean up previous files
run: |
sudo rm -rf /opt/finch
Expand All @@ -85,8 +88,36 @@ jobs:
brew bump-cask-pr --write-only -f --version=$FINCH_VERSION finch
- name: Silently install
run: |
export HOMEBREW_NO_INSTALL_FROM_API=1
cd $(brew --repo homebrew/cask)
brew install --cask ./Casks/finch.rb
- name: Build project
run: |
brew install go lz4 automake autoconf libtool
export PATH="/opt/homebrew/opt/libtool/libexec/gnubin:$PATH"
make
- name: Multiple instances of Finch test
run: |
# start two Finch VM instances
./_output/bin/finch vm init
finch vm init
# start a container in each VM instance
./_output/bin/finch pull alpine
finch pull alpine
./_output/bin/finch run --name test-ctr1 alpine
finch run --name test-ctr2 alpine
# clean up the VMs
./_output/bin/finch vm stop && ./_output/bin/finch vm remove
finch vm stop && finch vm remove
- name: Clean up multiple instance test
run: |
sudo rm -rf ./_output
export HOMEBREW_NO_INSTALL_FROM_API=1
cd $(brew --repo homebrew/cask)
# Need to reinstall because there were errors on arm64 11.7 and arm64 12.6 hosts after running multiple instances tests,
# that caused the VM initialization failure in the e2e test.
# Example workflow run /~https://github.com/runfinch/finch/actions/runs/4367457552/jobs/7638794529
brew reinstall --cask ./Casks/finch.rb
- name: Run e2e tests
run: INSTALLED=true make test-e2e
- name: Silently uninstall
Expand Down Expand Up @@ -124,6 +155,9 @@ jobs:
- uses: actions/checkout@v3
with:
ref: ${{ env.FINCH_TAG }}
fetch-depth: 0
persist-credentials: false
submodules: true
- name: Clean up previous files
run: |
sudo rm -rf /opt/finch
Expand All @@ -148,8 +182,33 @@ jobs:
brew bump-cask-pr --write-only -f --version=$FINCH_VERSION finch
- name: Silently install
run: |
export HOMEBREW_NO_INSTALL_FROM_API=1
cd $(brew --repo homebrew/cask)
brew install --cask ./Casks/finch.rb
- name: Build project
run: |
brew install go lz4 automake autoconf libtool
export PATH="/opt/homebrew/opt/libtool/libexec/gnubin:$PATH"
make
- name: Multiple instances of Finch test
run: |
# start two Finch VM instances
./_output/bin/finch vm init
finch vm init
# start a container in each VM instance
./_output/bin/finch pull alpine
finch pull alpine
./_output/bin/finch run --name test-ctr1 alpine
finch run --name test-ctr2 alpine
# clean up the VMs
./_output/bin/finch vm stop && ./_output/bin/finch vm remove
finch vm stop && finch vm remove
- name: Clean up multiple instance test
run: |
sudo rm -rf ./_output
export HOMEBREW_NO_INSTALL_FROM_API=1
cd $(brew --repo homebrew/cask)
brew reinstall --cask ./Casks/finch.rb
- name: Run e2e tests
run: INSTALLED=true make test-e2e
- name: Silently uninstall
Expand All @@ -161,7 +220,7 @@ jobs:
echo ERROR: Finch is not uninstalled
exit 1
fi
pr-to-homebrew:
needs: [get-latest-tag, macos-arm64-test-installer, macos-amd64-test-installer]
runs-on: macos-latest
Expand Down
91 changes: 87 additions & 4 deletions .github/workflows/release-installer.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,20 @@ jobs:
steps:
- uses: actions/setup-go@v3
with:
go-version: 1.19.x
- uses: actions/checkout@v3
go-version-file: go.mod
cache: true
- name: Checkout the tag
uses: actions/checkout@v3
with:
ref: ${{ github.ref_name }}
fetch-depth: 0
persist-credentials: false
submodules: true
- name: Clean up previous files
run: |
sudo rm -rf /opt/finch
sudo rm -rf ~/.finch
sudo rm -rf ./_output
if pgrep '^qemu-system'; then
sudo pkill '^qemu-system'
fi
Expand All @@ -64,6 +72,41 @@ jobs:
aws s3 cp s3://${{ secrets.INSTALLER_PRIVATE_BUCKET_NAME }}/Finch-${GITHUB_REF_NAME}-aarch64.pkg Finch-${GITHUB_REF_NAME}-aarch64.pkg
- name: Silently install
run: sudo installer -pkg Finch-${GITHUB_REF_NAME}-aarch64.pkg -target /
- name: Build project
run: |
brew install go lz4 automake autoconf libtool
export PATH="/opt/homebrew/opt/libtool/libexec/gnubin:$PATH"
make
- name: Multiple instances of Finch test
run: |
# start two Finch VM instances
./_output/bin/finch vm init
finch vm init
# start a container in each VM instance
./_output/bin/finch pull alpine
finch pull alpine
./_output/bin/finch run --name test-ctr1 alpine
finch run --name test-ctr2 alpine
# check whether containers exist
if ! ./_output/bin/finch ps -a | grep 'test-ctr1'; then
echo "ERROR: The container test-ctr1 doesn't exist"
exit 1
fi
if ! finch ps -a | grep 'test-ctr2'; then
echo "ERROR: The container test-ctr2 doesn't exist"
exit 1
fi
# clean up the VMs
./_output/bin/finch vm stop && ./_output/bin/finch vm remove
finch vm stop && finch vm remove
- name: Clean up multiple instance test
run: |
sudo rm -rf ./_output
echo 'y' | sudo bash /Applications/Finch/uninstall.sh
# Need to reinstall because there were errors on arm64 11.7 and arm64 12.6 hosts after running multiple instances tests,
# that caused the VM initialization failure in the e2e test.
# Example workflow run /~https://github.com/runfinch/finch/actions/runs/4367457552/jobs/7638794529
sudo installer -pkg Finch-${GITHUB_REF_NAME}-aarch64.pkg -target /
- name: Run e2e tests
run: INSTALLED=true make test-e2e
- name: Silently uninstall
Expand All @@ -88,12 +131,20 @@ jobs:
steps:
- uses: actions/setup-go@v3
with:
go-version: 1.19.x
- uses: actions/checkout@v3
go-version-file: go.mod
cache: true
- name: Checkout the tag
uses: actions/checkout@v3
with:
ref: ${{ github.ref_name }}
fetch-depth: 0
persist-credentials: false
submodules: true
- name: Clean up previous files
run: |
sudo rm -rf /opt/finch
sudo rm -rf ~/.finch
sudo rm -rf ./_output
if pgrep '^qemu-system'; then
sudo pkill '^qemu-system'
fi
Expand All @@ -112,6 +163,38 @@ jobs:
- name: Silently install
run: |
sudo installer -pkg Finch-${GITHUB_REF_NAME}-x86_64.pkg -target /
- name: Build project
run: |
brew install go lz4 automake autoconf libtool
export PATH="/opt/homebrew/opt/libtool/libexec/gnubin:$PATH"
make
- name: Multiple instances of Finch test
run: |
# start two Finch VM instances
./_output/bin/finch vm init
finch vm init
# start a container in each VM instance
./_output/bin/finch pull alpine
finch pull alpine
./_output/bin/finch run --name test-ctr1 alpine
finch run --name test-ctr2 alpine
# check whether containers exist
if ! ./_output/bin/finch ps -a | grep 'test-ctr1'; then
echo "ERROR: The container test-ctr1 doesn't exist"
exit 1
fi
if ! finch ps -a | grep 'test-ctr2'; then
echo "ERROR: The container test-ctr2 doesn't exist"
exit 1
fi
# clean up the VMs
./_output/bin/finch vm stop && ./_output/bin/finch vm remove
finch vm stop && finch vm remove
- name: Clean up multiple instance test
run: |
sudo rm -rf ./_output
echo 'y' | sudo bash /Applications/Finch/uninstall.sh
sudo installer -pkg Finch-${GITHUB_REF_NAME}-x86_64.pkg -target /
- name: Run e2e tests
run: INSTALLED=true make test-e2e
- name: Silently uninstall
Expand Down
27 changes: 27 additions & 0 deletions .github/workflows/sync-submodules.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
name: Sync Submodules

# Pulls changes from the main branch of submodules daily at 9:00 UTC and opens a PR.
on:
schedule:
- cron: '0 9 * * *'
workflow_dispatch:

jobs:
update:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
with:
submodules: recursive
token: ${{ secrets.GITHUB_TOKEN }}
- name: Update sub modules
run: |
git submodule update --remote
./.github/bin/update-os-image.sh
- name: Create PR
uses: peter-evans/create-pull-request@v4
with:
token: ${{ secrets.GITHUB_TOKEN }}
signoff: true
title: 'build(deps): Bump submodules'
2 changes: 2 additions & 0 deletions .github/workflows/update-deps.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
name: Update dependencies
on:
schedule:
- cron: '0 11 * * 2'
workflow_dispatch:

permissions:
Expand Down
8 changes: 6 additions & 2 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -139,9 +139,13 @@ If the repo is already cloned, but the submodules are not pulled yet, the follow
git submodule update --init --recursive
```

After cloning the repo, run `make` to build the binary.
After cloning the repo, run the following command to make subsequent `git pull` to also update submodules to the versions specified in the upstream branch.

The binary in `_output` can be directly used. E.g. initializing the vm and display the version
```shell
git config submodule.recurse true
```

Then run `make` to build the binary. 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
8 changes: 4 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -34,14 +34,14 @@ 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-20230302174539.qcow2
LIMA_URL ?= https://deps.runfinch.com/aarch64/lima-and-qemu.macos-aarch64.1673290784.tar.gz
FINCH_OS_BASENAME ?= Fedora-Cloud-Base-37-1.7.aarch64-20230317205128.qcow2
LIMA_URL ?= https://deps.runfinch.com/aarch64/lima-and-qemu.macos-aarch64.1678826933.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-20230302173518.qcow2
LIMA_URL ?= https://deps.runfinch.com/x86-64/lima-and-qemu.macos-x86_64.1673290501.tar.gz
FINCH_OS_BASENAME ?= Fedora-Cloud-Base-37-1.7.x86_64-20230317204632.qcow2
LIMA_URL ?= https://deps.runfinch.com/x86-64/lima-and-qemu.macos-x86_64.1678817277.tar.gz
endif

FINCH_OS_HASH := `shasum -a 256 $(OUTDIR)/os/$(FINCH_OS_BASENAME) | cut -d ' ' -f 1`
Expand Down
32 changes: 32 additions & 0 deletions cmd/finch/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,39 @@ import (

const finchRootCmd = "finch"

type Shape interface {
Area() float64
}

type Rectangle struct {
Width float64
Height float64
}

func (r Rectangle) Area() float64 {
return 0
}

type Square struct {
Width float64
}

func (r Square) Area() float64 {
return 1
}

func computeArea(shape Shape) float64 {
return shape.Area()
}

func main() {
println(computeArea(&Rectangle{
Width: 0,
Height: 0,
}))
println(computeArea(&Square{
Width: 1,
}))
logger := flog.NewLogrus()
stdLib := system.NewStdLib()
fs := afero.NewOsFs()
Expand Down
2 changes: 1 addition & 1 deletion cmd/finch/virtual_machine_init.go
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ func (iva *initVMAction) run() error {
iva.logger.Info("Initializing and starting Finch virtual machine...")
logs, err := limaCmd.CombinedOutput()
if err != nil {
iva.logger.Errorf("Finch virtual machine failed to start, debug logs: %s", logs)
iva.logger.Errorf("Finch virtual machine failed to start, debug logs:\n%s", logs)
return err
}
iva.logger.Info("Finch virtual machine started successfully")
Expand Down
2 changes: 1 addition & 1 deletion cmd/finch/virtual_machine_init_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -289,7 +289,7 @@ func TestInitVMAction_run(t *testing.T) {
mockBaseYamlFilePath, "--tty=false").Return(command)

logger.EXPECT().Info("Initializing and starting Finch virtual machine...")
logger.EXPECT().Errorf("Finch virtual machine failed to start, debug logs: %s", logs)
logger.EXPECT().Errorf("Finch virtual machine failed to start, debug logs:\n%s", logs)
},
},
}
Expand Down
2 changes: 1 addition & 1 deletion cmd/finch/virtual_machine_remove.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ func (rva *removeVMAction) removeVM(force bool) error {
}
logs, err := limaCmd.CombinedOutput()
if err != nil {
rva.logger.Errorf("Finch virtual machine failed to remove, debug logs: %s", logs)
rva.logger.Errorf("Finch virtual machine failed to remove, debug logs:\n%s", logs)
return err
}
rva.logger.Info("Finch virtual machine removed successfully")
Expand Down
2 changes: 1 addition & 1 deletion cmd/finch/virtual_machine_remove_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ func TestRemoveVMAction_run(t *testing.T) {
command.EXPECT().CombinedOutput().Return(logs, errors.New("failed to remove instance"))
creator.EXPECT().CreateWithoutStdio("remove", limaInstanceName).Return(command)
logger.EXPECT().Info("Removing existing Finch virtual machine...")
logger.EXPECT().Errorf("Finch virtual machine failed to remove, debug logs: %s", logs)
logger.EXPECT().Errorf("Finch virtual machine failed to remove, debug logs:\n%s", logs)
},
force: false,
},
Expand Down
Loading

0 comments on commit 0f11984

Please sign in to comment.