Skip to content

Commit

Permalink
Merge branch 'main' into angzh/fix-config-mount
Browse files Browse the repository at this point in the history
# Conflicts:
#	cmd/finch/main.go
  • Loading branch information
azhouwd committed Mar 28, 2023
2 parents 1d18c46 + fd3bf19 commit ebba98a
Show file tree
Hide file tree
Showing 32 changed files with 1,015 additions and 176 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci-docs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ jobs:
e2e-tests:
strategy:
matrix:
os: [[self-hosted, macos, amd64, 11.7], [self-hosted, macos, amd64, 12.6], [self-hosted, macos, arm64, 11.7], [self-hosted, macos, arm64, 12.6]]
os: [[self-hosted, macos, amd64, 13], [self-hosted, macos, amd64, 12.6], [self-hosted, macos, arm64, 13], [self-hosted, macos, arm64, 12.6]]
runs-on: ${{ matrix.os }}
steps:
- run: echo "Skipping CI for docs & contrib files"
Expand Down
4 changes: 3 additions & 1 deletion .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ jobs:
strategy:
fail-fast: false
matrix:
os: [[self-hosted, macos, amd64, 11.7], [self-hosted, macos, amd64, 12.6], [self-hosted, macos, arm64, 11.7], [self-hosted, macos, arm64, 12.6]]
os: [[self-hosted, macos, amd64, 13], [self-hosted, macos, amd64, 12.6], [self-hosted, macos, arm64, 13], [self-hosted, macos, arm64, 12.6]]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v3
Expand All @@ -102,6 +102,8 @@ jobs:
if pgrep '^socket_vmnet'; then
sudo pkill '^socket_vmnet'
fi
- name: Install Rosetta 2
run: echo "A" | softwareupdate --install-rosetta || true
- run: brew install go lz4 automake autoconf libtool
- name: Build project
run: |
Expand Down
50 changes: 42 additions & 8 deletions .github/workflows/release-homebrew.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -52,16 +52,16 @@ jobs:
FINCH_TAG: ${{ needs.get-latest-tag.outputs.tag }}
FINCH_VERSION: ${{ needs.get-latest-tag.outputs.version }}
steps:
- uses: actions/setup-go@v4
with:
go-version-file: go.mod
cache: true
- uses: actions/checkout@v3
with:
ref: ${{ env.FINCH_TAG }}
fetch-depth: 0
persist-credentials: false
submodules: true
- uses: actions/setup-go@v4
with:
go-version-file: go.mod
cache: true
- name: Clean up previous files
run: |
sudo rm -rf /opt/finch
Expand Down Expand Up @@ -106,6 +106,23 @@ jobs:
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 in the built finch VM"
exit 1
fi
if ./_output/bin/finch ps -a | grep 'test-ctr2'; then
echo "ERROR: The container test-ctr2 shoudn't exist in the built finch VM"
exit 1
fi
if ! finch ps -a | grep 'test-ctr2'; then
echo "ERROR: The container test-ctr2 doesn't exist in the installed finch VM"
exit 1
fi
if finch ps -a | grep 'test-ctr1'; then
echo "ERROR: The container test-ctr1 shoudn't exist in the installed finch VM"
exit 1
fi
# clean up the VMs
./_output/bin/finch vm stop && ./_output/bin/finch vm remove
finch vm stop && finch vm remove
Expand Down Expand Up @@ -148,16 +165,16 @@ jobs:
FINCH_TAG: ${{ needs.get-latest-tag.outputs.tag }}
FINCH_VERSION: ${{ needs.get-latest-tag.outputs.version }}
steps:
- uses: actions/setup-go@v4
with:
go-version-file: go.mod
cache: true
- uses: actions/checkout@v3
with:
ref: ${{ env.FINCH_TAG }}
fetch-depth: 0
persist-credentials: false
submodules: true
- uses: actions/setup-go@v4
with:
go-version-file: go.mod
cache: true
- name: Clean up previous files
run: |
sudo rm -rf /opt/finch
Expand Down Expand Up @@ -200,6 +217,23 @@ jobs:
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 in the built finch VM"
exit 1
fi
if ./_output/bin/finch ps -a | grep 'test-ctr2'; then
echo "ERROR: The container test-ctr2 shoudn't exist in the built finch VM"
exit 1
fi
if ! finch ps -a | grep 'test-ctr2'; then
echo "ERROR: The container test-ctr2 doesn't exist in the installed finch VM"
exit 1
fi
if finch ps -a | grep 'test-ctr1'; then
echo "ERROR: The container test-ctr1 shoudn't exist in the installed finch VM"
exit 1
fi
# clean up the VMs
./_output/bin/finch vm stop && ./_output/bin/finch vm remove
finch vm stop && finch vm remove
Expand Down
40 changes: 28 additions & 12 deletions .github/workflows/release-installer.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -39,17 +39,17 @@ jobs:
env:
ACCESS_TOKEN: ${{ secrets.FINCH_BOT_TOKEN }}
steps:
- uses: actions/setup-go@v4
with:
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
- uses: actions/setup-go@v4
with:
go-version-file: go.mod
cache: true
- name: Clean up previous files
run: |
sudo rm -rf /opt/finch
Expand Down Expand Up @@ -89,11 +89,19 @@ jobs:
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"
echo "ERROR: The container test-ctr1 doesn't exist in the built finch VM"
exit 1
fi
if ./_output/bin/finch ps -a | grep 'test-ctr2'; then
echo "ERROR: The container test-ctr2 shoudn't exist in the built finch VM"
exit 1
fi
if ! finch ps -a | grep 'test-ctr2'; then
echo "ERROR: The container test-ctr2 doesn't exist"
echo "ERROR: The container test-ctr2 doesn't exist in the installed finch VM"
exit 1
fi
if finch ps -a | grep 'test-ctr1'; then
echo "ERROR: The container test-ctr1 shoudn't exist in the installed finch VM"
exit 1
fi
# clean up the VMs
Expand Down Expand Up @@ -129,17 +137,17 @@ jobs:
env:
ACCESS_TOKEN: ${{ secrets.FINCH_BOT_TOKEN }}
steps:
- uses: actions/setup-go@v4
with:
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
- uses: actions/setup-go@v4
with:
go-version-file: go.mod
cache: true
- name: Clean up previous files
run: |
sudo rm -rf /opt/finch
Expand Down Expand Up @@ -180,11 +188,19 @@ jobs:
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"
echo "ERROR: The container test-ctr1 doesn't exist in the built finch VM"
exit 1
fi
if ./_output/bin/finch ps -a | grep 'test-ctr2'; then
echo "ERROR: The container test-ctr2 shoudn't exist in the built finch VM"
exit 1
fi
if ! finch ps -a | grep 'test-ctr2'; then
echo "ERROR: The container test-ctr2 doesn't exist"
echo "ERROR: The container test-ctr2 doesn't exist in the installed finch VM"
exit 1
fi
if finch ps -a | grep 'test-ctr1'; then
echo "ERROR: The container test-ctr1 shoudn't exist in the installed finch VM"
exit 1
fi
# clean up the VMs
Expand Down
56 changes: 28 additions & 28 deletions .github/workflows/upload-build-to-s3.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,70 +12,70 @@ permissions:
contents: read # This is required for actions/checkout

jobs:
macos-arm64-build:
macos-aarch64-build:
runs-on: ['self-hosted', 'macos', 'arm64', '11.7']
timeout-minutes: 60
steps:
- uses: actions/setup-go@v4
with:
go-version-file: go.mod
cache: true
- uses: actions/checkout@v3
with:
fetch-depth: 0
persist-credentials: false
submodules: true
- uses: actions/setup-go@v4
with:
go-version-file: go.mod
cache: true

- name: Make macos arm64 build
- name: Make macos aarch64 build
run: |
brew install go lz4 automake autoconf libtool
make clean
make download-licenses
make FINCH_OS_IMAGE_LOCATION_ROOT=/Applications/Finch
tar -zcvf finch.arm64."$(date '+%s').tar.gz" _output
tar -zcvf finch.${GITHUB_REF_NAME}.aarch64.tar.gz _output
- name: Upload macos arm64 build
- name: Upload macos aarch64 build
uses: actions/upload-artifact@v2
with:
name: finch.macos-arm64
path: finch.arm64.*.tar.gz
name: finch.macos-aarch64
path: finch.*.aarch64.tar.gz
if-no-files-found: error

macos-x86-build:
macos-x86_64-build:
runs-on: ['self-hosted', 'macos', 'amd64', '10.15']
timeout-minutes: 60
steps:
- uses: actions/setup-go@v4
with:
go-version-file: go.mod
cache: true
- uses: actions/checkout@v3
with:
fetch-depth: 0
persist-credentials: false
submodules: true
- uses: actions/setup-go@v4
with:
go-version-file: go.mod
cache: true

- name: Make macos amd64 build
- name: Make macos x86_64 build
run: |
brew install go lz4 automake autoconf libtool
make clean
make download-licenses
make FINCH_OS_IMAGE_LOCATION_ROOT=/Applications/Finch
tar -zcvf finch.amd64."$(date '+%s').tar.gz" _output
tar -zcvf finch.${GITHUB_REF_NAME}.x86_64.tar.gz _output
- name: Upload macos amd64 build
- name: Upload macos x86_64 build
uses: actions/upload-artifact@v2
with:
name: finch.macos-amd64
path: finch.amd64.*.tar.gz
name: finch.macos-x86_64
path: finch.*.x86_64.tar.gz
if-no-files-found: error

release:
runs-on: ubuntu-latest
timeout-minutes: 5
needs:
- macos-x86-build
- macos-arm64-build
- macos-x86_64-build
- macos-aarch64-build
steps:
- uses: actions/checkout@v3
with:
Expand All @@ -89,19 +89,19 @@ jobs:
role-session-name: dependency-upload-session
aws-region: ${{ secrets.REGION }}

- name: Download macos arm64 build
- name: Download macos aarch64 build
uses: actions/download-artifact@v2
with:
name: finch.macos-arm64
name: finch.macos-aarch64
path: build

- name: Download macos amd64 build
- name: Download macos x86_64 build
uses: actions/download-artifact@v2
with:
name: finch.macos-amd64
name: finch.macos-x86_64
path: build
# TODO: Change destination bucket after creating automation for signing.
- name: "Upload to S3"
run: |
aws s3 cp ./build/ s3://${{ secrets.DEPENDENCY_BUCKET_NAME }}/aarch64/ --recursive --exclude "*" --include "finch.arm64*"
aws s3 cp ./build/ s3://${{ secrets.DEPENDENCY_BUCKET_NAME }}/x86-64/ --recursive --exclude "*" --include "finch.amd64*"
aws s3 cp ./build/ s3://${{ secrets.DEPENDENCY_BUCKET_NAME }}/aarch64/ --recursive --exclude "*" --include "finch.${GITHUB_REF_NAME}.aarch64.tar.gz"
aws s3 cp ./build/ s3://${{ secrets.DEPENDENCY_BUCKET_NAME }}/x86-64/ --recursive --exclude "*" --include "finch.${GITHUB_REF_NAME}.x86_64.tar.gz"
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-20230317205128.qcow2
LIMA_URL ?= https://deps.runfinch.com/aarch64/lima-and-qemu.macos-aarch64.1678826933.tar.gz
FINCH_OS_BASENAME ?= Fedora-Cloud-Base-37-1.7.aarch64-20230321224649.qcow2
LIMA_URL ?= https://deps.runfinch.com/aarch64/lima-and-qemu.macos-aarch64.1679936560.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-20230317204632.qcow2
LIMA_URL ?= https://deps.runfinch.com/x86-64/lima-and-qemu.macos-x86_64.1678817277.tar.gz
FINCH_OS_BASENAME ?= Fedora-Cloud-Base-37-1.7.x86_64-20230321224635.qcow2
LIMA_URL ?= https://deps.runfinch.com/x86-64/lima-and-qemu.macos-x86_64.1679936560.tar.gz
endif

FINCH_OS_HASH := `shasum -a 256 $(OUTDIR)/os/$(FINCH_OS_BASENAME) | cut -d ' ' -f 1`
Expand Down
11 changes: 11 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,17 @@ memory: 4GiB
additional_directories:
# the path of each additional directory.
- path: /Volumes
# vmType (Experimental): sets which Hypervisor to use to launch the VM. (optional)
# Only takes effect when a new VM is launched (only on vm init).
# One of: "qemu", "vz".
# - "qemu" (default): Uses QEMU as the Hypervisor.
# - "vz": Uses Virtualization.framework as the Hypervisor.
vmType: "qemu"
# rosetta (Experimental): sets whether to enable Rosetta as the binfmt_misc handler inside the VM. (optional)
# Only takes effect when a new VM is launched (only on vm init).
# Only available when using vmType "vz" on Apple Silicon running macOS 13+.
# If true, also sets vmType to "vz".
rosetta: false
```
### FAQ
Expand Down
4 changes: 2 additions & 2 deletions cmd/finch/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -116,11 +116,11 @@ func virtualMachineCommands(
lcc,
logger,
optionalDepGroups,
config.NewLimaApplier(fc, fs, fp.LimaOverrideConfigPath()),
config.NewLimaApplier(fc, ecc, fs, fp.LimaOverrideConfigPath(), system.NewStdLib()),
config.NewNerdctlApplier(fssh.NewDialer(), fs, fp.LimaSSHPrivateKeyPath(), stdLib.Env("USER")),
fp,
fs,
disk.NewUserDataDiskManager(lcc, &afero.OsFs{}, fp, stdLib.Env("HOME")),
disk.NewUserDataDiskManager(lcc, ecc, &afero.OsFs{}, fp, system.NewStdLib().Env("HOME"), fc),
)
}

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 @@ -81,7 +81,7 @@ func (iva *initVMAction) run() error {
iva.logger.Errorf("Dependency error: %v", err)
}

err = iva.limaConfigApplier.Apply()
err = iva.limaConfigApplier.Apply(true)
if err != nil {
return err
}
Expand Down
Loading

0 comments on commit ebba98a

Please sign in to comment.