forked from kube-rs/kube
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Run e2e,integration tests against supported kubernetes versions (kube…
…-rs#924) * Run e2e tests against supported kubernetes versions As part of Kubernetes version policies proposed in kube-rs/website#19 for kube-rs#684 Signed-off-by: clux <[email protected]> * add integration tests as specific job to run it against mk8sv Signed-off-by: clux <[email protected]> * rename tests and try to fix integration Signed-off-by: clux <[email protected]> * fix k3d args? Signed-off-by: clux <[email protected]> * fix e2e Signed-off-by: clux <[email protected]> * test against v1.19 Signed-off-by: clux <[email protected]> * badge update Signed-off-by: clux <[email protected]> * s/MINK8SV/MK8SV Signed-off-by: clux <[email protected]> * Big e2e rework (WIP) Now two e2e tests, and more feature combinations. Signed-off-by: clux <[email protected]> * avoid rustls local due to the issues Signed-off-by: clux <[email protected]> * split e2e tests into own file and clean up when to matrix Signed-off-by: clux <[email protected]> * running bump-k8s also bumps mk8sv Signed-off-by: clux <[email protected]> * avoid illegal anchors and add badge bumping Signed-off-by: clux <[email protected]> * better version checks for mk8sv and msrv on ci Signed-off-by: clux <[email protected]> * move some ci around for consistency in naming Signed-off-by: clux <[email protected]> * stray command Signed-off-by: clux <[email protected]> * fix syntax errors? Signed-off-by: clux <[email protected]> * fix test warning from kube-derive after apiext removal Signed-off-by: clux <[email protected]> * evars from tests Signed-off-by: clux <[email protected]> * better run description on integration jobs Signed-off-by: clux <[email protected]> * better output for flaky integration test Signed-off-by: clux <[email protected]> * fmt + give test more time? Signed-off-by: clux <[email protected]> * sanity after timeout. seems likely cause. Signed-off-by: clux <[email protected]> * no need for an agent in k3d cmd Signed-off-by: clux <[email protected]> * how slow is this actions cluster? Signed-off-by: clux <[email protected]> * re-trigger once more to check * apiserver, are you ok? Signed-off-by: clux <[email protected]> * another empty commit to retrigger Signed-off-by: clux <[email protected]> * remove duplicate changes from kube-rs#924 (won't build until that is merged) Signed-off-by: clux <[email protected]>
- Loading branch information
Showing
18 changed files
with
363 additions
and
200 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,12 @@ | ||
name: CI | ||
name: test | ||
on: | ||
pull_request: | ||
|
||
env: | ||
RUST_BACKTRACE: 1 | ||
|
||
jobs: | ||
cargo-test: | ||
unit: | ||
strategy: | ||
# Prevent GitHub from cancelling all in-progress jobs when a matrix job fails. | ||
fail-fast: false | ||
|
@@ -66,7 +69,7 @@ jobs: | |
run: cargo test -p kube-examples --example crd_derive_no_schema --no-default-features --features=openssl-tls,latest | ||
if: matrix.os == 'ubuntu-latest' | ||
|
||
check-msrv: | ||
msrv: | ||
# Run `cargo check` on our minimum supported Rust version | ||
runs-on: ubuntu-latest | ||
steps: | ||
|
@@ -89,6 +92,18 @@ jobs: | |
command: check | ||
args: --all | ||
|
||
- name: Check rust-version keys matches MSRV consistently | ||
run: | | ||
if [[ $(cat ./*/Cargo.toml | grep "rust-version" | uniq | wc -l) -gt 1 ]]; then | ||
echo "inconsistent rust-version keys set in various kube-crates:" | ||
rg "rust-version" ./*/Cargo.toml | ||
exit 1 | ||
fi | ||
if ! cat kube/Cargo.toml | grep "rust-version" | grep "${{ steps.msrv.outputs.msrv }}"; then | ||
echo "msrv policy inconsistent with rust-version key" | ||
exit 1 | ||
fi | ||
- name: Check devcontainer matches MSRV | ||
run: | | ||
versions=$(sed -nE 's|^FROM (.*/)?rust:([^ ]+)|\2|p' .devcontainer/Dockerfile) | ||
|
@@ -100,86 +115,170 @@ jobs: | |
exit 1 | ||
fi | ||
e2e: | ||
# e2e tests are docker on linux | ||
integration: | ||
runs-on: ubuntu-latest | ||
strategy: | ||
# Prevent GitHub from cancelling all in-progress jobs when a matrix job fails. | ||
fail-fast: false | ||
matrix: | ||
# Run these tests against older clusters as well | ||
k8s: [v1.19, latest] | ||
steps: | ||
- uses: actions/checkout@v2 | ||
- uses: actions-rs/toolchain@v1 | ||
with: | ||
override: true | ||
toolchain: stable | ||
profile: minimal | ||
# Smart caching for Rust projects. | ||
# Includes workaround for macos cache corruption. | ||
# - https://github.com/rust-lang/cargo/issues/8603 | ||
# - https://github.com/actions/cache/issues/403 | ||
- uses: Swatinem/rust-cache@v1 | ||
|
||
- uses: nolar/setup-k3d-k3s@v1 | ||
with: | ||
version: ${{matrix.k8s}} | ||
# k3d-kube | ||
k3d-name: kube | ||
# Used to avoid rate limits when fetching the releases from k3s repo. | ||
# Anonymous access is limited to 60 requests / hour / worker | ||
# github-token: ${{ secrets.GITHUB_TOKEN }} | ||
k3d-args: "--no-lb --k3s-arg --no-deploy=traefik,servicelb,metrics-server@server:*" | ||
|
||
# Real CI work starts here | ||
- name: Build workspace | ||
run: cargo build | ||
|
||
# Run the equivalent of `just integration` | ||
- name: Run all default features integration library tests | ||
run: cargo test --lib --all -- --ignored | ||
- name: Run all facade integration library tests with extra features | ||
run: cargo test -p kube --lib --features=derive,runtime -- --ignored --nocapture | ||
- name: Run all client integration library tests with rustls and ws | ||
run: cargo test -p kube-client --lib --features=rustls-tls,ws -- --ignored | ||
- name: Run derive example tests | ||
run: cargo run -p kube-examples --example crd_derive | ||
- name: Run crd example tests | ||
run: cargo run -p kube-examples --example crd_api | ||
|
||
|
||
mk8sv: | ||
# comile check e2e tests against mk8sv | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v2 | ||
|
||
- name: Find MK8SV | ||
id: mk8sv | ||
run: | | ||
MK8SV=$(grep MK8SV README.md | grep -oE "[[:digit:]]+\.[[:digit:]]+" | head -n 1) | ||
echo $MK8SV | ||
echo ::set-output name=mk8sv::${MK8SV} | ||
echo ::set-output name=mk8svdash::v${MK8SV/\./_} | ||
- name: Check ci jobs run against advertised MK8SV | ||
run: | | ||
if ! grep "${{ steps.mk8sv.outputs.mk8sv }}" -q .github/workflows/ci.yml; then | ||
echo "mk8sv not set correctly in tests" | ||
exit 1 | ||
fi | ||
if ! grep "${{ steps.mk8sv.outputs.mk8svdash }}" e2e/Cargo.toml | grep mk8sv; then | ||
echo "mk8sv not set correctly in e2e features" | ||
exit 1 | ||
fi | ||
- uses: actions-rs/toolchain@v1 | ||
with: | ||
override: true | ||
toolchain: stable | ||
profile: minimal | ||
# Smart caching for Rust projects. | ||
# Includes workaround for macos cache corruption. | ||
# - https://github.com/rust-lang/cargo/issues/8603 | ||
# - https://github.com/actions/cache/issues/403 | ||
- uses: Swatinem/rust-cache@v1 | ||
|
||
- uses: nolar/setup-k3d-k3s@v1 | ||
with: | ||
version: v1.19 | ||
# k3d-kube | ||
k3d-name: kube | ||
# Used to avoid rate limits when fetching the releases from k3s repo. | ||
# Anonymous access is limited to 60 requests / hour / worker | ||
# github-token: ${{ secrets.GITHUB_TOKEN }} | ||
k3d-args: "--no-lb --k3s-arg --no-deploy=traefik,servicelb,metrics-server@server:*" | ||
|
||
# Real CI work starts here | ||
- name: Build workspace | ||
run: cargo build | ||
|
||
- name: boot openssl, latest k8s | ||
run: cargo run -p e2e --bin boot --features=openssl,latest | ||
- name: boot openssl, minimum supported k8s | ||
run: cargo run -p e2e --bin boot --features=openssl,mk8sv | ||
# no rustls local yet: https://github.com/kube-rs/kube-rs/issues/153 | ||
# we could edit kubeconfig and /etc/hosts to have the following lines: | ||
# /etc/hosts: 127.0.0.1 k3d.local | ||
# kubeconfig: server: https://k3d.local:36729 (e.g. swap out 0.0.0.0 under cluster) | ||
# Together, that makes it work locally. Maybe that can be done with some k3d-args to host-aliases. | ||
#- name: boot rustls, latest k8s | ||
# run: cargo run -p e2e --bin boot --features=rustls,latest | ||
#- name: boot rustls, minimum supported k8s | ||
# run: cargo run -p e2e --bin boot --features=rustls,mk8sv | ||
|
||
in-cluster: | ||
# in-cluster e2e via docker on linux | ||
runs-on: ubuntu-latest | ||
strategy: | ||
# Prevent GitHub from cancelling all in-progress jobs when a matrix job fails. | ||
fail-fast: false | ||
matrix: | ||
tls: [openssl, rustls] | ||
steps: | ||
- uses: actions/checkout@v2 | ||
- uses: actions/cache@v2 | ||
with: | ||
path: | | ||
~/.cargo/registry/index | ||
~/.cargo/registry/cache | ||
~/.cargo/git | ||
target | ||
key: musl-cargo-${{ hashFiles('**/Cargo.toml') }} | ||
key: musl-cargo-${{ hashFiles('**/Cargo.toml') }}-${{matrix.tls}} | ||
|
||
- uses: nolar/setup-k3d-k3s@v1 | ||
with: | ||
version: v1.20 | ||
version: latest | ||
# k3d-kube | ||
k3d-name: kube | ||
# Used to avoid rate limits when fetching the releases from k3s repo. | ||
# Anonymous access is limited to 60 requests / hour / worker | ||
# github-token: ${{ secrets.GITHUB_TOKEN }} | ||
k3d-args: "--no-lb --k3s-arg --no-deploy=traefik,servicelb,metrics-server@server:*" | ||
|
||
- name: Compile dapp | ||
- name: Compile e2e job against ${{matrix.tls}} | ||
run: | | ||
mkdir -p ~/.cargo/{git,registry} | ||
docker run --rm -t \ | ||
--mount type=bind,source=${{ github.workspace }},target=/volume \ | ||
--mount type=bind,source=$HOME/.cargo/registry,target=/root/.cargo/registry \ | ||
--mount type=bind,source=$HOME/.cargo/git,target=/root/.cargo/git \ | ||
clux/muslrust:stable \ | ||
cargo build -p e2e --release -v | ||
cp target/x86_64-unknown-linux-musl/release/dapp e2e/ | ||
cargo build -p e2e --release --bin=job --features=latest,${{matrix.tls}} -v | ||
cp target/x86_64-unknown-linux-musl/release/job e2e/ | ||
- name: Build image | ||
run: "docker build -t clux/kube-dapp:${{ github.sha }} e2e/" | ||
run: "docker build -t clux/kube-e2e:${{ github.sha }} e2e/" | ||
- name: Import image | ||
run: "k3d image import clux/kube-dapp:${{ github.sha }} --cluster kube" | ||
run: "k3d image import clux/kube-e2e:${{ github.sha }} --cluster kube" | ||
- run: sed -i 's/latest/${{ github.sha }}/g' e2e/deployment.yaml | ||
|
||
- name: Create resource | ||
run: kubectl apply -f e2e/deployment.yaml -n apps | ||
- run: kubectl get all -n apps | ||
- run: kubectl describe jobs/dapp -n apps | ||
- run: kubectl describe jobs/e2e -n apps | ||
- name: Wait for job to complete | ||
run: | | ||
kubectl wait --for=condition=complete job/dapp -n apps --timeout=50s || kubectl logs -f job/dapp -n apps | ||
kubectl wait --for=condition=complete job/e2e -n apps --timeout=50s || kubectl logs -f job/e2e -n apps | ||
kubectl get all -n apps | ||
kubectl wait --for=condition=complete job/dapp -n apps --timeout=10s || kubectl get pods -n apps | grep dapp | grep Completed | ||
cargo-deny: | ||
name: Run cargo deny | ||
runs-on: ubuntu-latest | ||
strategy: | ||
matrix: | ||
checks: | ||
- advisories | ||
- bans licenses sources | ||
|
||
# Prevent sudden announcement of a new advisory from failing ci: | ||
continue-on-error: ${{ matrix.checks == 'advisories' }} | ||
|
||
steps: | ||
- uses: actions/checkout@v2 | ||
- uses: EmbarkStudios/cargo-deny-action@v1 | ||
with: | ||
command: check ${{ matrix.checks }} | ||
|
||
rustfmt: | ||
name: Run rustfmt | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v2 | ||
- uses: actions-rs/[email protected] | ||
with: | ||
profile: minimal | ||
toolchain: nightly | ||
components: rustfmt | ||
override: true | ||
- name: Run rustfmt | ||
id: rustfmt | ||
run: rustfmt +nightly --edition 2018 --check $(find . -type f -iname *.rs) | ||
kubectl wait --for=condition=complete job/e2e -n apps --timeout=10s || kubectl get pods -n apps | grep e2e | grep Completed |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
name: lint | ||
on: | ||
pull_request: | ||
|
||
jobs: | ||
cargo-deny: | ||
name: cargo deny | ||
runs-on: ubuntu-latest | ||
strategy: | ||
matrix: | ||
checks: | ||
- advisories | ||
- bans licenses sources | ||
|
||
# Prevent sudden announcement of a new advisory from failing ci: | ||
continue-on-error: ${{ matrix.checks == 'advisories' }} | ||
|
||
steps: | ||
- uses: actions/checkout@v2 | ||
- uses: EmbarkStudios/cargo-deny-action@v1 | ||
with: | ||
command: check ${{ matrix.checks }} | ||
|
||
rustfmt: | ||
name: rustfmt | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v2 | ||
- uses: actions-rs/[email protected] | ||
with: | ||
profile: minimal | ||
toolchain: nightly | ||
components: rustfmt | ||
override: true | ||
- name: Run rustfmt | ||
id: rustfmt | ||
run: rustfmt +nightly --edition 2018 --check $(find . -type f -iname *.rs) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.