Skip to content

Commit

Permalink
Add FreeBSD in CI
Browse files Browse the repository at this point in the history
  • Loading branch information
quantumsheep committed May 9, 2023
1 parent 76c81a1 commit 51659d6
Show file tree
Hide file tree
Showing 2 changed files with 91 additions and 0 deletions.
31 changes: 31 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ jobs:
flags: unit,os_linux
fail_ci_if_error: true
verbose: true

test-linux-arm64:
runs-on: linux-arm64
steps:
Expand All @@ -48,6 +49,31 @@ jobs:
run: |
make format || true
make test
test-freebsd-amd64:
runs-on: macos-latest
steps:
- uses: actions/checkout@v2
- name: Set up go
uses: actions/setup-go@v3
with:
go-version-file: 'go.mod'
- name: Test in FreeBSD
id: test
uses: vmactions/freebsd-vm@v0
with:
usesh: true
prepare: |
wget https://go.dev/dl/go1.20.4.freebsd-amd64.tar.gz
tar -C /usr/local -xzf go1.20.4.freebsd-amd64.tar.gz
export GOROOT=/usr/local/go
export GOPATH=/usr/local/gopath
export PATH=$PATH:$GOPATH/bin
run: |
make format || true
make test
test-windows:
runs-on: windows-2019
steps:
Expand Down Expand Up @@ -99,6 +125,7 @@ jobs:
needs:
- test-linux-amd64
- test-linux-arm64
- test-freebsd-amd64
- test-windows
runs-on: ubuntu-latest
steps:
Expand Down Expand Up @@ -148,6 +175,10 @@ jobs:
with:
name: lifecycle-linux-arm64-sha256
path: out/lifecycle-v*+linux.arm64.tgz.sha256
- uses: actions/upload-artifact@v2
with:
name: lifecycle-freebsd-x86-64
path: out/lifecycle-v*+freebsd.x86-64.tgz
- uses: actions/upload-artifact@v2
with:
name: lifecycle-windows-x86-64
Expand Down
60 changes: 60 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ build: build-linux-amd64 build-linux-arm64 build-windows-amd64

build-linux-amd64: build-linux-amd64-lifecycle build-linux-amd64-symlinks build-linux-amd64-launcher
build-linux-arm64: build-linux-arm64-lifecycle build-linux-arm64-symlinks build-linux-arm64-launcher
build-freebsd-amd64: build-freebsd-amd64-lifecycle build-freebsd-amd64-symlinks build-freebsd-amd64-launcher
build-windows-amd64: build-windows-amd64-lifecycle build-windows-amd64-symlinks build-windows-amd64-launcher

build-image-linux-amd64: build-linux-amd64 package-linux-amd64
Expand All @@ -55,6 +56,11 @@ build-image-linux-arm64: ARCHIVE_PATH=$(BUILD_DIR)/lifecycle-v$(LIFECYCLE_VERSIO
build-image-linux-arm64:
$(GOCMD) run ./tools/image/main.go -daemon -lifecyclePath $(ARCHIVE_PATH) -os linux -arch arm64 -tag lifecycle:$(LIFECYCLE_IMAGE_TAG)

build-image-freebsd-amd64: build-freebsd-amd64 package-freebsd-amd64
build-image-freebsd-amd64: ARCHIVE_PATH=$(BUILD_DIR)/lifecycle-v$(LIFECYCLE_VERSION)+freebsd.x86-64.tgz
build-image-freebsd-amd64:
$(GOCMD) run ./tools/image/main.go -daemon -lifecyclePath $(ARCHIVE_PATH) -os freebsd -arch amd64 -tag lifecycle:$(LIFECYCLE_IMAGE_TAG)

build-image-windows-amd64: build-windows-amd64 package-windows-amd64
build-image-windows-amd64: ARCHIVE_PATH=$(BUILD_DIR)/lifecycle-v$(LIFECYCLE_VERSION)+windows.x86-64.tgz
build-image-windows-amd64:
Expand All @@ -64,6 +70,8 @@ build-linux-amd64-lifecycle: $(BUILD_DIR)/linux-amd64/lifecycle/lifecycle

build-linux-arm64-lifecycle: $(BUILD_DIR)/linux-arm64/lifecycle/lifecycle

build-freebsd-amd64-lifecycle: $(BUILD_DIR)/freebsd-amd64/lifecycle/lifecycle

$(BUILD_DIR)/linux-amd64/lifecycle/lifecycle: export GOOS:=linux
$(BUILD_DIR)/linux-amd64/lifecycle/lifecycle: export GOARCH:=amd64
$(BUILD_DIR)/linux-amd64/lifecycle/lifecycle: OUT_DIR?=$(BUILD_DIR)/$(GOOS)-$(GOARCH)/lifecycle
Expand All @@ -82,6 +90,15 @@ $(BUILD_DIR)/linux-arm64/lifecycle/lifecycle:
mkdir -p $(OUT_DIR)
$(GOENV) $(GOBUILD) -o $(OUT_DIR)/lifecycle -a ./cmd/lifecycle

$(BUILD_DIR)/freebsd-amd64/lifecycle/lifecycle: export GOOS:=freebsd
$(BUILD_DIR)/freebsd-amd64/lifecycle/lifecycle: export GOARCH:=amd64
$(BUILD_DIR)/freebsd-amd64/lifecycle/lifecycle: OUT_DIR?=$(BUILD_DIR)/$(GOOS)-$(GOARCH)/lifecycle
$(BUILD_DIR)/freebsd-amd64/lifecycle/lifecycle: $(GOFILES)
$(BUILD_DIR)/freebsd-amd64/lifecycle/lifecycle:
@echo "> Building lifecycle/lifecycle for $(GOOS)/$(GOARCH)..."
mkdir -p $(OUT_DIR)
$(GOENV) $(GOBUILD) -o $(OUT_DIR)/lifecycle -a ./cmd/lifecycle

build-linux-amd64-launcher: $(BUILD_DIR)/linux-amd64/lifecycle/launcher

$(BUILD_DIR)/linux-amd64/lifecycle/launcher: export GOOS:=linux
Expand All @@ -106,6 +123,18 @@ $(BUILD_DIR)/linux-arm64/lifecycle/launcher:
$(GOENV) $(GOBUILD) -o $(OUT_DIR)/launcher -a ./cmd/launcher
test $$(du -m $(OUT_DIR)/launcher|cut -f 1) -le 3

build-freebsd-amd64-launcher: $(BUILD_DIR)/freebsd-amd64/lifecycle/launcher

$(BUILD_DIR)/freebsd-amd64/lifecycle/launcher: export GOOS:=freebsd
$(BUILD_DIR)/freebsd-amd64/lifecycle/launcher: export GOARCH:=amd64
$(BUILD_DIR)/freebsd-amd64/lifecycle/launcher: OUT_DIR?=$(BUILD_DIR)/$(GOOS)-$(GOARCH)/lifecycle
$(BUILD_DIR)/freebsd-amd64/lifecycle/launcher: $(GOFILES)
$(BUILD_DIR)/freebsd-amd64/lifecycle/launcher:
@echo "> Building lifecycle/launcher for $(GOOS)/$(GOARCH)..."
mkdir -p $(OUT_DIR)
$(GOENV) $(GOBUILD) -o $(OUT_DIR)/launcher -a ./cmd/launcher
test $$(du -m $(OUT_DIR)/launcher|cut -f 1) -le 3

build-linux-amd64-symlinks: export GOOS:=linux
build-linux-amd64-symlinks: export GOARCH:=amd64
build-linux-amd64-symlinks: OUT_DIR?=$(BUILD_DIR)/$(GOOS)-$(GOARCH)/lifecycle
Expand Down Expand Up @@ -134,6 +163,20 @@ build-linux-arm64-symlinks:
ln -sf lifecycle $(OUT_DIR)/creator
ln -sf lifecycle $(OUT_DIR)/extender

build-freebsd-amd64-symlinks: export GOOS:=freebsd
build-freebsd-amd64-symlinks: export GOARCH:=amd64
build-freebsd-amd64-symlinks: OUT_DIR?=$(BUILD_DIR)/$(GOOS)-$(GOARCH)/lifecycle
build-freebsd-amd64-symlinks:
@echo "> Creating phase symlinks for $(GOOS)/$(GOARCH)..."
ln -sf lifecycle $(OUT_DIR)/detector
ln -sf lifecycle $(OUT_DIR)/analyzer
ln -sf lifecycle $(OUT_DIR)/restorer
ln -sf lifecycle $(OUT_DIR)/builder
ln -sf lifecycle $(OUT_DIR)/exporter
ln -sf lifecycle $(OUT_DIR)/rebaser
ln -sf lifecycle $(OUT_DIR)/creator
ln -sf lifecycle $(OUT_DIR)/extender

build-windows-amd64-lifecycle: $(BUILD_DIR)/windows-amd64/lifecycle/lifecycle.exe

$(BUILD_DIR)/windows-amd64/lifecycle/lifecycle.exe: export GOOS:=windows
Expand Down Expand Up @@ -239,6 +282,14 @@ run-syft-linux-arm64:
syft $(BUILD_DIR)/$(GOOS)-$(GOARCH)/lifecycle/lifecycle -o json=$(BUILD_DIR)/$(GOOS)-$(GOARCH)/lifecycle/lifecycle.sbom.syft.json -o spdx-json=$(BUILD_DIR)/$(GOOS)-$(GOARCH)/lifecycle/lifecycle.sbom.spdx.json -o cyclonedx-json=$(BUILD_DIR)/$(GOOS)-$(GOARCH)/lifecycle/lifecycle.sbom.cdx.json
syft $(BUILD_DIR)/$(GOOS)-$(GOARCH)/lifecycle/launcher -o json=$(BUILD_DIR)/$(GOOS)-$(GOARCH)/lifecycle/launcher.sbom.syft.json -o spdx-json=$(BUILD_DIR)/$(GOOS)-$(GOARCH)/lifecycle/launcher.sbom.spdx.json -o cyclonedx-json=$(BUILD_DIR)/$(GOOS)-$(GOARCH)/lifecycle/launcher.sbom.cdx.json

run-syft-freebsd-amd64: install-syft
run-syft-freebsd-amd64: export GOOS:=freebsd
run-syft-freebsd-amd64: export GOARCH:=amd64
run-syft-freebsd-amd64:
@echo "> Running syft..."
syft $(BUILD_DIR)/$(GOOS)-$(GOARCH)/lifecycle/lifecycle -o json=$(BUILD_DIR)/$(GOOS)-$(GOARCH)/lifecycle/lifecycle.sbom.syft.json -o spdx-json=$(BUILD_DIR)/$(GOOS)-$(GOARCH)/lifecycle/lifecycle.sbom.spdx.json -o cyclonedx-json=$(BUILD_DIR)/$(GOOS)-$(GOARCH)/lifecycle/lifecycle.sbom.cdx.json
syft $(BUILD_DIR)/$(GOOS)-$(GOARCH)/lifecycle/launcher -o json=$(BUILD_DIR)/$(GOOS)-$(GOARCH)/lifecycle/launcher.sbom.syft.json -o spdx-json=$(BUILD_DIR)/$(GOOS)-$(GOARCH)/lifecycle/launcher.sbom.spdx.json -o cyclonedx-json=$(BUILD_DIR)/$(GOOS)-$(GOARCH)/lifecycle/launcher.sbom.cdx.json

install-syft:
@echo "> Installing syft..."
curl -sSfL https://raw.githubusercontent.com/anchore/syft/main/install.sh | sh -s -- -b /usr/local/bin
Expand Down Expand Up @@ -320,6 +371,15 @@ package-linux-arm64:
@echo "> Packaging lifecycle for $(GOOS)/$(GOARCH)..."
$(GOCMD) run $(PACKAGER) --inputDir $(INPUT_DIR) -archivePath $(ARCHIVE_PATH) -descriptorPath $(LIFECYCLE_DESCRIPTOR_PATH) -version $(LIFECYCLE_VERSION)

package-freebsd-amd64: GOOS:=freebsd
package-freebsd-amd64: GOARCH:=amd64
package-freebsd-amd64: INPUT_DIR:=$(BUILD_DIR)$/$(GOOS)-$(GOARCH)$/lifecycle
package-freebsd-amd64: ARCHIVE_PATH=$(BUILD_DIR)$/lifecycle-v$(LIFECYCLE_VERSION)+$(GOOS).x86-64.tgz
package-freebsd-amd64: PACKAGER=.$/tools$/packager$/main.go
package-freebsd-amd64:
@echo "> Packaging lifecycle for $(GOOS)/$(GOARCH)..."
$(GOCMD) run $(PACKAGER) --inputDir $(INPUT_DIR) -archivePath $(ARCHIVE_PATH) -descriptorPath $(LIFECYCLE_DESCRIPTOR_PATH) -version $(LIFECYCLE_VERSION)

package-windows-amd64: GOOS:=windows
package-windows-amd64: GOARCH:=amd64
package-windows-amd64: INPUT_DIR:=$(BUILD_DIR)$/$(GOOS)-$(GOARCH)$/lifecycle
Expand Down

0 comments on commit 51659d6

Please sign in to comment.