Skip to content

Commit 497f938

Browse files
authored
Build tooling updates and fixes. (#974)
* Build tooling updates and fixes. I stared with documenting how to regenerate protos, and found a few things that were blocking release, and also was just broken. So this PR includes: * Documenting how to regenerate protos with `cargo` and `make`. * `make` targets for generating protobuf * Fixes and updates for build tooling for release. * Updates to rust version - which aligns with the available darwin builder image tags. * Replace `live-server` which broke as unmaintained with `browser-sync` which is also way better. * * Fixes for lint issues. * Rollback to rust 1.77.1 * There's a joseluisq/rust-linux-darwin-builder:1.77.1 image, but no 1.77.0 image 🤷🏻‍♂️ - so need to update so we can release macos binaries. * Can't upgrade to 1.78.0 because of tikv/pprof-rs#232
1 parent d312e4c commit 497f938

File tree

6 files changed

+34
-23
lines changed

6 files changed

+34
-23
lines changed

build/Makefile

+14-9
Original file line numberDiff line numberDiff line change
@@ -131,14 +131,19 @@ build: binary-archive build-image
131131
# Build all binaries
132132
build-all-binaries: ensure-build-image build-linux-binary build-macos-binary build-windows-binary
133133

134+
# Checks for changes to protobuf definitions and generates rust code if there is any.
135+
gen-protobuf: ensure-build-image
136+
docker run --rm $(DOCKER_RUN_ARGS) $(common_rust_args) \
137+
--entrypoint=cargo $(BUILD_IMAGE_TAG) run -p proto-gen -- generate
138+
134139
# Build an archive all binaries
135140
binary-archive: ensure-build-image build-licence-report build-all-binaries
136141
docker run --rm $(common_rust_args) -w $(CARGO_TARGET_DIR) \
137142
--entrypoint=bash $(BUILD_IMAGE_TAG) -c 'cp ../../license.html . && zip ../../quilkin-$(package_version).zip ./*/release/quilkin ./*/release/quilkin.exe ./license.html'
138143

139144
# Build binary for x86_64-unknown-linux-gnu.
140145
# Use BUILD_LOCAL=1 to build through local cargo rather than through the build container.
141-
build-linux-binary: ensure-build-image
146+
build-linux-binary: ensure-build-image gen-protobuf
142147
ifdef BUILD_LOCAL
143148
cargo $(cargo_build_x86_64_linux)
144149
else
@@ -148,7 +153,7 @@ endif
148153

149154
# Build binary for x86_64-pc-windows-gnu
150155
# Use BUILD_LOCAL=1 to build through local cargo rather than through the build container.
151-
build-windows-binary: ensure-build-image
156+
build-windows-binary: ensure-build-image gen-protobuf
152157
ifdef BUILD_LOCAL
153158
cargo $(cargo_build_x86_64_windows)
154159
else
@@ -158,7 +163,7 @@ endif
158163

159164
# Build binary for x86_64-apple-darwin and aarch64-apple-darwin
160165
# Use BUILD_LOCAL=1 to build through local cargo rather than through the build container.
161-
build-macos-binary:
166+
build-macos-binary: gen-protobuf
162167
ifdef BUILD_LOCAL
163168
cargo $(cargo_build_x86_64_apple)
164169
cargo $(cargo_build_aarch64-apple)
@@ -169,7 +174,8 @@ else
169174
-e "CC=o64-clang" -e "CXX=o64-clang++" \
170175
-e "PROTOC=/opt/protoc/bin/protoc" \
171176
joseluisq/rust-linux-darwin-builder:$(rust_toolchain) \
172-
sh -c "/workspace/build/darwin-builder/setup.sh && cargo $(cargo_build_x86_64_apple) --no-default-features && \
177+
sh -c "rustup target add x86_64-apple-darwin aarch64-apple-darwin && \
178+
cargo $(cargo_build_x86_64_apple) --no-default-features && \
173179
CC=oa64-clang CXX=oa64-clang++ LIBZ_SYS_STATIC=1 cargo $(cargo_build_aarch64-apple) --no-default-features"
174180
endif
175181

@@ -242,24 +248,23 @@ minikube-test-agones: minikube-push
242248
$(MAKE) DOCKER_RUN_ARGS="$(minikube_args)" run-test-agones
243249

244250
# Runs mdbook and cargo doc in the same directory structure as what is hosted on Github pages.
245-
# Open http://localhost:3000/book/index.html or http://localhost:3000/api/quilkin/index.html after running. Pages will live reload on change.
246-
# (the .html extension is required for hot reload, but pages will display without it)
251+
# Open http://localhost:3000/ after running and browse to the docs you are editing. Pages will live reload on change.
247252
# Use `GITHUB_REF_NAME` (default: `main`) to specify the branch or tag to point Github links to and `QUILKIN_VERSION`
248253
# (default `$(make version)) to specify which Quilkin version the documentation uses for examples.
249254
docs: ensure-build-image
250255
docs: GITHUB_REF_NAME ?= main
251256
docs: QUILKIN_VERSION ?= $(shell $(MAKE) version)
252257
docs:
253-
@echo "📭 Open browser to http://localhost:3000/book/index.html or http://localhost:3000/api/quilkin/index.html (the .html extension is required for hot reload)"
258+
@echo "📭 Open browser to http://localhost:3000/ and browse as needed"
254259
docker run -it --rm $(common_rust_args) -p 3000:3000 \
255260
-e GITHUB_REF_NAME=$(GITHUB_REF_NAME) -e QUILKIN_VERSION=$(QUILKIN_VERSION) \
256261
--entrypoint=bash $(BUILD_IMAGE_TAG) -c \
257-
'mkdir /tmp/docs && (live-server -p 3000 /tmp/docs &) && \
262+
'mkdir /tmp/docs && (browser-sync start --server "/tmp/docs" --directory --index index.html --port 3000 --no-open --files "/tmp/docs" &) && \
258263
mkdir -p "$(CARGO_TARGET_DIR)/doc"; ln -s "$(CARGO_TARGET_DIR)/doc" /tmp/docs/api && \
259264
cargo watch -s "cargo doc --workspace --no-deps && cd docs && mdbook build --dest-dir /tmp/docs/book"'
260265

261266
# Start an interactive shell inside the build image
262-
# Useful for testing, or adhoc cargo, gcloud, kubectl or terraform commands
267+
# Useful for testing, or adhoc cargo, gcloud, kubectl or other commands
263268
shell: ensure-gcloud-dirs ensure-kube-dirs ensure-build-image
264269
# we --network=host because docker containers are not great at ipv6.
265270
docker run --rm -it $(DOCKER_RUN_ARGS) $(common_rust_args) \

build/README.md

+12-8
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,17 @@ To build a production release, run:
3737

3838
`cargo build --release`
3939

40+
##### Generating Protobuf Files
41+
42+
If you are adding or editing the `.proto` files in this repository, they will need to be regenerated. To do this,
43+
you will need [protoc](https://grpc.io/docs/protoc-installation/) installed locally.
44+
45+
Then run:
46+
47+
`cargo run -p proto-gen -- generate`
48+
49+
Which will identify changes in protobuf definitions and regenerate code appropriately.
50+
4051
#### Testing
4152

4253
To run the unit, integration and docs tests:
@@ -53,7 +64,7 @@ To test dependency licences and security advisories:
5364

5465
`cargo deny check`
5566

56-
See the [agones](../agones) folder for the [Agones](https://agones.dev) integration testing tooling.
67+
See the [agones](../crates/agones) folder for the [Agones](https://agones.dev) integration testing tooling.
5768

5869
### Developing with Make + Docker
5970

@@ -70,13 +81,6 @@ To use the tooling for Make + Docker testing and development, you will need:
7081
* Make installed
7182
* [Docker installed](https://docs.docker.com/get-docker/)
7283

73-
#### Known issues
74-
75-
* If you are running on an arm64 machine, such as an M1 Mac, `make build-macos-binary` to build an amd64 macOS
76-
binary will fail. Depending on your setup, it may be possible to use `BUILD_LOCAL=1 make build-macos-binary` to
77-
attempt to build the binary with local `cargo` tooling. This is generally only a release time task, so we expect
78-
it to be of minimal impact. See [#608](https://github.com/googleforgames/quilkin/issues/608) for more details.
79-
8084
#### Run tests
8185

8286
`make test` will run all tests for this project, except the [Agones](https:/agones.dev) integration tests.

build/build-image/Dockerfile

+5-5
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15-
FROM debian:bullseye
15+
FROM debian:bookworm
1616

1717
ARG RUST_TOOLCHAIN
1818

@@ -25,9 +25,9 @@ ENV RUSTUP_HOME=/usr/local/rustup \
2525
# Install packages
2626
RUN set -eux && \
2727
apt-get update && \
28-
apt-get install -y lsb-release jq curl wget zip git build-essential software-properties-common \
29-
libssl-dev pkg-config python3-pip bash-completion g++-x86-64-linux-gnu g++-mingw-w64-x86-64 && \
30-
pip3 install live-server && \
28+
apt-get install -y lsb-release jq curl wget zip git build-essential software-properties-common protobuf-compiler \
29+
libssl-dev pkg-config nodejs npm bash-completion g++-x86-64-linux-gnu g++-mingw-w64-x86-64 && \
30+
npm install -g browser-sync && \
3131
echo "source /etc/bash_completion" >> /root/.bashrc
3232

3333
# install gcloud
@@ -38,7 +38,7 @@ RUN echo "deb [signed-by=/usr/share/keyrings/cloud.google.gpg] https://packages.
3838
echo "source <(kubectl completion bash)" >> /root/.bashrc
3939

4040
# install terraform. There is no apt support for arm64, so direct downloading instead.
41-
RUN wget --quiet -O terraform.zip "https://releases.hashicorp.com/terraform/1.3.1/terraform_1.3.1_linux_$(dpkg --print-architecture).zip" && \
41+
RUN wget --quiet -O terraform.zip "https://releases.hashicorp.com/terraform/1.5.4/terraform_1.5.4_linux_$(dpkg --print-architecture).zip" && \
4242
unzip terraform.zip && rm terraform.zip && mv terraform /usr/local/bin/
4343

4444
# install helm

rust-toolchain.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,5 +13,5 @@
1313
# limitations under the License.
1414

1515
[toolchain]
16-
channel = "1.77.0"
16+
channel = "1.77.1"
1717
components = ["rustfmt", "clippy"]

src/filters/registry.rs

+1
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ mod tests {
7070
use crate::filters::{Filter, FilterError, FilterRegistry, ReadContext, WriteContext};
7171
use crate::net::endpoint::{Endpoint, EndpointAddress};
7272

73+
#[allow(dead_code)]
7374
struct TestFilter {}
7475

7576
#[async_trait::async_trait]

src/net/phoenix.rs

+1
Original file line numberDiff line numberDiff line change
@@ -570,6 +570,7 @@ mod tests {
570570
use tokio::sync::Mutex;
571571

572572
#[derive(Clone)]
573+
#[allow(dead_code)]
573574
struct LoggingMockMeasurement {
574575
latencies: HashMap<SocketAddr, DistanceMeasure>,
575576
probed_addresses: Arc<Mutex<HashSet<SocketAddr>>>,

0 commit comments

Comments
 (0)