Skip to content

Commit

Permalink
Move non-linux builds to github (#899)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
Jake-Shadle authored Mar 4, 2024
1 parent 0195d09 commit 490e538
Show file tree
Hide file tree
Showing 3 changed files with 73 additions and 12 deletions.
47 changes: 45 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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
17 changes: 14 additions & 3 deletions build/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
21 changes: 14 additions & 7 deletions cloudbuild.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -44,7 +51,7 @@ steps:
- name: us-docker.pkg.dev/$PROJECT_ID/ci/make-docker
dir: ./build
args:
- build
- build-image
id: build

#
Expand All @@ -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:
Expand All @@ -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:
Expand Down

0 comments on commit 490e538

Please sign in to comment.