Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Golden tests compare golden files (.txt) with \n
*.txt text eol=lf
63 changes: 63 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
name: CI

on:
push:
pull_request:

jobs:
staticcheck:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: dominikh/staticcheck-action@v1

tests:
strategy:
matrix:
os:
- macos-latest
- ubuntu-latest
- windows-latest
runs-on: ${{ matrix.os }}

steps:
- uses: actions/checkout@v4

- uses: actions/setup-go@v5
with:
# Latest stable version of Go, e.g. 1.20.2
go-version: 'stable'

- name: Ensure all files were formatted as per gofmt
if: matrix.os == 'ubuntu-latest'
run: |
[ "$(gofmt -l $(find . -name '*.go') 2>&1)" = "" ]

- name: install rsync
if: matrix.os == 'ubuntu-latest'
run: |
docker build --pull --no-cache --rm -t=rsync-debian -f testdata/ci-debian.Dockerfile .
docker build --pull --no-cache --rm -t=rsync-fedora -f testdata/ci-fedora.Dockerfile .

- name: install rsync
if: matrix.os == 'windows-latest'
run: choco install rsync

- name: run tests (linux)
if: matrix.os == 'ubuntu-latest'
run: |
go test -v ./...
echo "::group::rsync from Debian"
docker run -v $PWD:/usr/src/rsync/ -w /usr/src/rsync rsync-debian go test ./...
echo "::endgroup::"
echo "::group::rsync from Fedora"
docker run -v $PWD:/usr/src/rsync/ -w /usr/src/rsync rsync-fedora go test ./...
echo "::endgroup::"

- name: run tests (macos)
if: matrix.os == 'macos-latest'
run: sudo go test -v ./...

- name: run tests (windows)
if: matrix.os == 'windows-latest'
run: go test -v ./...
34 changes: 2 additions & 32 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,32 +1,2 @@
# If you prefer the allow list template instead of the deny list, see community template:
# https://github.com/github/gitignore/blob/main/community/Golang/Go.AllowList.gitignore
#
# Binaries for programs and plugins
*.exe
*.exe~
*.dll
*.so
*.dylib

# Test binary, built with `go test -c`
*.test

# Code coverage profiles and other test artifacts
*.out
coverage.*
*.coverprofile
profile.cov

# Dependency directories (remove the comment below to include it)
# vendor/

# Go workspace file
go.work
go.work.sum

# env file
.env

# Editor/IDE
# .idea/
# .vscode/
gon_*.hcl
dist
99 changes: 99 additions & 0 deletions .goreleaser.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
before:
hooks:
- go mod download
- go generate ./...

builds:
- id: "rsync-linux"
main: "./cmd/gokr-rsync"
binary: "gokr-rsync"
env:
- CGO_ENABLED=0
goos:
- linux
goarch:
- amd64
- arm
- arm64
- 386

- id: "rsync-windows"
main: "./cmd/gokr-rsync"
binary: "gokr-rsync"
env:
- CGO_ENABLED=0
goos:
- windows
goarch:
- arm64
- amd64
- 386

- id: "rsync-macos"
main: "./cmd/gokr-rsync"
binary: "gokr-rsync"
env:
- CGO_ENABLED=0
goos:
- darwin
goarch:
- arm64
- amd64

archives:
- id: linux
name_template: >-
rsync_
{{- title .Os }}_
{{- if eq .Arch "amd64" }}x86_64
{{- else if eq .Arch "386" }}i386
{{- else}}{{ .Arch }}{{ end }}
builds: ["rsync-linux"]

- id: windows
name_template: >-
rsync_
{{- title .Os }}_
{{- if eq .Arch "amd64" }}x86_64
{{- else if eq .Arch "386" }}i386
{{- else}}{{ .Arch }}{{ end }}
builds: ["rsync-windows"]
format: zip

- id: macos
name_template: >-
rsync_Mac_
{{- if eq .Arch "amd64" }}Intel
{{- else if eq .Arch "arm64" }}Apple_Silicon
{{- else}}{{ .Arch }}{{ end }}
builds: ["rsync-macos"]
format: zip

signs:
- id: mac-notarize
ids: [macos]
signature: "${artifact}.dmg"
output: true
cmd: bash
args:
- "-c"
- "gon gon_$(echo ${artifact} | sed 's,^dist/rsync_,,g;s,\\.zip$,,g').hcl"
artifacts: archive

checksum:
name_template: 'checksums.txt'

snapshot:
name_template: "{{ .Tag }}-next"

changelog:
sort: asc
filters:
exclude:
- '^docs:'
- '^test:'

release:
github:
owner: gokrazy
name: rsync
27 changes: 27 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
Copyright (c) 2021 the gokrazy authors. All rights reserved.

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are
met:

* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above
copyright notice, this list of conditions and the following disclaimer
in the documentation and/or other materials provided with the
distribution.
* Neither the name of gokrazy nor the names of its
contributors may be used to endorse or promote products derived from
this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
46 changes: 46 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
.PHONY: all run systemd test privileged-test docker raspi mac staticcheck

all:
CGO_ENABLED=0 go install github.com/runpod/rsync/cmd/...

staticcheck:
staticcheck ./...

run: all
sudo ~/go/bin/gokr-rsyncd -modulemap=default=/etc/default

systemd: all
sudo systemctl stop gokr-rsyncd.socket gokr-rsyncd.service && \
sudo cp /home/michael/go/bin/gokr-rsyncd /usr/bin/ && \
sudo cp systemd/gokr-rsyncd.socket systemd/gokr-rsyncd.service /etc/systemd/system/ && \
sudo systemctl daemon-reload && \
(sudo systemctl kill -f gokr-rsyncd.service; \
sudo systemctl restart gokr-rsyncd.socket)

test:
GOGC=off CGO_ENABLED=0 go test -fullpath ./...

privileged-test:
GOGC=off CGO_ENABLED=0 sudo go test -fullpath ./integration/interop ./integration/receiver

docker:
CGO_ENABLED=0 GOBIN=$$PWD/docker go install github.com/runpod/rsync/cmd/gokr-rsyncd
(cd docker && docker build -t=stapelberg/gokrazy-rsync .)

router7:
GOARCH=amd64 CGO_ENABLED=0 go install github.com/runpod/rsync/cmd/gokr-rsyncd && \
(ssh router7.lan killall gokr-rsyncd || true) && \
cp ~/go/bin/gokr-rsyncd /mnt/loop/ && \
ssh router7.lan /perm/gokr-rsyncd -modulemap distri=/perm/srv/repo.distr1.org/distri/ -listen=10.0.0.1:8730 -monitoring_listen=10.0.0.1:8780

raspi:
# -tags nonamespacing
GOARCH=arm64 CGO_ENABLED=0 go install github.com/runpod/rsync/cmd/gokr-rsyncd && \
ssh gokrazy.lan killall gokr-rsyncd && \
cp ~/go/bin/linux_arm64/gokr-rsyncd /mnt/loop/ && \
ssh gokrazy.lan /perm/gokr-rsyncd -modulemap pwd=/gokrazy -listen=:873

mac:
GOARCH=arm64 GOOS=darwin CGO_ENABLED=0 go install github.com/runpod/rsync/cmd/gokr-rsyncd && \
scp ~/go/bin/darwin_arm64/gokr-rsyncd m1a.lan: && \
ssh m1a.lan ~/gokr-rsyncd -help
Loading
Loading