Skip to content

Commit ac2cd4a

Browse files
Merge pull request #69 from nable-backup/release/2.9-8-cove
BCF-6382: Merge release/2.9-8-cove to master
2 parents e8e5cf9 + 3382487 commit ac2cd4a

15 files changed

Lines changed: 734 additions & 11 deletions

Jenkinsfile

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@ import nable.cove.helpers.ShellHelper
33
import nable.cove.SecretManager
44

55
final String jobName = env.JOB_NAME.split('/')[-2]
6-
final String branchName = env.CHANGE_BRANCH ?: env.BRANCH_NAME
6+
final String branchName = env.CHANGE_TARGET ?: env.BRANCH_NAME
77
final boolean isProd = jobName.endsWith('-prd')
8-
final boolean isProdBranch = branchName == 'master' || branchName.startsWith('release')
8+
final boolean isProdBranch = branchName == 'master'
99
final String envType = isProd ? 'prd' : 'dev'
1010

1111
def String repositoryName = 'rear'
@@ -55,8 +55,10 @@ pipeline {
5555
steps {
5656
script {
5757
if (isProd != isProdBranch) {
58-
echo "Environment mismatch: isProd=${isProd}, isProdBranch=${isProdBranch}. Skipping build."
58+
echo "Environment mismatch: target branch is ${branchName}, job is ${jobName}. Skipping build."
5959
shouldBuild = false
60+
} else {
61+
echo "Environment match: target branch is ${branchName}, job is ${jobName}. Proceeding with build."
6062
}
6163

6264
secretManager = new SecretManager(

Makefile

Lines changed: 25 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -34,12 +34,22 @@ else
3434
git_date := $(shell git log -n 1 --format="%ai")
3535
git_ref := $(shell git rev-parse HEAD | cut -c 1-8)
3636
git_count := $(shell git rev-list HEAD --no-merges | wc -l)
37-
git_branch_suffix = $(shell echo "$${CHANGE_BRANCH:-$${BRANCH_NAME:-$$(git symbolic-ref HEAD || echo unknown)}}" | sed -e 's,^.*/,,' -e "s/[^A-Za-z0-9]//g")
37+
git_branch_name = $(shell echo "$${CHANGE_BRANCH:-$${BRANCH_NAME:-$$(git symbolic-ref HEAD || echo unknown)}}")
38+
git_branch_suffix = $(shell echo "$(git_branch_name)" | sed -e 's,^.*/,,' -e "s/[^A-Za-z0-9]//g")
39+
cove_suffix = $(git_branch_suffix)
40+
release_suffix = $(shell echo "$(git_branch_name)" | sed -nE 's/^.*?release\/([0-9.-]*-cove).*/\1/p')
41+
ifneq ($(release_suffix),)
42+
cove_suffix = $(release_suffix)
43+
endif
44+
feature_suffix = $(shell echo "$(git_branch_name)" | sed -nE 's/^.*?(feature|hotfix)\/([A-Za-z0-9_-]+-[0-9]+).*/\2/p')
45+
ifneq ($(feature_suffix),)
46+
cove_suffix = $(feature_suffix)
47+
endif
3848
git_status := $(shell git status --porcelain)
39-
git_stamp := $(git_count).$(git_ref).$(git_branch_suffix)
4049
ifneq ($(git_status),)
41-
git_stamp := $(git_stamp).changed
42-
endif # git_status
50+
changed_suffix = .changed
51+
endif
52+
git_stamp := $(git_count).$(git_ref).$(git_branch_suffix)
4353
else # no git
4454
git_date := now
4555
git_ref := 0
@@ -50,9 +60,17 @@ else
5060
endif # has .git
5161
git_stamp ?= 0.0.unknown
5262

53-
distversion = $(version)-git.$(git_stamp)
54-
debrelease = 0git.$(git_stamp)
55-
rpmrelease = .git.$(git_stamp)
63+
ifneq ($(release_suffix),)
64+
distversion = $(cove_suffix)$(changed_suffix)
65+
else
66+
ifneq ($(feature_suffix),)
67+
distversion = $(version)-$(git_count).$(git_ref).$(cove_suffix)$(changed_suffix)
68+
else # is not release version
69+
distversion = $(version)-$(git_stamp)$(changed_suffix)
70+
endif
71+
endif # is release version
72+
debrelease = 0git.$(git_stamp)$(changed_suffix)
73+
rpmrelease = .git.$(git_stamp)$(changed_suffix)
5674
obsproject = Archiving:Backup:Rear:Snapshot
5775
obspackage = $(name)
5876

tests/COVE/000_save_future_dangling_efi_entries.bats

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
#!/usr/bin/env bats
2+
13
setup_file() {
24
export REAR_SHARE_DIR="$(realpath "$BATS_TEST_DIRNAME/../../usr/share/rear")"
35
export USING_UEFI_BOOTLOADER="yes"

tests/COVE/001_remove_dangling_efi_entries.bats

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
#!/usr/bin/env bats
2+
13
setup_file() {
24
export REAR_SHARE_DIR="$(realpath "$BATS_TEST_DIRNAME/../../usr/share/rear")"
35
export USING_UEFI_BOOTLOADER="yes"
Lines changed: 107 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,107 @@
1+
#!/usr/bin/env bats
2+
3+
#
4+
# Unit tests for upgrading Shim and GRUB bootloaders on Debian 10
5+
#
6+
7+
function setup_file() {
8+
REAR_SHARE_DIR="$(realpath "$BATS_TEST_DIRNAME/../../usr/share/rear")"
9+
export REAR_SHARE_DIR
10+
}
11+
12+
function setup() {
13+
# shellcheck disable=SC1091
14+
source "$REAR_SHARE_DIR/lib/global-functions.sh"
15+
16+
function LogPrint() {
17+
echo "$@"
18+
}
19+
20+
OS_VERSION=10
21+
USING_UEFI_BOOTLOADER=yes
22+
function is_cove_in_azure() {
23+
false
24+
}
25+
EFI_STUB=no
26+
UEFI_BOOTLOADER=/boot/efi/EFI/debian/shimx64.efi
27+
}
28+
29+
@test "Shim and GRUB are upgraded successfully" {
30+
function upgrade_bootloaders() {
31+
return 0
32+
}
33+
34+
run source "$REAR_SHARE_DIR/finalize/COVE/Debian/620_upgrade_bootloaders.sh"
35+
[ "$status" -eq 0 ]
36+
37+
local expected_output="Upgraded signed Shim and GRUB bootloaders for this system."
38+
[ "$output" = "$expected_output" ]
39+
}
40+
41+
@test "Failed to upgrade Shim and GRUB" {
42+
function upgrade_bootloaders() {
43+
return 1
44+
}
45+
46+
run source "$REAR_SHARE_DIR/finalize/COVE/Debian/620_upgrade_bootloaders.sh"
47+
[ "$status" -eq 0 ]
48+
49+
local expected_output="Failed to upgrade signed Shim and GRUB bootloaders for this system. UEFI Secure Boot might not be available."
50+
[ "$output" = "$expected_output" ]
51+
}
52+
53+
@test "Skip upgrading Shim and GRUB if the system is not Debian 10" {
54+
# shellcheck disable=SC2034
55+
OS_VERSION=11
56+
57+
run source "$REAR_SHARE_DIR/finalize/COVE/Debian/620_upgrade_bootloaders.sh"
58+
[ "$status" -eq 0 ]
59+
60+
local expected_output=""
61+
[ "$output" = "$expected_output" ]
62+
}
63+
64+
@test "Skip upgrading Shim and GRUB if the system is not EFI" {
65+
# shellcheck disable=SC2034
66+
USING_UEFI_BOOTLOADER=no
67+
68+
run source "$REAR_SHARE_DIR/finalize/COVE/Debian/620_upgrade_bootloaders.sh"
69+
[ "$status" -eq 0 ]
70+
71+
local expected_output=""
72+
[ "$output" = "$expected_output" ]
73+
}
74+
75+
@test "Skip upgrading Shim and GRUB on Azure" {
76+
function is_cove_in_azure() {
77+
true
78+
}
79+
80+
run source "$REAR_SHARE_DIR/finalize/COVE/Debian/620_upgrade_bootloaders.sh"
81+
[ "$status" -eq 0 ]
82+
83+
local expected_output=""
84+
[ "$output" = "$expected_output" ]
85+
}
86+
87+
@test "Skip upgrading Shim and GRUB if the system is EFI stub" {
88+
# shellcheck disable=SC2034
89+
EFI_STUB=yes
90+
91+
run source "$REAR_SHARE_DIR/finalize/COVE/Debian/620_upgrade_bootloaders.sh"
92+
[ "$status" -eq 0 ]
93+
94+
local expected_output=""
95+
[ "$output" = "$expected_output" ]
96+
}
97+
98+
@test "Skip upgrading Shim and GRUB if the bootloader is not shim" {
99+
# shellcheck disable=SC2034
100+
UEFI_BOOTLOADER=/boot/efi/EFI/debian/grubx64.efi
101+
102+
run source "$REAR_SHARE_DIR/finalize/COVE/Debian/620_upgrade_bootloaders.sh"
103+
[ "$status" -eq 0 ]
104+
105+
local expected_output=""
106+
[ "$output" = "$expected_output" ]
107+
}

0 commit comments

Comments
 (0)