Skip to content
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
13 changes: 5 additions & 8 deletions .github/workflows/build_and_test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ jobs:
path: /tmp/*.iso
key: ${{ env.cache-name }}-${{ hashFiles('Dockerfile', '**/go.sum', '**/pkg/**', '**/examples/**', '**/cmd/**', '**/vendor/**', '**/Makefile', '**/main.go') }}
enableCrossOsArchive: true

build-disk:
runs-on: ubuntu-latest
env:
Expand Down Expand Up @@ -98,7 +98,7 @@ jobs:
enableCrossOsArchive: true

tests-matrix:
needs:
needs:
- build-disk
runs-on: ubuntu-latest
env:
Expand All @@ -115,9 +115,6 @@ jobs:
uses: actions/setup-go@v3
with:
go-version-file: go.mod
- name: Install deps
run: |
make test-deps
- run: |
git fetch --prune --unshallow
- name: Cached Disk
Expand All @@ -133,16 +130,16 @@ jobs:
- name: Enable KVM group perms
run: |
sudo apt-get update
sudo apt-get install qemu qemu-utils ovmf qemu-system-x86
sudo apt-get install qemu-utils ovmf qemu-system-x86
echo 'KERNEL=="kvm", GROUP="kvm", MODE="0666", OPTIONS+="static_node=kvm"' | sudo tee /etc/udev/rules.d/99-kvm4all.rules
sudo udevadm control --reload-rules
sudo udevadm trigger --name-match=kvm
- name: Run ${{ matrix.test }}
run: |
make DISK=/tmp/elemental-${{ env.FLAVOR }}.${{ env.ARCH}}.qcow2 ELMNTL_TARGETARCH=${{ env.ARCH }} ELMNTL_FIRMWARE=/usr/share/OVMF/OVMF_CODE.fd ${{ matrix.test }}
make DISK=/tmp/elemental-${{ env.FLAVOR }}.${{ env.ARCH}}.qcow2 ELMNTL_TARGETARCH=${{ env.ARCH }} ELMNTL_FIRMWARE=/usr/share/OVMF/OVMF_CODE_4M.fd ${{ matrix.test }}
# TODO include other logs SUT collects on failure
- name: Upload serial console for ${{ matrix.test }}
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
if: always()
with:
name: serial-${{ env.ARCH }}-${{ env.FLAVOR }}-${{ matrix.test }}.log
Expand Down
2 changes: 0 additions & 2 deletions .github/workflows/cli.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,6 @@ jobs:
args: -v
- name: Build
run: make build-cli
- name: Deps
run: make test-deps
- name: Run tests
run: |
make test-cli
Expand Down
3 changes: 2 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,12 @@ FROM golang:${GO_VERSION}-alpine as elemental-bin
ENV CGO_ENABLED=0
WORKDIR /src/

# needed for `go mod download`
RUN apk add git
# Add specific dirs to the image so cache is not invalidated when modifying non go files
ADD go.mod .
ADD go.sum .
ADD vendor vendor
RUN go mod download
ADD cmd cmd
ADD internal internal
ADD pkg pkg
Expand Down
2 changes: 1 addition & 1 deletion cmd/build-disk.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
Copyright © 2022 - 2024 SUSE LLC
Copyright © 2022 - 2025 SUSE LLC

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand Down
2 changes: 1 addition & 1 deletion cmd/build-iso.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
Copyright © 2022 - 2024 SUSE LLC
Copyright © 2022 - 2025 SUSE LLC

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand Down
2 changes: 1 addition & 1 deletion cmd/build-iso_test.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
Copyright © 2022 - 2024 SUSE LLC
Copyright © 2022 - 2025 SUSE LLC

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand Down
2 changes: 1 addition & 1 deletion cmd/cloud-init.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
Copyright © 2022 - 2024 SUSE LLC
Copyright © 2022 - 2025 SUSE LLC

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand Down
8 changes: 7 additions & 1 deletion cmd/config/config.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
Copyright © 2022 - 2024 SUSE LLC
Copyright © 2022 - 2025 SUSE LLC

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -33,6 +33,7 @@ import (
"k8s.io/mount-utils"

"github.com/rancher/elemental-toolkit/internal/version"

"github.com/rancher/elemental-toolkit/pkg/config"
"github.com/rancher/elemental-toolkit/pkg/constants"
v1 "github.com/rancher/elemental-toolkit/pkg/types/v1"
Expand Down Expand Up @@ -295,6 +296,11 @@ func ReadUpgradeSpec(r *v1.RunConfig, flags *pflag.FlagSet) (*v1.UpgradeSpec, er
r.Logger.Warnf("error unmarshalling UpgradeSpec: %s", err)
}
err = upgrade.Sanitize()
if err != nil {
return nil, fmt.Errorf("failed sanitizing upgrade spec: %v", err)
}

err = config.ReconcileUpgradeSpec(r, upgrade)
r.Logger.Debugf("Loaded upgrade UpgradeSpec: %s", litter.Sdump(upgrade))
return upgrade, err
}
Expand Down
6 changes: 2 additions & 4 deletions cmd/config/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,7 @@ var _ = Describe("Config", Label("config"), func() {

up, err := ReadUpgradeSpec(cfg, nil)
Expect(err).Should(HaveOccurred(), litter.Sdump(cfg))

Expect(up.GrubDefEntry).To(Equal("so"))
Expect(up.Active.Size).To(Equal(uint(2000)), litter.Sdump(up))
Expect(up).To(BeNil())

inst, err := ReadInstallSpec(cfg, nil)
Expect(err).Should(HaveOccurred(), litter.Sdump(cfg))
Expand Down Expand Up @@ -438,7 +436,7 @@ var _ = Describe("Config", Label("config"), func() {
ghwTest.CreateDevices()
defer ghwTest.Clean()

err := os.Setenv("ELEMENTAL_UPGRADE_RECOVERY", "true")
Expect(os.Setenv("ELEMENTAL_UPGRADE_RECOVERY", "true")).To(Succeed())
spec, err := ReadUpgradeSpec(cfg, nil)
Expect(err).ShouldNot(HaveOccurred())
// Overwrites recovery-system image, flags have priority over files and env vars
Expand Down
2 changes: 1 addition & 1 deletion cmd/flags.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
Copyright © 2022 - 2024 SUSE LLC
Copyright © 2022 - 2025 SUSE LLC

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand Down
2 changes: 1 addition & 1 deletion cmd/helpers.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
Copyright © 2022 - 2024 SUSE LLC
Copyright © 2022 - 2025 SUSE LLC

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand Down
2 changes: 1 addition & 1 deletion cmd/init.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
Copyright © 2022 - 2024 SUSE LLC
Copyright © 2022 - 2025 SUSE LLC

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand Down
2 changes: 1 addition & 1 deletion cmd/install.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
Copyright © 2022 - 2024 SUSE LLC
Copyright © 2022 - 2025 SUSE LLC

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand Down
2 changes: 1 addition & 1 deletion cmd/pull-image.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
Copyright © 2022 - 2024 SUSE LLC
Copyright © 2022 - 2025 SUSE LLC

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand Down
2 changes: 1 addition & 1 deletion cmd/pull-image_test.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
Copyright © 2022 - 2024 SUSE LLC
Copyright © 2022 - 2025 SUSE LLC

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand Down
2 changes: 1 addition & 1 deletion cmd/reset.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
Copyright © 2022 - 2024 SUSE LLC
Copyright © 2022 - 2025 SUSE LLC

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand Down
2 changes: 1 addition & 1 deletion cmd/root.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
Copyright © 2022 - 2024 SUSE LLC
Copyright © 2022 - 2025 SUSE LLC

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand Down
2 changes: 1 addition & 1 deletion cmd/run-stage.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
Copyright © 2022 - 2024 SUSE LLC
Copyright © 2022 - 2025 SUSE LLC

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand Down
2 changes: 1 addition & 1 deletion cmd/upgrade.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
Copyright © 2022 - 2024 SUSE LLC
Copyright © 2022 - 2025 SUSE LLC

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand Down
2 changes: 1 addition & 1 deletion cmd/upgrade_test.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
Copyright © 2022 - 2024 SUSE LLC
Copyright © 2022 - 2025 SUSE LLC

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand Down
2 changes: 1 addition & 1 deletion cmd/version.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
Copyright © 2022 - 2024 SUSE LLC
Copyright © 2022 - 2025 SUSE LLC

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand Down
2 changes: 1 addition & 1 deletion docs/generate_docs.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
Copyright © 2022 - 2024 SUSE LLC
Copyright © 2022 - 2025 SUSE LLC

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand Down
2 changes: 1 addition & 1 deletion internal/version/version.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
Copyright © 2022 - 2024 SUSE LLC
Copyright © 2022 - 2025 SUSE LLC

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand Down
2 changes: 1 addition & 1 deletion main.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
Copyright © 2022 - 2024 SUSE LLC
Copyright © 2022 - 2025 SUSE LLC

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand Down
30 changes: 13 additions & 17 deletions make/Makefile.test
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
GINKGO?=$(shell which ginkgo 2> /dev/null)
ifeq ("$(GINKGO)","")
GINKGO="$(HOME)/go/bin/ginkgo"
endif

GINKGO_ARGS?=-v --fail-fast -r --timeout=3h
GINKGO ?= "github.com/onsi/ginkgo/v2/ginkgo"
GINKGO_ARGS ?=-v --fail-fast -r --timeout=3h

.PHONY: prepare-test
prepare-test:
Expand All @@ -13,7 +9,7 @@ ifeq ("$(DISK)","")
endif
@scripts/run_vm.sh start $(DISK)
@echo "VM started from $(DISK)"
$(GINKGO) run $(GINKGO_ARGS) ./tests/wait-active
go run $(GINKGO) run $(GINKGO_ARGS) ./tests/wait-active

.PHONY: prepare-installer-test
prepare-installer-test:
Expand All @@ -31,27 +27,27 @@ test-clean:

.PHONY: test-smoke
test-smoke: prepare-test
$(GINKGO) run $(GINKGO_ARGS) ./tests/smoke
go run $(GINKGO) run $(GINKGO_ARGS) ./tests/smoke

.PHONY: test-grubfallback
test-grubfallback: prepare-test
$(GINKGO) run $(GINKGO_ARGS) ./tests/grubfallback
go run $(GINKGO) run $(GINKGO_ARGS) ./tests/grubfallback

.PHONY: test-recovery
test-recovery: prepare-test
$(GINKGO) run $(GINKGO_ARGS) ./tests/recovery
go run $(GINKGO) run $(GINKGO_ARGS) ./tests/recovery

.PHONY: test-fallback
test-fallback: prepare-test
$(GINKGO) run $(GINKGO_ARGS) ./tests/fallback
go run $(GINKGO) run $(GINKGO_ARGS) ./tests/fallback

.PHONY: test-fsck
test-fsck: prepare-test
$(GINKGO) run $(GINKGO_ARGS) ./tests/fsck
go run $(GINKGO) run $(GINKGO_ARGS) ./tests/fsck

.PHONY: test-upgrade
test-upgrade: prepare-test
$(GINKGO) run $(GINKGO_ARGS) ./tests/upgrade
go run $(GINKGO) run $(GINKGO_ARGS) ./tests/upgrade

.PHONY: test-deps
test-deps:
Expand All @@ -60,16 +56,16 @@ test-deps:
go install github.com/onsi/ginkgo/v2/ginkgo

.PHONY: test-cli
test-cli: $(GINKGO)
$(GINKGO) run --label-filter '!root' --fail-fast --race --covermode=atomic --coverprofile=coverage.txt --coverpkg=github.com/rancher/elemental-toolkit/... -p -r ${PKG}
test-cli:
go run $(GINKGO) run --label-filter '!root' --fail-fast --race --covermode=atomic --coverprofile=coverage.txt --coverpkg=github.com/rancher/elemental-toolkit/... -p -r ${PKG}

.PHONY: test-root
test-root: $(GINKGO)
test-root:
ifneq ($(shell id -u), 0)
@echo "This tests require root/sudo to run."
@exit 1
else
$(GINKGO) run --label-filter root --fail-fast --race --covermode=atomic --coverprofile=coverage_root.txt --coverpkg=github.com/rancher/elemental-toolkit/... -procs=1 -r ${PKG}
go run $(GINKGO) run --label-filter root --fail-fast --race --covermode=atomic --coverprofile=coverage_root.txt --coverpkg=github.com/rancher/elemental-toolkit/... -procs=1 -r ${PKG}
endif


2 changes: 1 addition & 1 deletion pkg/action/action_suite_test.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
Copyright © 2022 - 2024 SUSE LLC
Copyright © 2022 - 2025 SUSE LLC

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand Down
2 changes: 1 addition & 1 deletion pkg/action/build-disk.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
Copyright © 2022 - 2024 SUSE LLC
Copyright © 2022 - 2025 SUSE LLC

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand Down
2 changes: 1 addition & 1 deletion pkg/action/build-iso.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
Copyright © 2022 - 2024 SUSE LLC
Copyright © 2022 - 2025 SUSE LLC

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand Down
2 changes: 1 addition & 1 deletion pkg/action/build_test.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
Copyright © 2022 - 2024 SUSE LLC
Copyright © 2022 - 2025 SUSE LLC

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand Down
2 changes: 1 addition & 1 deletion pkg/action/common.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
Copyright © 2022 - 2024 SUSE LLC
Copyright © 2022 - 2025 SUSE LLC

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand Down
2 changes: 1 addition & 1 deletion pkg/action/init.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
Copyright © 2022 - 2024 SUSE LLC
Copyright © 2022 - 2025 SUSE LLC

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand Down
2 changes: 1 addition & 1 deletion pkg/action/init_test.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
Copyright © 2022 - 2024 SUSE LLC
Copyright © 2022 - 2025 SUSE LLC

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand Down
2 changes: 1 addition & 1 deletion pkg/action/install.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
Copyright © 2022 - 2024 SUSE LLC
Copyright © 2022 - 2025 SUSE LLC

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand Down
2 changes: 1 addition & 1 deletion pkg/action/install_test.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
Copyright © 2022 - 2024 SUSE LLC
Copyright © 2022 - 2025 SUSE LLC

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand Down
2 changes: 1 addition & 1 deletion pkg/action/reset.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
Copyright © 2022 - 2024 SUSE LLC
Copyright © 2022 - 2025 SUSE LLC

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand Down
Loading
Loading