diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..b032f91 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,75 @@ +name: Lint Test Build + +on: + push: + branches: + - main + pull_request: + branches: + - main + +jobs: + lint: + name: Linting + runs-on: ubuntu-latest + + steps: + - name: Checkout code + uses: actions/checkout@v3 + + - name: Set up Go + uses: actions/setup-go@v4 + with: + go-version: 1.21 + - name: Install golangci-lint + run: | + curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin v1.54.2 + golangci-lint version + + - name: Run golangci-lint + run: golangci-lint run --timeout=5m + + test: + name: Testing + runs-on: ubuntu-latest + + steps: + - name: Checkout code + uses: actions/checkout@v3 + + - name: Set up Go + uses: actions/setup-go@v4 + with: + go-version: 1.21 + + - name: Install dependencies + run: go mod tidy + + - name: Run tests + run: go test ./... -v + + build: + name: Building + runs-on: ubuntu-latest + + steps: + - name: Checkout code + uses: actions/checkout@v3 + + - name: Set up Go + uses: actions/setup-go@v4 + with: + go-version: 1.21 + + - name: Install dependencies + run: go mod tidy + + - name: Build the project + run: go build -o gocrab main.go + + - name: Verify binary exists + run: | + if [ ! -f "./gocrab" ]; then + echo "Build failed: binary not found." + exit 1 + fi diff --git a/.github/workflows/docker-release.yml b/.github/workflows/docker-release.yml new file mode 100644 index 0000000..a357ef2 --- /dev/null +++ b/.github/workflows/docker-release.yml @@ -0,0 +1,34 @@ +name: Docker Build and Push + +on: + workflow_run: + workflows: + - Lint Test Build + types: + - completed +jobs: + docker: + name: Build and Push to Docker Hub + runs-on: ubuntu-latest + + steps: + - name: Checkout code + uses: actions/checkout@v3 + + - name: Log in to Docker Hub + uses: docker/login-action@v2 + with: + username: ${{ secrets.DOCKER_USERNAME }} + password: ${{ secrets.DOCKER_PASSWORD }} + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v2 + + - name: Build and Push Docker Image + uses: docker/build-push-action@v4 + with: + context: . + push: true + tags: | + ${{ secrets.DOCKER_USERNAME }}/gocrab:latest + ${{ secrets.DOCKER_USERNAME }}/gocrab:${{ github.sha }} diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 79d0484..6fdd962 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -54,6 +54,22 @@ git push origin feature/amazing-feature Go to the original repository and create a Pull Request. Include a description of your changes, the reason behind them, and any additional context that may help the maintainers review your contribution. +#### Docker Image +If you're actively contributing to **GoCrab** and want to build and test the Docker image locally, use the following commands: + +1. **Build the Docker Image**: + ```sh + docker build -t gocrab . + ``` + +2. **Run the Local Docker Image**: + ```sh + docker run --rm -v $(pwd):/app gocrab /app/path/to/rust/file.rs + ``` + +With Docker, **GoCrab** provides a simple and portable way to transpile Rust to Go without needing to install Go locally. + + ## Code of Conduct Please note that GoCrab follows a Code of Conduct to foster an open and welcoming environment. By participating, you are expected to uphold this standard. diff --git a/Readme.md b/Readme.md index 72e4a70..a7dfbec 100644 --- a/Readme.md +++ b/Readme.md @@ -114,6 +114,36 @@ GoCrab path/to/rust/file.rs This command will generate a `.go` file with equivalent Go code in the same directory. +### Usage (Docker) + +If you prefer to use Docker to run **GoCrab**, you can pull the latest image from Docker Hub and use it to transpile Rust code to Go. + +#### Pull the Docker Image +To get the latest **GoCrab** image from Docker Hub, run the following command: + +```sh +docker pull SkySingh04/gocrab:latest +``` + +#### Run the Transpiler +You can use the Docker container to transpile your Rust files. Mount the directory containing your Rust file and specify the file as an argument: + +```sh +docker run --rm -v $(pwd):/app SkySingh04/gocrab:latest /app/path/to/rust/file.rs +``` + +This will generate the transpiled `.go` file in the same directory as your Rust file. + +#### Example +If you have a Rust file `example.rs` in your current directory, you can transpile it as follows: + +```sh +docker run --rm -v $(pwd):/app SkySingh04/gocrab:latest /app/example.rs +``` + +The output file `example.go` will be created in the same directory. + +--- ## Contributing