FreeBSD fix and test (#55)

* add: test on freebsd

* test fix vm

* fix: transform to lowercase

transform the `OSTYPE` to a lowercase and store it inside `OSName`

* add: caching of the vm
This commit is contained in:
meo 2025-01-06 00:43:43 +01:00 committed by GitHub
parent bd8d447150
commit 393cbe2a12
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 34 additions and 7 deletions

View File

@ -26,3 +26,28 @@ jobs:
- name: Run testing script on macOS - name: Run testing script on macOS
run: ./testing.sh run: ./testing.sh
FreeBSDTest:
name: Test on FreeBSD
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Cache dependencies
uses: actions/cache@v3
with:
path: ~/.cache
key: ${{ runner.os }}-cache-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-cache-
- name: Test in FreeBSD
id: test
uses: vmactions/freebsd-vm@v1
with:
usesh: true
prepare: |
pkg install -y bash
run: |
./testing.sh

View File

@ -59,7 +59,7 @@ function rebalance() {
# this shouldn't be needed in the typical case of `find` only finding files with links == 1 # this shouldn't be needed in the typical case of `find` only finding files with links == 1
# but this can run for a long time, so it's good to double check if something changed # but this can run for a long time, so it's good to double check if something changed
if [[ "${skip_hardlinks_flag}" == "true"* ]]; then if [[ "${skip_hardlinks_flag}" == "true"* ]]; then
if [[ "${OSTYPE}" == "linux-gnu"* ]]; then if [[ "${OSName}" == "linux-gnu"* ]]; then
# Linux # Linux
# #
# -c --format=FORMAT # -c --format=FORMAT
@ -68,7 +68,7 @@ function rebalance() {
# %h number of hard links # %h number of hard links
hardlink_count=$(stat -c "%h" "${file_path}") hardlink_count=$(stat -c "%h" "${file_path}")
elif [[ "${OSTYPE}" == "darwin"* ]] || [[ "${OSTYPE}" == "freebsd"* ]]; then elif [[ "${OSName}" == "darwin"* ]] || [[ "${OSName}" == "freebsd"* ]]; then
# Mac OS # Mac OS
# FreeBSD # FreeBSD
# -f format # -f format
@ -108,7 +108,7 @@ function rebalance() {
tmp_file_path="${file_path}${tmp_extension}" tmp_file_path="${file_path}${tmp_extension}"
echo "Copying '${file_path}' to '${tmp_file_path}'..." echo "Copying '${file_path}' to '${tmp_file_path}'..."
if [[ "${OSTYPE}" == "linux-gnu"* ]]; then if [[ "${OSName}" == "linux-gnu"* ]]; then
# Linux # Linux
# --reflink=never -- force standard copy (see ZFS Block Cloning) # --reflink=never -- force standard copy (see ZFS Block Cloning)
@ -116,7 +116,7 @@ function rebalance() {
# -p -- preserve ACLs to # -p -- preserve ACLs to
# -x -- stay on one system # -x -- stay on one system
cp --reflink=never -ax "${file_path}" "${tmp_file_path}" cp --reflink=never -ax "${file_path}" "${tmp_file_path}"
elif [[ "${OSTYPE}" == "darwin"* ]] || [[ "${OSTYPE}" == "freebsd"* ]]; then elif [[ "${OSName}" == "darwin"* ]] || [[ "${OSName}" == "freebsd"* ]]; then
# Mac OS # Mac OS
# FreeBSD # FreeBSD
@ -133,7 +133,7 @@ function rebalance() {
# compare copy against original to make sure nothing went wrong # compare copy against original to make sure nothing went wrong
if [[ "${checksum_flag}" == "true"* ]]; then if [[ "${checksum_flag}" == "true"* ]]; then
echo "Comparing copy against original..." echo "Comparing copy against original..."
if [[ "${OSTYPE}" == "linux-gnu"* ]]; then if [[ "${OSName}" == "linux-gnu"* ]]; then
# Linux # Linux
# file attributes # file attributes
@ -156,7 +156,7 @@ function rebalance() {
copy_md5="${copy_md5} $(md5sum -b "${tmp_file_path}")" copy_md5="${copy_md5} $(md5sum -b "${tmp_file_path}")"
# remove the temporary extension # remove the temporary extension
copy_md5=${copy_md5%"${tmp_extension}"} copy_md5=${copy_md5%"${tmp_extension}"}
elif [[ "${OSTYPE}" == "darwin"* ]] || [[ "${OSTYPE}" == "freebsd"* ]]; then elif [[ "${OSName}" == "darwin"* ]] || [[ "${OSName}" == "freebsd"* ]]; then
# Mac OS # Mac OS
# FreeBSD # FreeBSD
@ -250,6 +250,8 @@ done
root_path=$1 root_path=$1
OSName=$(echo "$OSTYPE" | tr '[:upper:]' '[:lower:]')
color_echo "$Cyan" "Start rebalancing $(date):" color_echo "$Cyan" "Start rebalancing $(date):"
color_echo "$Cyan" " Path: ${root_path}" color_echo "$Cyan" " Path: ${root_path}"
color_echo "$Cyan" " Rebalancing Passes: ${passes_flag}" color_echo "$Cyan" " Rebalancing Passes: ${passes_flag}"