diff --git a/.github/workflows/go.yml b/.github/workflows/go.yml new file mode 100644 index 0000000000..cf4acfb76d --- /dev/null +++ b/.github/workflows/go.yml @@ -0,0 +1,84 @@ +name: Go CI + +on: + push: + branches: ["main"] + paths: + - glide-core/** + - submodules/** + - go/** + - .github/workflows/go.yml + pull_request: + paths: + - glide-core/** + - submodules/** + - go/** + - .github/workflows/go.yml + +# Run only the latest job on a branch and cancel previous ones +concurrency: + group: ${{ github.head_ref || github.ref }} + cancel-in-progress: true + +jobs: + build-and-test-go-client: + timeout-minutes: 25 + strategy: + # Run all jobs + fail-fast: false + matrix: + go: + - '1.18' + - '1.21' + redis: + - 6.2.14 + - 7.2.3 + os: + - ubuntu-latest + - macos-latest + + runs-on: ${{ matrix.os }} + + steps: + - uses: actions/checkout@v4 + with: + submodules: recursive + + - name: Set up Go ${{ matrix.go }} + uses: actions/setup-go@v5 + with: + go-version: '^1.13.1' + + - name: Install shared software dependencies + uses: ./.github/workflows/install-shared-dependencies + with: + os: ${{ matrix.os }} + target: ${{ matrix.os == 'ubuntu-latest' && 'x86_64-unknown-linux-gnu' || 'x86_64-apple-darwin' }} + github-token: ${{ secrets.GITHUB_TOKEN }} + + - name: Install redis + # TODO: make this step macos compatible: https://github.com/aws/glide-for-redis/issues/781 + if: ${{ matrix.os == 'ubuntu-latest' }} + uses: ./.github/workflows/install-redis + with: + redis-version: ${{ matrix.redis }} + + - name: Build glide-core + working-directory: ./glide-core + run: cargo build --release + + - name: Build glide + working-directory: ./go/glide + run: cargo build --release + + - name: Generate the Go protobuf files + run: | + go install google.golang.org/protobuf/cmd/protoc-gen-go@latest + mkdir go/glide/protobuf + protoc --proto_path=glide-core/src/protobuf \ + --go_opt=Mconnection_request.proto=github.com/aws/glide-for-redis/go/glide/protobuf \ + --go_opt=Mredis_request.proto=github.com/aws/glide-for-redis/go/glide/protobuf \ + --go_opt=Mresponse.proto=github.com/aws/glide-for-redis/go/glide/protobuf \ + --go_out=go/glide/protobuf \ + --go_opt=paths=source_relative \ + glide-core/src/protobuf/*.proto diff --git a/.gitignore b/.gitignore index fdc9d2b163..a0d5b9bc4e 100644 --- a/.gitignore +++ b/.gitignore @@ -49,3 +49,7 @@ utils/tls_crts/ # java compiled files. *.class + +# Go compilation files +go/**/lib.h +*.pb.go diff --git a/go/glide/.cargo/config.toml b/go/glide/.cargo/config.toml new file mode 100644 index 0000000000..f510628c9e --- /dev/null +++ b/go/glide/.cargo/config.toml @@ -0,0 +1,3 @@ +[env] +GLIDE_NAME = { value = "GlideGo", force = true } +GLIDE_VERSION = "0.1.0" diff --git a/go/glide/Cargo.toml b/go/glide/Cargo.toml new file mode 100644 index 0000000000..4c8564d9f3 --- /dev/null +++ b/go/glide/Cargo.toml @@ -0,0 +1,27 @@ +[package] +name = "glide-rs" +version = "0.1.0" +edition = "2021" +license = "Apache-2.0" +authors = ["Amazon Web Services"] + +build = "build.rs" + +[build-dependencies] +cbindgen = "0.20" + +[lib] +crate-type = ["cdylib"] + +[dependencies] +redis = { path = "../../submodules/redis-rs/redis", features = ["aio", "tokio-comp", "tls", "tokio-native-tls-comp", "tls-rustls-insecure"] } +glide-core = { path = "../../glide-core" } +tokio = { version = "^1", features = ["rt", "macros", "rt-multi-thread", "time"] } +num-derive = "0.4.0" +num-traits = "0.2.15" +tracing-subscriber = "0.3.16" +protobuf = { version = "3.3.0", features = [] } + +[profile.release] +lto = true +debug = true diff --git a/go/glide/build.rs b/go/glide/build.rs new file mode 100644 index 0000000000..37de0f5120 --- /dev/null +++ b/go/glide/build.rs @@ -0,0 +1,16 @@ +/** + * Copyright GLIDE-for-Redis Project Contributors - SPDX Identifier: Apache-2.0 + */ + +use std::env; + +fn main() { + let crate_dir = env::var("CARGO_MANIFEST_DIR").unwrap(); + + cbindgen::Builder::new() + .with_crate(crate_dir) + .with_language(cbindgen::Language::C) + .generate() + .expect("Unable to generate bindings") + .write_to_file("lib.h"); +} diff --git a/go/glide/glide.go b/go/glide/glide.go new file mode 100644 index 0000000000..9f12fc6096 --- /dev/null +++ b/go/glide/glide.go @@ -0,0 +1,9 @@ +package glide + +import ( + "fmt" +) + +func main() { + fmt.Println("Hello world!") +} diff --git a/go/glide/go.mod b/go/glide/go.mod new file mode 100644 index 0000000000..11b9cb0b75 --- /dev/null +++ b/go/glide/go.mod @@ -0,0 +1 @@ +module github.com/aws/glide-for-redis/go/glide diff --git a/go/glide/src/lib.rs b/go/glide/src/lib.rs new file mode 100644 index 0000000000..f0847900a4 --- /dev/null +++ b/go/glide/src/lib.rs @@ -0,0 +1,3 @@ +fn main() { + println!("Hello World!"); +} \ No newline at end of file