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

build: make finch-core a submodule instead of downloading archives #188

Merged
merged 4 commits into from
Jan 26, 2023
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
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"]
vsiravar marked this conversation as resolved.
Show resolved Hide resolved
path = deps/finch-core
url = https://github.com/runfinch/finch-core.git
8 changes: 7 additions & 1 deletion 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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is it worth adding a note to tell users to run git submodule update --init if they cloned without --recurse-submodules? the error when you try to build without submodules is a bit obtuse:

go build -ldflags "-X github.com/runfinch/finch/pkg/version.Version=903a1d4 -X github.com/runfinch/finch/pkg/version.GitCommit=903a1d49aa0a41bef7bac8160a42ec995b69d629" -o /Users/bernings/scratch/runfinch/finch-test/_output/bin/finch github.com/runfinch/finch/cmd/finch
cd deps/finch-core && \
		FINCH_OS_x86_URL="" \
		FINCH_OS_AARCH64_URL="" \
		VDE_TEMP_PREFIX=/Users/bernings/scratch/runfinch/finch-test/_output/dependencies/vde/opt/finch \
		/Library/Developer/CommandLineTools/usr/bin/make
make[1]: *** No targets specified and no makefile found.  Stop.
make: *** [finch-core] Error 2

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I mentioned it in another comment on this PR, but we can also add it to README.md or CONTRIBUTING.md, wdyt is more appropriate?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think CONTRIBUTING.md makes more sense. Honestly, it might be worth adding the note right below this line and before the make command.

```

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
18 changes: 4 additions & 14 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 @@ -292,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