Skip to content

Commit 896fc07

Browse files
Theo Paristheoparis
authored andcommitted
feat: use btrfs with zstd compression
I specified zstd:13, but I'm not sure that it is the best compression level.
1 parent c28619d commit 896fc07

File tree

1 file changed

+27
-4
lines changed

1 file changed

+27
-4
lines changed

action.yml

Lines changed: 27 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,14 @@ inputs:
2323
You should prefer adjusting root-reserve-mb/temp-reserve-mb over using this option.
2424
required: false
2525
default: 'false'
26+
filesystem-type:
27+
description: 'The filesystem to use'
28+
required: false
29+
default: 'ext4'
30+
btrfs-compression-level:
31+
description: 'The compression level to use if the filesystem is btrfs'
32+
required: false
33+
default: '0'
2634
build-mount-path:
2735
description: 'Absolute path to the mount point where the build space will be available, defaults to $GITHUB_WORKSPACE if unset.'
2836
required: false
@@ -177,12 +185,27 @@ runs:
177185
echo "Creating build volume"
178186
# create and mount build volume
179187
sudo lvcreate -l 100%FREE -n buildlv "${VG_NAME}"
180-
if [[ ${{ inputs.overprovision-lvm }} == 'true' ]]; then
181-
sudo mkfs.ext4 -m0 "/dev/mapper/${VG_NAME}-buildlv"
188+
if [[ ${inputs.filesystem-type} == 'btrfs' ]]; then
189+
sudo mkfs.btrfs -m single -d single "/dev/mapper/${VG_NAME}-buildlv"
190+
191+
mount_options=('space_cache=v2' 'noatime')
192+
if [[ ${{ inputs.overprovision-lvm }} == 'true' ]]; then
193+
mount_options+=('discard=async')
194+
else
195+
mount_options+=('nodiscard')
196+
fi
197+
if [[ ${{ inputs.btrfs-compression-level }} != '0' ]]; then
198+
mount_options+=("compress-force=zstd:${inputs.build-compression-level}")
199+
fi
200+
IFS="," sudo mount -t btrfs -o ${mount_options[*]} "/dev/mapper/${VG_NAME}-buildlv" "${BUILD_MOUNT_PATH}"
182201
else
183-
sudo mkfs.ext4 -Enodiscard -m0 "/dev/mapper/${VG_NAME}-buildlv"
202+
if [[ ${{ inputs.overprovision-lvm }} == 'true' ]]; then
203+
sudo mkfs.ext4 -m0 "/dev/mapper/${VG_NAME}-buildlv"
204+
else
205+
sudo mkfs.ext4 -Enodiscard -m0 "/dev/mapper/${VG_NAME}-buildlv"
206+
fi
207+
IFS="," sudo mount -t ext4 "/dev/mapper/${VG_NAME}-buildlv" "${BUILD_MOUNT_PATH}"
184208
fi
185-
sudo mount "/dev/mapper/${VG_NAME}-buildlv" "${BUILD_MOUNT_PATH}"
186209
sudo chown -R "${{ inputs.build-mount-path-ownership }}" "${BUILD_MOUNT_PATH}"
187210
188211
# if build mount path is a parent of $GITHUB_WORKSPACE, and has been deleted, recreate it

0 commit comments

Comments
 (0)