From 490e5389f5405d5a527afdfae6c98ad1ff534ce4 Mon Sep 17 00:00:00 2001 From: Jake Shadle Date: Mon, 4 Mar 2024 07:59:06 +0100 Subject: [PATCH] Move non-linux builds to github (#899) * Move non-linux builds to github This allows CI to still check windows/macos compile, but actually run in parallel rather than serializing on each platform and wasting valuable CI time * Separate clippy/deny/fmt into separate job * Remove spammy test output unless requested (or test fails) * Serialize on fetch * Move clippy/fmt/deny checks to github * SKip deny for now --- .github/workflows/ci.yml | 47 ++++++++++++++++++++++++++++++++++++++-- build/Makefile | 17 ++++++++++++--- cloudbuild.yaml | 21 ++++++++++++------ 3 files changed, 73 insertions(+), 12 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index aba5f33c38..7c0fbdb079 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -17,7 +17,7 @@ # with auto-merge enabled and update it to the latest `main`, forming a best-effort queue # of approved PRs. -name: Validate protobufs +name: CI on: push: @@ -30,10 +30,53 @@ concurrency: cancel-in-progress: true jobs: - validate: + lint: + name: Lint + runs-on: ubuntu-22.04 + steps: + - uses: actions/checkout@v4 + - uses: dtolnay/rust-toolchain@stable + with: + components: "clippy, rustfmt" + - uses: Swatinem/rust-cache@v2 + + # make sure all code has been formatted with rustfmt and linted with clippy + - name: rustfmt + run: cargo fmt -- --check --color always + + # run clippy to verify we have no warnings + - run: cargo fetch + - name: cargo clippy + run: cargo clippy --all-targets --all-features -- -D warnings + + validate-proto-bufs: + name: Validate proto bufs runs-on: ubuntu-22.04 steps: - uses: actions/checkout@v4 with: submodules: true - run: cargo run -p proto-gen -- validate + + build: + name: Build + strategy: + matrix: + os: [windows-2022, macos-14] + runs-on: ${{ matrix.os }} + steps: + - uses: actions/checkout@v4 + with: + submodules: true + - uses: dtolnay/rust-toolchain@stable + - uses: Swatinem/rust-cache@v2 + - run: cargo fetch + - run: cargo build + + deny-check: + runs-on: ubuntu-22.04 + if: false # skip until I've updated the action + steps: + - uses: actions/checkout@v4 + - name: deny check + uses: EmbarkStudios/cargo-deny-action@v1 diff --git a/build/Makefile b/build/Makefile index 629a67cd28..d9adf726a8 100644 --- a/build/Makefile +++ b/build/Makefile @@ -78,18 +78,29 @@ version: # Run all tests test: ensure-build-image test-quilkin test-examples test-docs -# test only the quilkin crate -test-quilkin: ensure-build-image +# In CI with split jobs that both fetch they will fail if run in parallel since +# cargo will be fighting with itself for some the same host directory that is +# mapped into the container, so instead just split it out to its own job +fetch-quilkin: ensure-build-image + docker run --rm $(common_rust_args) \ + --network=host \ + -e RUST_BACKTRACE=1 --entrypoint=cargo $(BUILD_IMAGE_TAG) fetch + +check-quilkin: ensure-build-image docker run --rm $(common_rust_args) \ --entrypoint=cargo $(BUILD_IMAGE_TAG) deny check docker run --rm $(common_rust_args) \ --entrypoint=cargo $(BUILD_IMAGE_TAG) clippy --tests -- -D warnings docker run --rm $(common_rust_args) \ --entrypoint=cargo $(BUILD_IMAGE_TAG) fmt -- --check + +# test only the quilkin crate, if you want to see test output regardless of test +# failure or success, set RUST_TEST_NOCAPTURE to something other than "0" +test-quilkin: ensure-build-image # --network=host because docker containers are not great at ipv6. docker run --rm $(common_rust_args) \ --network=host \ - -e RUST_BACKTRACE=1 --entrypoint=cargo $(BUILD_IMAGE_TAG) test -- --nocapture + -e RUST_BACKTRACE=1 --entrypoint=cargo $(BUILD_IMAGE_TAG) test # Run tests against the examples test-examples: ensure-build-image diff --git a/cloudbuild.yaml b/cloudbuild.yaml index 49d9b4a8ac..93d454065e 100644 --- a/cloudbuild.yaml +++ b/cloudbuild.yaml @@ -14,23 +14,30 @@ steps: - name: gcr.io/cloud-builders/git - args: [ submodule, update, --init, --recursive ] + args: [submodule, update, --init, --recursive] id: fetch-git-submodules waitFor: - "-" - name: gcr.io/cloud-builders/docker - args: [ pull, "${_BUILD_IMAGE_TAG}" ] + args: [pull, "${_BUILD_IMAGE_TAG}"] id: pull-build-image waitFor: - "-" # Run immediately, don't wait for any previous steps - name: us-docker.pkg.dev/$PROJECT_ID/ci/make-docker dir: ./build args: - - test-quilkin - id: test-quilkin + - fetch-quilkin + id: fetch-quilkin waitFor: - fetch-git-submodules - pull-build-image + - name: us-docker.pkg.dev/$PROJECT_ID/ci/make-docker + dir: ./build + args: + - test-quilkin + id: test-quilkin + waitFor: + - fetch-quilkin - name: us-docker.pkg.dev/$PROJECT_ID/ci/make-docker dir: ./build args: @@ -44,7 +51,7 @@ steps: - name: us-docker.pkg.dev/$PROJECT_ID/ci/make-docker dir: ./build args: - - build + - build-image id: build # @@ -56,7 +63,7 @@ steps: dir: ./build entrypoint: bash args: - - '-c' + - "-c" - 'timeout --signal=INT --preserve-status 5s docker run --rm -v "/workspace/examples/proxy.yaml:/etc/quilkin/quilkin.yaml" ${_REPOSITORY}quilkin:$(make version) proxy' id: test-quilkin-image-default-config-file waitFor: @@ -67,7 +74,7 @@ steps: dir: ./build entrypoint: bash args: - - '-c' + - "-c" - 'timeout --signal=INT --preserve-status 5s docker run -v /tmp:/etc/quilkin/ --rm ${_REPOSITORY}quilkin:$(make version) proxy --to="127.0.0.1:0"' id: test-quilkin-image-command-line waitFor: