Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

dev: Update build tooling #116

Merged
merged 1 commit into from
May 30, 2022
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
8 changes: 8 additions & 0 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,14 @@
"tamasfe.even-better-toml",
"zxh404.vscode-proto3"
],
"settings": {
"protoc": {
"path": "/usr/local/bin/protoc",
"options": [
"--proto_path=proto",
]
}
},
"runArgs": [
"--init"
],
Expand Down
28 changes: 28 additions & 0 deletions .github/workflows/go.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
name: go

on:
pull_request:
paths:
- go.*
- '**/*.go'
- '**/*.proto'
- justfile
- .github/workflows/go.yml

permissions:
contents: read

jobs:
go:
timeout-minutes: 5
runs-on: ubuntu-latest
steps:
- uses: extractions/setup-just@aa5d15c144db4585980a44ebfdd2cf337c4f14cb
- uses: actions/setup-go@b22fbbc2921299758641fab08929b4ac52b32923
with:
go-version: '1.17'
- uses: actions/checkout@2541b1294d2704b0964813337f33b291d3f8596b
- uses: ./.github/actions/install-protoc
- run: just go-mod-check
- run: just go-gen-check
- run: just go-build
2 changes: 2 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ name: release
on:
pull_request:
paths:
- justfile
- .github/workflows/release.yml
push:
tags:
Expand Down Expand Up @@ -49,6 +50,7 @@ jobs:
- uses: actions/checkout@dcd71f646680f2efd8db4afa5ad64fdcba30e748
- uses: ./.github/actions/install-protoc
- run: just rs-fetch
- run: just rs-gen-check
- run: just rs-test-build
- run: just rs-test

Expand Down
47 changes: 23 additions & 24 deletions .github/workflows/ci.yml → .github/workflows/rust.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,25 @@
name: CI
on: [pull_request]
name: rust

on:
pull_request:
paths:
- Cargo.*
- '**/*.rs'
- '**/*.proto'
- justfile
- .github/workflows/rust.yml

env:
CARGO_INCREMENTAL: 0
CARGO_NET_RETRY: 10
RUSTUP_MAX_RETRIES: 10

permissions:
contents: read

jobs:
rust_build:
name: Rust build
timeout-minutes: 5
rust-build:
timeout-minutes: 10
runs-on: ubuntu-latest
container:
image: docker://rust:1.60
Expand All @@ -15,12 +30,13 @@ jobs:
- uses: actions/checkout@2541b1294d2704b0964813337f33b291d3f8596b
- uses: ./.github/actions/install-protoc
- run: just rs-fetch
- run: just rs-gen-check
- run: just rs-clippy
- run: just rs-docs
- run: just rs-test-build
- run: just rs-test

rust_audit:
name: Rust audit
rust-deps:
timeout-minutes: 5
runs-on: ubuntu-latest
strategy:
Expand All @@ -35,20 +51,3 @@ jobs:
- uses: EmbarkStudios/cargo-deny-action@30ecad1d5873c1cc2cad10a33637371ca094768b
with:
command: check ${{ matrix.checks }}

go_build:
name: Go build
timeout-minutes: 5
runs-on: ubuntu-18.04
steps:
- uses: extractions/setup-just@aa5d15c144db4585980a44ebfdd2cf337c4f14cb
- uses: actions/setup-go@b22fbbc2921299758641fab08929b4ac52b32923
with:
go-version: '1.17'
- uses: actions/checkout@2541b1294d2704b0964813337f33b291d3f8596b
- uses: ./.github/actions/install-protoc
- name: Check go
run: |
export PATH="$(go env GOPATH)/bin:$PATH"
just go-check

31 changes: 31 additions & 0 deletions examples/gen.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
use std::{fs, path::PathBuf};

/// Read protobuf definitions from `./proto` to generate sources into `./src/gen`.
fn main() -> Result<(), Box<dyn std::error::Error>> {
// List all protobuf definitions.
let proto_dir = PathBuf::from("proto");
let mut proto_files = Vec::new();
for ent in fs::read_dir(&*proto_dir)? {
let ent = ent?;
if ent.metadata()?.is_file() {
let path = ent.path();
if path.extension().and_then(|e| e.to_str()) == Some("proto") {
proto_files.push(path);
}
}
}

// Generate rust bindings.
let out_dir = PathBuf::from("src").join("gen");
if let Err(e) = tonic_build::configure()
.build_client(true)
.build_server(true)
.out_dir(out_dir)
.compile(&*proto_files, &[proto_dir])
{
eprintln!("{}", e.to_string().replace("\\n", "\n").trim_end());
std::process::exit(1);
}

Ok(())
}
10 changes: 9 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1,9 +1,17 @@
module github.com/linkerd/linkerd2-proxy-api

go 1.14
go 1.17

require (
github.com/golang/protobuf v1.5.2
google.golang.org/grpc v1.46.2
google.golang.org/grpc/cmd/protoc-gen-go-grpc v1.2.0
google.golang.org/protobuf v1.28.0
)

require (
golang.org/x/net v0.0.0-20201021035429-f5854403a974 // indirect
golang.org/x/sys v0.0.0-20210119212857-b64e53b001e4 // indirect
golang.org/x/text v0.3.3 // indirect
google.golang.org/genproto v0.0.0-20200526211855-cb27e3aa2013 // indirect
)
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,8 @@ google.golang.org/grpc v1.33.1/go.mod h1:fr5YgcSWrqhRRxogOsw7RzIpsmvOZ6IcH4kBYTp
google.golang.org/grpc v1.36.0/go.mod h1:qjiiYl8FncCW8feJPdyg3v6XW24KsRHe+dy9BAGRRjU=
google.golang.org/grpc v1.46.2 h1:u+MLGgVf7vRdjEYZ8wDFhAVNmhkbJ5hmrA1LMWK1CAQ=
google.golang.org/grpc v1.46.2/go.mod h1:vN9eftEi1UMyUsIF80+uQXhHjbXYbm0uXoFCACuMGWk=
google.golang.org/grpc/cmd/protoc-gen-go-grpc v1.2.0 h1:TLkBREm4nIsEcexnCjgQd5GQWaHcqMzwQV0TX9pq8S0=
google.golang.org/grpc/cmd/protoc-gen-go-grpc v1.2.0/go.mod h1:DNq5QpG7LJqD2AamLZ7zvKE0DEpVl2BSEVjFycAAjRY=
google.golang.org/protobuf v0.0.0-20200109180630-ec00e32a8dfd/go.mod h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8=
google.golang.org/protobuf v0.0.0-20200221191635-4d8936d0db64/go.mod h1:kwYJMbMJ01Woi6D6+Kah6886xMZcty6N08ah7+eCXa0=
google.golang.org/protobuf v0.0.0-20200228230310-ab0ca4ff8a60/go.mod h1:cfTl7dwQJ+fmap5saPgwCLgHXTUD7jkjRqWcaiX5VyM=
Expand Down
Loading