Skip to content

feat: Add reflink FileCopyMethod (copy-on-write) #370

feat: Add reflink FileCopyMethod (copy-on-write)

feat: Add reflink FileCopyMethod (copy-on-write) #370

Workflow file for this run

name: Go
on:
push:
branches: [ main, develop ]
pull_request:
branches: [ main, develop ]
workflow_dispatch:
jobs:
build:
name: Build
runs-on: ${{ matrix.os.runner }}
strategy:
matrix:
os:
- runner: macos-latest
- runner: ubuntu-latest
- runner: windows-latest
- runner: macos-latest
filesystem: APFS
copymethod: ReflinkCopy
- runner: ubuntu-latest
filesystem: btrfs
copymethod: ReflinkCopy
go: ['1.18', '1.19', '1.20']
steps:
- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: ${{ matrix.go }}
id: go
- name: Check out code into the Go module directory
uses: actions/checkout@v3
- name: Get dependencies
run: go get -v -t -d ./...
- name: Build
run: go build -v .
- name: Set up testing environment
run: |-
mkdir ./test/filesystems
echo "TEST_PATH=." >> $GITHUB_ENV
- name: Set up filesystem (MacOS)
if: ${{ matrix.os.filesystem != '' && startsWith(matrix.os.runner, 'macos-') }}
run: |-
IMAGE_PATH="./test/filesystems/${{matrix.os.filesystem}}.dmg"
MOUNT_PATH="./test/filesystems/${{matrix.os.filesystem}}.mount"
echo "TEST_PATH=${MOUNT_PATH}" >> $GITHUB_ENV
hdiutil create -size 500m -fs APFS "$IMAGE_PATH"
hdiutil attach -mountpoint "$MOUNT_PATH" "$IMAGE_PATH"
- name: Set up filesystem (Linux)
if: ${{ matrix.os.filesystem != '' && startsWith(matrix.os.runner, 'ubuntu-') }}
run: |-
IMAGE_PATH="./test/filesystems/${{matrix.os.filesystem}}.img"
MOUNT_PATH="./test/filesystems/${{matrix.os.filesystem}}.mount"
echo "TEST_PATH=${MOUNT_PATH}" >> $GITHUB_ENV
truncate -s 500m "$IMAGE_PATH"
mkfs -t "${{matrix.os.filesystem}}" "$IMAGE_PATH"
mkdir "$MOUNT_PATH"
whoami
id -u
sudo mount -o loop "$IMAGE_PATH" "$MOUNT_PATH"
sudo chown -R "$(id -u):$(id -g)" "$MOUNT_PATH"
- name: Copy files to filesystem
if: ${{ matrix.os.filesystem != '' }}
run: |-
rsync -av --exclude=".*" --exclude "test/filesystems" . "$TEST_PATH"
- name: Test
working-directory: ${{ env.TEST_PATH }}
env:
TEST_FILESYSTEM: ${{ matrix.os.filesystem }}
TEST_FILECOPYMETHOD: ${{ matrix.os.copymethod }}
run: go test -v --tags=go${{ matrix.go }}
benchmark:
name: Benchmark
runs-on: ubuntu-latest
strategy:
matrix:
go: ['1.21']
steps:
- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: ${{ matrix.go }}
id: go
- name: Check out code into the Go module directory
uses: actions/checkout@v3
- name: Get dependencies
run: go get -v -t -d ./...
- name: Benchmark
run: go test -bench . -benchmem -benchtime 8s