Add CI build & tests

test: Prepare for using in GH CI
test/approvals: Add approvals for CI
.github/workflows/tests.yml: Add CI workflow for testing dcuc

Signed-off-by: Filip Gołaś <filip.golas@3mdeb.com>
This commit is contained in:
Filip Gołaś
2024-10-14 13:46:59 +02:00
committed by Filip Gołaś
parent 1b47518bd7
commit ac6ec86efb
51 changed files with 12821 additions and 16 deletions

28
.github/workflows/tests.yml vendored Normal file
View File

@@ -0,0 +1,28 @@
name: CI
on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]
workflow_dispatch:
jobs:
Tests:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: build
uses: addnab/docker-run-action@v3
with:
image: dannyben/bashly
options: --rm -v ${{ github.workspace }}:/app
run: bashly generate
- name: tests
uses: addnab/docker-run-action@v3
with:
image: ghcr.io/dasharo/dasharo-sdk:v1.5.0
options: --rm -v ${{ github.workspace }}:/dcu
run: |
cd dcu
test/approve-ci

8
dcu
View File

@@ -354,8 +354,8 @@ dcu_mac_command() {
fi
fi
"${NVMTOOL}" "$GBE_FLASHREGION_PATH" setmac "${_mac}" 1> /dev/null || { cleanup; return 23; }
"${IFDTOOL}" -i gbe:"$GBE_FLASHREGION_PATH" "${DASHARO_ROM}" 1> /dev/null || { cleanup; return 23; }
"${NVMTOOL}" "$GBE_FLASHREGION_PATH" setmac "${_mac}" 1> /dev/null || { cleanup; return 22; }
"${IFDTOOL}" -i gbe:"$GBE_FLASHREGION_PATH" "${DASHARO_ROM}" 1> /dev/null || { cleanup; return 21; }
echo "Moving ${DASHARO_ROM}.new to ${DASHARO_ROM}"
mv "${DASHARO_ROM}.new" "${DASHARO_ROM}" -f
echo "Success"
@@ -364,7 +364,7 @@ dcu_mac_command() {
get_mac() {
# dump sections
"${NVMTOOL}" "$GBE_FLASHREGION_PATH" dump
echo "Success"
}
init() {
@@ -518,7 +518,7 @@ dcu_logo_command() {
fi
echo "Setting ${LOGO_FILE} as custom logo"
convert -background None ${LOGO_FILE} BMP3:/tmp/logo.bmp
convert -background None ${LOGO_FILE} BMP3:/tmp/logo.bmp &> /dev/null
# We do not care if this one fails. It can fail if serial_number is not
# already, there, which is fine.
"${CBFSTOOL}" "${DASHARO_ROM}" remove -n logo.bmp -r BOOTSPLASH > /dev/null 2> /dev/null || true

6
dcuc
View File

@@ -34,4 +34,8 @@ for ARG in "$@"; do
fi
done
docker run -t --rm -v "${SCRIPT_DIR}:${SCRIPT_DIR}" "${DOCKER_ARGS[@]}" -w "${SCRIPT_DIR}" $DOCKER_IMAGE ./dcu "${COMMAND_ARGS[@]}"
if [[ -v CI ]]; then
../dcu "${COMMAND_ARGS[@]}"
else
docker run -t --rm -v "${SCRIPT_DIR}:${SCRIPT_DIR}" "${DOCKER_ARGS[@]}" -w "${SCRIPT_DIR}" $DOCKER_IMAGE ./dcu "${COMMAND_ARGS[@]}"
fi

View File

@@ -24,7 +24,7 @@ if ! "${CBFSTOOL}" "${DASHARO_ROM}" layout -w | grep -q "BOOTSPLASH"; then
fi
echo "Setting ${LOGO_FILE} as custom logo"
convert -background None ${LOGO_FILE} BMP3:/tmp/logo.bmp
convert -background None ${LOGO_FILE} BMP3:/tmp/logo.bmp &> /dev/null
# We do not care if this one fails. It can fail if serial_number is not
# already, there, which is fine.
"${CBFSTOOL}" "${DASHARO_ROM}" remove -n logo.bmp -r BOOTSPLASH > /dev/null 2> /dev/null || true

View File

@@ -32,7 +32,12 @@ approve() {
return
fi
<<<<<<< HEAD
if [[ "$(printf "%b" "$actual")" = "$(printf "%b" "$expected")" ]]; then
=======
$diff_cmd <(printf "%b" "$expected\n") <(printf "%b" "$actual\n") &> /dev/null && true
if [[ $? == 0 ]]; then
>>>>>>> dd9111f1f354 (ci fixes)
pass "$cmd"
else
printf -- "$changed_diff_string\n" "$cmd"
@@ -166,7 +171,7 @@ changed_diff_string="────┤ $(blue changed): $(bold %s) ├────
approval_string="[A]pprove? "
if diff --help | grep -- --color >/dev/null 2>&1; then
diff_cmd="diff --unified --color=always"
diff_cmd="diff --unified --strip-trailing-cr -wB --color=always"
else
diff_cmd="diff --unified"
diff_cmd="diff --unified --strip-trailing-cr -wB"
fi

25
test/approvals/_dcu_help Normal file
View File

@@ -0,0 +1,25 @@
dcu - Dasharo Configuration Utility
Usage:
dcu COMMAND
dcu [COMMAND] --help | -h
dcu --version | -v
Commands:
mac Get/set MAC address in a firmware image
smbios Edit SMBIOS data in a firmware image
logo Insert custom logo boot splash into firmware image
variable Edit Dasharo configuration variables
Options:
--help, -h
Show this help
--version, -v
Show version number
Examples:
dcu setmac coreboot.rom 12:34:45:56:78:9A
dcu smbios coreboot.rom -u 96bcfa1a-42b4-6717-a44c-d8bbc18cbea4 -s D07229051
dcu logo coreboot.rom -l bootsplash.bmp
dcu variable coreboot.rom --get EnableWifiBt

View File

@@ -0,0 +1,2 @@
Setting ./data/work/bootsplash.bmp as custom logo
Success

View File

@@ -0,0 +1 @@
Invalid or unsupported logo file format

View File

@@ -0,0 +1,2 @@
BOOTSPLASH region not found
Customizable logo not supported by the ./data/work/protectli_vault_kbl_v1.0.14.rom image

View File

@@ -0,0 +1,22 @@
Using */data/work/novacustom_v540tu_mtl_v0.9.0_gbe.rom
Part 0:
MAC: 12:34:56:78:9a:bc
0000000 3412 7856 bc9a 0801 ffff 1014 0001 0084
0000010 ffff ffff 10c3 0000 8086 550a 0000 0000
0000020 0000 0000 8000 a705 3030 1600 0000 0c00
0000030 18f4 0a02 0843 0113 550a baad 550a 550b
0000040 baad 550a baad 550a 0000 8000 4e00 0886
0000050 0000 0000 0007 a000 0020 0000 0e00 0000
0000060 0100 4000 1228 4007 ffff ffff ffff ffff
0000070 ffff ffff ffff ffff ffff 0200 ffff ba41
Part 1:
MAC: 12:34:56:78:9a:bc
0000000 3412 7856 bc9a 0801 ffff 1014 0001 0084
0000010 ffff ffff 10c3 0000 8086 550a 0000 0000
0000020 0000 0000 8000 a705 3030 1600 0000 0c00
0000030 18f4 0a02 0843 0113 550a baad 550a 550b
0000040 baad 550a baad 550a 0000 8000 4e00 0886
0000050 0000 0000 0007 a000 0020 0000 0e00 0000
0000060 0100 4000 1228 4007 ffff ffff ffff ffff
0000070 ffff ffff ffff ffff ffff 0200 ffff ba41
Success

View File

@@ -0,0 +1,4 @@
Using */data/work/novacustom_v540tu_mtl_v0.9.0_gbe.rom
Copying region 0 to region 1
Bad MAC address
Operation canceled

View File

@@ -0,0 +1,5 @@
Using */data/work/novacustom_v540tu_mtl_v0.9.0_gbe.rom
Copying region 0 to region 1
Warning: No platform specified. Output may be incomplete
Moving */data/work/novacustom_v540tu_mtl_v0.9.0_gbe.rom.new to */data/work/novacustom_v540tu_mtl_v0.9.0_gbe.rom
Success

View File

@@ -0,0 +1,23 @@
Using */data/work/novacustom_v540tu_mtl_v0.9.0.rom
BAD checksum in part 0
BAD checksum in part 1
Part 0:
MAC: ff:ff:ff:ff:ff:ff
0000000 ffff ffff ffff ffff ffff ffff ffff ffff
0000010 ffff ffff ffff ffff ffff ffff ffff ffff
0000020 ffff ffff ffff ffff ffff ffff ffff ffff
0000030 ffff ffff ffff ffff ffff ffff ffff ffff
0000040 ffff ffff ffff ffff ffff ffff ffff ffff
0000050 ffff ffff ffff ffff ffff ffff ffff ffff
0000060 ffff ffff ffff ffff ffff ffff ffff ffff
0000070 ffff ffff ffff ffff ffff ffff ffff ffff
Part 1:
MAC: ff:ff:ff:ff:ff:ff
0000000 ffff ffff ffff ffff ffff ffff ffff ffff
0000010 ffff ffff ffff ffff ffff ffff ffff ffff
0000020 ffff ffff ffff ffff ffff ffff ffff ffff
0000030 ffff ffff ffff ffff ffff ffff ffff ffff
0000040 ffff ffff ffff ffff ffff ffff ffff ffff
0000050 ffff ffff ffff ffff ffff ffff ffff ffff
0000060 ffff ffff ffff ffff ffff ffff ffff ffff
0000070 ffff ffff ffff ffff ffff ffff ffff ffff

View File

@@ -0,0 +1,8 @@
Using */data/work/novacustom_v540tu_mtl_v0.9.0.rom
BAD checksum in part 0
Operation canceled
Failed to copy region 0 to region 1
BAD checksum in part 1
Operation canceled
Failed to copy region 1 to region 0
Both regions are invalid, aborting

View File

@@ -0,0 +1,2 @@
Using */data/work/protectli_vault_cml_v1.2.0-rc1_vp46xx.rom
Managing the MAC address in this binary is currently not supported

View File

@@ -0,0 +1,3 @@
Will modify ./data/work/novacustom_nv4x_adl_v1.6.0.rom
Configurable Serial Number not supported by the coreboot image

View File

@@ -0,0 +1,3 @@
Will modify ./data/work/novacustom_nv4x_adl_v1.6.0.rom
Configurable UUID not supported by the coreboot image

View File

@@ -0,0 +1,3 @@
Will modify ./data/work/novacustom_nv4x_adl_v1.6.0.rom
Configurable UUID not supported by the coreboot image

View File

@@ -0,0 +1,4 @@
Will modify ./data/work/protectli_vault_cml_v1.2.0-rc1_vp46xx.rom
Setting Serial Number to D07229051
Success

View File

@@ -0,0 +1,6 @@
Will modify ./data/work/protectli_vault_cml_v1.2.0-rc1_vp46xx.rom
Setting System UUID to 96bcfa1a-42b4-6717-a44c-d8bbc18cbea4
Success
Setting Serial Number to D07229051
Success

Some files were not shown because too many files have changed in this diff Show More