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
11 changes: 11 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
version: 2

updates:
- package-ecosystem: "gomod"
directory: "/"
schedule:
interval: "weekly"
groups:
go-dependencies:
patterns:
- "*"
51 changes: 32 additions & 19 deletions .github/workflows/quality.yml
Original file line number Diff line number Diff line change
@@ -1,31 +1,44 @@
name: 📋 Quality
name: 📋 Quality Checks

on:
pull_request:
types: [ synchronize, opened, reopened, ready_for_review ]

concurrency:
group: test-${{ github.head_ref }}
cancel-in-progress: true

jobs:
test:
name: Test
lint:
name: 📋 Lint
runs-on: ubuntu-latest
steps:
- name: Git clone the repository
uses: actions/checkout@v4

- name: 📦 Install Go
uses: actions/setup-go@v3
with:
go-version: '1.23'
- name: ⬇️ Git clone the repository
uses: actions/checkout@v5

- name: Lint
- name: 📦 Install Mise
run: |
go install github.com/mgechev/revive@latest
make lint
curl https://mise.run | sh
mise install
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: 🧪 Lint
run: mise lint

test:
name: 📋 Test
needs: lint
runs-on: ubuntu-latest
steps:
- name: ⬇️ Git clone the repository
uses: actions/checkout@v5

- name: Test
- name: 📦 Install Mise
run: |
make test
curl https://mise.run | sh
mise install
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: 🧪 Lint
run: mise lint

- name: 🧪 Test
run: mise test
41 changes: 15 additions & 26 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -1,39 +1,28 @@
name: "📋 Release"
name: ☁️ Release

on:
push:
tags:
- 'v[0-9]+.[0-9]+.[0-9]+[0-9A-Za-z]?'
- '*'

env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}
permissions:
contents: write
packages: write

jobs:
build:
release:
runs-on: ubuntu-latest

permissions:
contents: read
packages: write
attestations: write
id-token: write

steps:
- name: ⬇️ Git clone the repository
uses: actions/checkout@v4

- name: 🔐 Log in to the Container registry
uses: docker/login-action@65b78e6e13532edd9afa3aa52ac7964289d1a9c1
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: ⬇️ Checkout Code
uses: actions/checkout@v5

- name: 📦 Build
- name: 📦 Install Mise
run: |
docker build -t ${{ env.REGISTRY }}/${{ github.repository }}:${{ github.ref_name }} .
curl https://mise.run | sh
mise install

- name: ☁️ Push
- name: ☁️ Release
run: |
docker push ${{ env.REGISTRY }}/${{ github.repository }}:${{ github.ref_name }}
mise release
env:
GITHUB_TOKEN: ${{ secrets.GH_TOKEN }}
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/bin
/dist
/.idea
/vendor
30 changes: 30 additions & 0 deletions .goreleaser.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
project_name: s3-sync

version: 2

builds:
- id: s3-sync
binary: skpr-s3-sync
ldflags:
- -extldflags '-static'
env:
- CGO_ENABLED=0
goos: [ linux ]
goarch: [ amd64, arm64 ]
goamd64: [ v3 ]

dockers_v2:
- id: s3-sync
dockerfile: Dockerfile
ids:
- s3-sync
images:
- 022593270620.dkr.ecr.ap-southeast-2.amazonaws.com/nmhc/s3-sync
tags:
- "latest"
sbom: false
flags:
- "--pull"

changelog:
use: github-native
35 changes: 35 additions & 0 deletions .mise.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
[tools]
go = "1.26"
"ubi:golangci/golangci-lint" = "2.10"
"ubi:goreleaser/goreleaser" = "2.14"

[env]
CGO_ENABLED=0

[tasks.vendor]
description = "Vendor resets the main module's vendor directory to include all packages needed to build the application"
run = "go mod vendor"

[tasks.tidy]
description = "Tidy makes sure go.mod matches the source code in the module"
run = "go mod tidy"

[tasks.build]
description = "Build all the applications"
run = "go build -o bin/s3-sync -ldflags=${CLI_LDFLAGS} github.com/skpr/s3-sync"
depends = ["vendor"]

[tasks."lint"]
description = "Linting automatically checks code for errors and style issues"
run = "golangci-lint run"
depends = ["tidy"]

[tasks.test]
description = "Checks to verify code correctness"
run = "go test -cover ./..."
depends = ["vendor"]

[tasks.release]
description = "Release the command line interface"
run = "goreleaser"
depends = ["vendor"]
11 changes: 3 additions & 8 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,9 +1,4 @@
FROM golang:1.23-alpine as build
ADD . /go/src/github.com/skpr/s3-sync
WORKDIR /go/src/github.com/skpr/s3-sync
RUN apk add make
RUN make build

FROM docker.io/amazon/aws-cli:2.17.59
COPY --from=build /go/src/github.com/skpr/s3-sync/bin/s3-sync /usr/local/bin/s3-sync
FROM docker.io/amazon/aws-cli:2.34.9
ARG TARGETPLATFORM
COPY $TARGETPLATFORM/skpr-s3-sync /usr/local/bin/s3-sync
ENTRYPOINT ["/usr/local/bin/s3-sync"]
16 changes: 0 additions & 16 deletions Makefile

This file was deleted.

6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
S3 Sync
=======

A container which makes it easier to copy files to and from S3 buckets.

This program is a wrapper over the AWS CLI.
4 changes: 2 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
module github.com/skpr/s3-sync

go 1.22.6
go 1.26

require (
github.com/alecthomas/kingpin/v2 v2.4.0
github.com/stretchr/testify v1.9.0
github.com/stretchr/testify v1.11.1
)

require (
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZb
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4=
github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg=
github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
github.com/stretchr/testify v1.11.1 h1:7s2iGBzp5EwR7/aIZr8ao5+dra3wiQyKjjFuvgVKu7U=
github.com/stretchr/testify v1.11.1/go.mod h1:wZwfW3scLgRK+23gO65QZefKpKQRnfz6sD981Nm4B6U=
github.com/xhit/go-str2duration/v2 v2.1.0 h1:lxklc02Drh6ynqX+DdPyp5pCKLUQpRT8bp8Ydu2Bstc=
github.com/xhit/go-str2duration/v2 v2.1.0/go.mod h1:ohY8p+0f07DiV6Em5LKB0s2YpLtXVyJfNt1+BlmyAsU=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
Expand Down
4 changes: 2 additions & 2 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,8 @@ func main() {
func buildArgs(endpoint, mode, source, target, exclude string) ([]string, error) {
args := []string{"s3"}

if *cliMode != ModeCP && *cliMode != ModeSync {
return args, fmt.Errorf("mode not support: %s", mode)
if mode != ModeCP && mode != ModeSync {
return args, fmt.Errorf("mode not supported: %s", mode)
}

if endpoint != "" {
Expand Down
14 changes: 9 additions & 5 deletions main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,21 +7,25 @@ import (
)

func TestBuildArgsWithEndpoint(t *testing.T) {
command := buildArgs("127.0.0.1", "sync", "foo", "bar", "")
command, err := buildArgs("127.0.0.1", "sync", "foo", "bar", "")
assert.NoError(t, err)
assert.Equal(t, []string{"s3", "--endpoint-url", "127.0.0.1", "sync", "foo", "bar"}, command)
}

func TestBuildArgsWithEndpointAndCP(t *testing.T) {
command := buildArgs("127.0.0.1", "cp", "foo", "bar", "")
assert.Equal(t, []string{"s3", "--endpoint-url", "127.0.0.1", "cp", "foo", "bar"}, command)
command, err := buildArgs("127.0.0.1", "cp", "foo", "bar", "")
assert.NoError(t, err)
assert.Equal(t, []string{"s3", "--endpoint-url", "127.0.0.1", "cp", "--recursive", "foo", "bar"}, command)
}

func TestBuildArgsdWithExcludes(t *testing.T) {
command := buildArgs("", "sync", "foo", "bar", "/stuff,/things")
command, err := buildArgs("", "sync", "foo", "bar", "/stuff,/things")
assert.NoError(t, err)
assert.Equal(t, []string{"s3", "sync", "--exclude", "/stuff", "--exclude", "/things", "foo", "bar"}, command)
}

func TestBuildArgsWithAll(t *testing.T) {
command := buildArgs("127.0.0.1", "sync", "foo", "bar", "/stuff,/things")
command, err := buildArgs("127.0.0.1", "sync", "foo", "bar", "/stuff,/things")
assert.NoError(t, err)
assert.Equal(t, []string{"s3", "--endpoint-url", "127.0.0.1", "sync", "--exclude", "/stuff", "--exclude", "/things", "foo", "bar"}, command)
}
14 changes: 0 additions & 14 deletions vendor/github.com/alecthomas/kingpin/v2/.travis.yml

This file was deleted.

19 changes: 0 additions & 19 deletions vendor/github.com/alecthomas/kingpin/v2/COPYING

This file was deleted.

Loading