generated from kubernetes/kubernetes-template-project
-
Notifications
You must be signed in to change notification settings - Fork 34
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
add ci for conformance tests #224
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 |
---|---|---|
@@ -0,0 +1,115 @@ | ||
name: conformance | ||
|
||
on: | ||
push: | ||
branches: | ||
- 'main' | ||
tags: | ||
- 'v*' | ||
pull_request: | ||
branches: [ main ] | ||
workflow_dispatch: | ||
|
||
env: | ||
GO_VERSION: "1.22.0" | ||
K8S_VERSION: "v1.29.2" | ||
KIND_VERSION: "v0.22.0" | ||
IMAGE_NAME: registry.k8s.io/networking/kube-network-policies | ||
KIND_CLUSTER_NAME: kind | ||
|
||
permissions: write-all | ||
|
||
jobs: | ||
conformance: | ||
name: conformance | ||
runs-on: ubuntu-22.04 | ||
timeout-minutes: 100 | ||
strategy: | ||
fail-fast: false | ||
matrix: | ||
ipFamily: ["ipv4", "ipv6"] | ||
env: | ||
JOB_NAME: "kube-network-policies-${{ matrix.ipFamily }}" | ||
IP_FAMILY: ${{ matrix.ipFamily }} | ||
steps: | ||
- name: Check out code | ||
uses: actions/checkout@v2 | ||
|
||
- name: Enable ipv4 and ipv6 forwarding | ||
run: | | ||
sudo sysctl -w net.ipv6.conf.all.forwarding=1 | ||
sudo sysctl -w net.ipv4.ip_forward=1 | ||
|
||
- name: Set up environment (download dependencies) | ||
run: | | ||
TMP_DIR=$(mktemp -d) | ||
# kubectl | ||
curl -L https://dl.k8s.io/${{ env.K8S_VERSION }}/bin/linux/amd64/kubectl -o ${TMP_DIR}/kubectl | ||
# kind | ||
curl -Lo ${TMP_DIR}/kind https://kind.sigs.k8s.io/dl/${{ env.KIND_VERSION }}/kind-linux-amd64 | ||
# Install | ||
sudo cp ${TMP_DIR}/kubectl /usr/local/bin/kubectl | ||
sudo cp ${TMP_DIR}/kind /usr/local/bin/kind | ||
sudo chmod +x /usr/local/bin/* | ||
|
||
- name: Create multi node cluster | ||
run: | | ||
# output_dir | ||
mkdir -p _artifacts | ||
# create cluster | ||
cat <<EOF | /usr/local/bin/kind create cluster \ | ||
--name ${{ env.KIND_CLUSTER_NAME}} \ | ||
--image kindest/node:${{ env.K8S_VERSION }} \ | ||
-v7 --wait 1m --retain --config=- | ||
kind: Cluster | ||
apiVersion: kind.x-k8s.io/v1alpha4 | ||
networking: | ||
ipFamily: ${IP_FAMILY} | ||
nodes: | ||
- role: control-plane | ||
- role: worker | ||
- role: worker | ||
EOF | ||
# dump the kubeconfig for later | ||
/usr/local/bin/kind get kubeconfig --name ${{ env.KIND_CLUSTER_NAME}} > _artifacts/kubeconfig.conf | ||
|
||
- name: Install kube-network-policies | ||
run: | | ||
# install CRDs | ||
/usr/local/bin/kubectl apply -f ./config/crd/experimental/policy.networking.k8s.io_adminnetworkpolicies.yaml | ||
/usr/local/bin/kubectl apply -f ./config/crd/experimental/policy.networking.k8s.io_baselineadminnetworkpolicies.yaml | ||
# install kube-network-policies | ||
/usr/local/bin/kubectl apply -f https://raw.githubusercontent.com/kubernetes-sigs/kube-network-policies/v0.2.0/install-anp.yaml | ||
|
||
- name: Get Cluster status | ||
run: | | ||
# wait network is ready | ||
sleep 5 | ||
/usr/local/bin/kubectl get nodes -o wide | ||
/usr/local/bin/kubectl get pods -A | ||
/usr/local/bin/kubectl wait --timeout=1m --for=condition=ready pods --namespace=kube-system -l k8s-app=kube-dns | ||
/usr/local/bin/kubectl wait --timeout=1m --for=condition=ready pods --namespace=kube-system -l app=kube-network-policies | ||
|
||
- name: Run tests | ||
run: | | ||
go mod download | ||
go test -v ./conformance -run TestConformanceProfiles -args --conformance-profiles=AdminNetworkPolicy,BaselineAdminNetworkPolicy --organization=kubernetes --project=kube-network-policies --url=https://github.com/kubernetes-sigs/kube-network-policies --version=0.2.0 [email protected] --additional-info=https://github.com/kubernetes-sigs/kube-network-policies | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. haha now I will add a second report :) to our implementations folder :D There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. feel free to modify as you like :) |
||
|
||
- name: Upload Junit Reports | ||
if: always() | ||
uses: actions/upload-artifact@v2 | ||
with: | ||
name: kind-junit-${{ env.JOB_NAME }}-${{ github.run_id }} | ||
path: './_artifacts/*.xml' | ||
|
||
- name: Export logs | ||
if: always() | ||
run: | | ||
/usr/local/bin/kind export logs --name ${KIND_CLUSTER_NAME} --loglevel=debug ./_artifacts/logs | ||
|
||
- name: Upload logs | ||
if: always() | ||
uses: actions/upload-artifact@v2 | ||
with: | ||
name: kind-logs-${{ env.JOB_NAME }}-${{ github.run_id }} | ||
path: ./_artifacts/logs |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm thinking we should also do a "Stable" run of the conformance suite as well, but we can tackle that in a follow up cc @tssurya
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yeah and its not a big deal since if we cover experimental that is pretty much standard + new fields so standard is automatically covered of sorts