Skip to content

Commit

Permalink
Merge pull request #53 from pratikkumar-mohite/pm/issue-11
Browse files Browse the repository at this point in the history
Issue 11: Adding readme
  • Loading branch information
pratikkumar-mohite authored Oct 13, 2024
2 parents 05c0231 + 5f91dbb commit 9fa2914
Show file tree
Hide file tree
Showing 9 changed files with 87 additions and 31 deletions.
10 changes: 5 additions & 5 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@ jobs:
echo "new_tag=$new_tag" >> $GITHUB_OUTPUT
fi
# - name: Create and push new tag
# run: |
# new_tag=${{ steps.update_latest_tag.outputs.new_tag }}
# git tag -a $new_tag -m "Release $new_tag"
# git push origin $new_tag
- name: Create and push new tag
run: |
new_tag=${{ steps.update_latest_tag.outputs.new_tag }}
git tag -a $new_tag -m "Release $new_tag"
git push origin $new_tag
4 changes: 2 additions & 2 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,6 @@ jobs:
GITHUB_TOKEN: ${{ secrets.GITHUB_CI_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./s3-cleanup
asset_name: s3-cleanup
asset_path: ./s3-cleaner
asset_name: s3-cleaner
asset_content_type: application/octet-stream
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,4 @@ go.work.sum
*.txt

# binary file
/s3-cleanup
/s3-cleaner
40 changes: 20 additions & 20 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,31 +1,31 @@
.PHONY: mod build run test
.PHONY: mod build run

mod:
@go mod download
@go mod verify

build: bench
@CGO_ENABLED=0 go build -pgo=cpu.out -ldflags="-w -s" -v -o s3-cleanup ./cmd/s3-cleanup/
build:
@CGO_ENABLED=0 go build -v -o s3-cleaner ./cmd/s3-cleaner/

run:
@CGO_ENABLED=0 go run ./cmd/s3-cleanup/
@CGO_ENABLED=0 go run ./cmd/s3-cleaner/

test:
@go run github.com/golangci/golangci-lint/cmd/golangci-lint@latest run -v --timeout=10m
@go test -v -timeout 20m -covermode=atomic -coverprofile=coverage.txt ./...
# test:
# @go run github.com/golangci/golangci-lint/cmd/golangci-lint@latest run -v --timeout=10m
# @go test -v -timeout 20m -covermode=atomic -coverprofile=coverage.txt ./...

bench:
@go test -v -bench=. -count=6 -cpuprofile=cpu.out -memprofile=mem.out ./cmd/s3-cleanup/ -run=^Benchmark$ > benchmark.txt
# bench:
# @go test -v -bench=. -count=6 -cpuprofile=cpu.out -memprofile=mem.out ./cmd/s3-cleaner/ -run=^Benchmark$ > benchmark.txt

bench-heavy:
@go test -v -bench=. -count=10 -cpu=1,2,4,8 -cpuprofile=cpu.out -memprofile=mem.out ./cmd/s3-cleanup/ -run=^Benchmark$ > benchmark.txt
@benchstat benchmark.txt
@echo top | go tool pprof mem.out
@echo top | go tool pprof cpu.out
# bench-heavy:
# @go test -v -bench=. -count=10 -cpu=1,2,4,8 -cpuprofile=cpu.out -memprofile=mem.out ./cmd/s3-cleaner/ -run=^Benchmark$ > benchmark.txt
# @benchstat benchmark.txt
# @echo top | go tool pprof mem.out
# @echo top | go tool pprof cpu.out

result:
@cp coverage.txt benchmark.txt mem.out cpu.out coverage
@go tool cover -func coverage.txt
@benchstat benchmark.txt
@echo top | go tool pprof mem.out
@echo top | go tool pprof cpu.out
# result:
# @cp coverage.txt benchmark.txt mem.out cpu.out coverage
# @go tool cover -func coverage.txt
# @benchstat benchmark.txt
# @echo top | go tool pprof mem.out
# @echo top | go tool pprof cpu.out
58 changes: 57 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1 +1,57 @@
# s3-cleanup
# S3 Cleaner
This project is a Go application designed to delete AWS S3 buckets. It retrieves the list of buckets from your AWS account and performs cleanup operations on specified buckets.

## Prerequisites

1. Go 20 and higher.
2. AWS account with IAM priviledges to perform S3 operations.

## Features

- List all S3 buckets in your AWS account.
- Delete specified S3 buckets and its Objects.
- Works with Versioned and Non-Versioned buckets.
- Utilize GO concurrency for delete operations.

## Build

1. Clone the repository:
```sh
git clone https://github.com/pratikkumar-mohite/s2-cleanup.git
```
2. Navigate to the project directory:
```sh
cd s3-cleaner
```
3. Build the application:
```sh
make build
```
4. Move the binary to executable path
```sh
mv s3-cleaner /usr/local/bin/
```

## Test
As of now the actual test are not there because we dont have s3 mock apis to mimic the s3 object behaviour specifically in go, this project has dependency on [S3Mock project](https://github.com/pratikkumar-mohite/S3Mock) to enable the `go test`.

## Usage

1. Ensure you have AWS credentials configured. You can set them up using the AWS CLI(ignore if already set):
```sh
aws configure --profile <your-aws-profile>
```
2. Setup Environment variables
```sh
export AWS_REGION=us-east-1
export AWS_DELETE_S3_BUCKET=pratikkumar-mohite-test
export AWS_PROFILE=pratikkumar-mohite-aws
```
2. Run the application:
```sh
s3-cleaner
```

## Contributing

Contributions are greatly appreciated. We actively manage the issues list, and try to highlight issues suitable for newcomers. The project follows the typical GitHub pull request model. Before starting any work, please either comment on an existing issue, or file a new one.
2 changes: 1 addition & 1 deletion cmd/s3-cleanup/cleanup.go → cmd/s3-cleaner/cleanup.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (
"sync"

log "github.com/sirupsen/logrus"
"github.com/pratikkumar-mohite/s3-cleanup/pkg/aws"
"github.com/pratikkumar-mohite/s3-cleaner/pkg/aws"
)

func setup() aws.S3Client {
Expand Down
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module github.com/pratikkumar-mohite/s3-cleanup
module github.com/pratikkumar-mohite/s3-cleaner

go 1.22.5

Expand Down

0 comments on commit 9fa2914

Please sign in to comment.