Skip to content

Commit

Permalink
Add CI build workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
aaron-congo committed Feb 8, 2024
1 parent 48e563f commit a032fa5
Show file tree
Hide file tree
Showing 8 changed files with 147 additions and 0 deletions.
84 changes: 84 additions & 0 deletions .github/workflows/go.yml
Original file line number Diff line number Diff line change
@@ -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
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -49,3 +49,7 @@ utils/tls_crts/

# java compiled files.
*.class

# Go compilation files
go/**/lib.h
*.pb.go
3 changes: 3 additions & 0 deletions go/glide/.cargo/config.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[env]
GLIDE_NAME = { value = "GlideGo", force = true }
GLIDE_VERSION = "0.1.0"
27 changes: 27 additions & 0 deletions go/glide/Cargo.toml
Original file line number Diff line number Diff line change
@@ -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
16 changes: 16 additions & 0 deletions go/glide/build.rs
Original file line number Diff line number Diff line change
@@ -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");
}
9 changes: 9 additions & 0 deletions go/glide/glide.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package glide

import (
"fmt"
)

func main() {
fmt.Println("Hello world!")
}
1 change: 1 addition & 0 deletions go/glide/go.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
module github.com/aws/glide-for-redis/go/glide
3 changes: 3 additions & 0 deletions go/glide/src/lib.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
fn main() {
println!("Hello World!");
}

0 comments on commit a032fa5

Please sign in to comment.