Skip to content

Commit

Permalink
Merge pull request #40 from foriequal0/riir
Browse files Browse the repository at this point in the history
  • Loading branch information
foriequal0 authored Aug 12, 2024
2 parents dccd475 + 8af4791 commit 70f5d8b
Show file tree
Hide file tree
Showing 111 changed files with 9,437 additions and 4,646 deletions.
2 changes: 2 additions & 0 deletions .cargo/config.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[target.x86_64-pc-windows-msvc]
linker = "rust-lld.exe"
161 changes: 161 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,161 @@
name: "CI"
on:
push:
branches:
- main
pull_request:
branches:
- main

jobs:
check:
timeout-minutes: 3
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions-rust-lang/setup-rust-toolchain@v1
with:
components: rustfmt, clippy
- name: cargo fetch
run: cargo fetch --verbose
- name: cargo check
run: cargo check --all-features --all-targets
if: always()
- name: cargo fmt
uses: actions-rust-lang/rustfmt@v1
if: always()
- id: clippy
run: cargo clippy --all-features --all-targets
if: always()

test:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
kind_image:
- "v1.30.2"
- "v1.29.4"
- "v1.28.9"
- "v1.27.13"
- "v1.26.15"
- "v1.25.16"
- "v1.24.17"
env:
KIND_IMAGE: kindest/node:${{matrix.kind_image}}
steps:
- uses: actions/checkout@v4
- uses: actions-rust-lang/setup-rust-toolchain@v1
with:
rustflags: ""
- name: Setup kind
run: |
kind create cluster --image="$KIND_IMAGE" --name test-pgd
- run: cargo fetch --verbose
- run: cargo test --all-features
timeout-minutes: 5

tests-result:
runs-on: ubuntu-latest
needs: test
if: always()
steps:
- name: All tests ok
if: ${{ !(contains(needs.*.result, 'failure')) }}
run: exit 0
- name: Some tests failed
if: ${{ contains(needs.*.result, 'failure') }}
run: exit 1

lint-helm:
timeout-minutes: 1
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- run: helm lint charts/pod-graceful-drain --strict

build-image:
timeout-minutes: 5
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- run: |
docker build --file docker/build.Dockerfile \
--tag "pod-graceful-drain:latest" \
.
- run: docker image save --output pod-graceful-drain.tar pod-graceful-drain
- uses: actions/upload-artifact@v4
with:
name: pod-graceful-drain.tar
path: ./pod-graceful-drain.tar

smoke-test:
timeout-minutes: 3
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
kind_image:
- "v1.30.2"
- "v1.29.4"
- "v1.28.9"
- "v1.27.13"
- "v1.26.15"
- "v1.25.16"
- "v1.24.17"
env:
KIND_IMAGE: kindest/node:${{matrix.kind_image}}
needs:
- build-image
steps:
- uses: actions/checkout@v4
- name: Setup kind
run: |
kind create cluster --image="$KIND_IMAGE"
- uses: eifinger/setup-rye@v4
with:
version: '0.37.0'
- uses: actions/download-artifact@v4
with:
name: pod-graceful-drain.tar
- run: |
docker image load --input pod-graceful-drain.tar
kind load docker-image pod-graceful-drain:latest
- run: |
helm install pod-graceful-drain charts/pod-graceful-drain \
--create-namespace --namespace pod-graceful-drain \
--set image.repository=pod-graceful-drain --set image.tag=latest \
--set experimentalGeneralIngress=true \
--set logLevel=info\\,pod_graceful_drain=trace \
--wait=true --timeout=1m
- run: rye sync
- run: rye test
- name: Dump
if: always()
run: |
KUBECTL="kubectl --namespace pod-graceful-drain"
echo "::group::kubectl get"
${KUBECTL} get --ignore-not-found=true --output wide all
echo "::endgroup::"
echo "::group::kubectl describe"
${KUBECTL} describe all
echo "::endgroup::"
for POD in $(${KUBECTL} get pod -o=name); do
echo "::group::kubectl logs ${POD}"
${KUBECTL} logs --ignore-errors=true "${POD}"
echo "::endgroup::"
done
smoke-tests-result:
runs-on: ubuntu-latest
needs: smoke-test
if: always()
steps:
- name: All tests ok
if: ${{ !(contains(needs.*.result, 'failure')) }}
run: exit 0
- name: Some tests failed
if: ${{ contains(needs.*.result, 'failure') }}
run: exit 1
4 changes: 2 additions & 2 deletions .github/workflows/release-chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ jobs:
name: Publish chart
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
- id: package
name: Package charts
run: |
Expand All @@ -33,4 +33,4 @@ jobs:
git config user.email [email protected]
git config user.name pod-graceful-drain-bot
git commit -m "Updated chart index: ${ADDED_FILE}"
- run: git push origin gh-pages
- run: git push origin gh-pages
45 changes: 23 additions & 22 deletions .github/workflows/release-image.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,34 +2,35 @@ name: Release image
on:
push:
tags:
- v*
- v*
workflow_dispatch:
jobs:
build:
name: Publish image
runs-on: ubuntu-latest
env:
IMG_NAME: pod-graceful-drain
steps:
- uses: actions/checkout@v2
- uses: actions/setup-go@v2
with:
go-version: ^1.18
- uses: docker/login-action@v1
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.CR_PAT }}
- run: make docker-build
- name: Tag and push
run: |
GIT_VERSION=$(git describe --tags --dirty --always)
REGISTRY=ghcr.io/${{ github.repository_owner }}
IMG_NAME=pod-graceful-drain
- uses: actions/checkout@v4
- uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.CR_PAT }}
- run: |
docker build --file docker/build.Dockerfile \
--tag "$IMG_NAME:latest" \
.
- name: Tag and push
run: |
GIT_VERSION=$(git describe --tags --dirty --always)
REGISTRY=ghcr.io/${{ github.repository_owner }}
tag-and-push() { docker tag $1 $2 && docker push $2; }
tag-and-push() { docker tag $1 $2 && docker push $2; }
tag-and-push $IMG_NAME:latest $REGISTRY/$IMG_NAME:$GIT_VERSION
tag-and-push $IMG_NAME:latest $REGISTRY/$IMG_NAME:$GIT_VERSION
LATEST_TAG="$(git describe --tags --dirty --always --abbrev=0)"
if git diff --quiet "$LATEST_TAG"; then
tag-and-push $IMG_NAME:latest $REGISTRY/$IMG_NAME:latest
fi
LATEST_TAG="$(git describe --tags --dirty --always --abbrev=0)"
if git diff --quiet "$LATEST_TAG"; then
tag-and-push $IMG_NAME:latest $REGISTRY/$IMG_NAME:latest
fi
46 changes: 0 additions & 46 deletions .github/workflows/test.yaml

This file was deleted.

27 changes: 5 additions & 22 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,24 +1,7 @@
.venv/
*.egg-info/
__pycache__/

# Binaries for programs and plugins
*.exe
*.exe~
*.dll
*.so
*.dylib
bin
target/

# Test binary, build with `go test -c`
*.test

# Output of the go coverage tool, specifically when used with LiteIDE
*.out

# Kubernetes Generated files - skip generated files, except for vendored files

!vendor/**/zz_generated.*

# editor and IDE paraphernalia
.idea
*.swp
*.swo
*~
.idea/
1 change: 1 addition & 0 deletions .python-version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
3.12.3
Loading

0 comments on commit 70f5d8b

Please sign in to comment.