-
Notifications
You must be signed in to change notification settings - Fork 68
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
1. Combine workflows (general, go, metallb_e2e, olm, upgrade) under one workflow, leveraging the "needs" option for code reuse and requiring successful dependent jobs, thus improving readability. 2. Add merge_group. 3. Add composite. Signed-off-by: shimritproj <[email protected]>
- Loading branch information
1 parent
fbc3c30
commit cfd8cd0
Showing
8 changed files
with
360 additions
and
496 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 |
---|---|---|
@@ -0,0 +1,297 @@ | ||
name: CI | ||
|
||
on: | ||
merge_group: | ||
pull_request: | ||
branches: | ||
- "main" | ||
- "v[0-9]+.[0-9]+.[0-9]+" | ||
- "v[0-9]+.[0-9]+" | ||
workflow_dispatch: | ||
|
||
jobs: | ||
lint: | ||
name: Lint | ||
runs-on: ubuntu-20.04 | ||
steps: | ||
- name: Cancel Previous Runs | ||
uses: styfle/[email protected] | ||
with: | ||
access_token: ${{ github.token }} | ||
|
||
- name: Check out code | ||
uses: actions/checkout@v2 | ||
|
||
- name: Verify | ||
uses: golangci/golangci-lint-action@v2 | ||
with: | ||
version: v1.51.2 | ||
args: --timeout=15m0s --verbose | ||
unit: | ||
runs-on: ubuntu-20.04 | ||
name: Unit and Integration tests | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v2 | ||
- name: Setup | ||
uses: ./.github/workflows/composite/setup | ||
- name: Verify manifests | ||
run: | | ||
make manifests | ||
git diff --exit-code | ||
- name: Verify bin dir | ||
run: | | ||
BIN_FILE="metallb-operator.yaml" make bin | ||
git diff --exit-code bin/ | ||
- name: Unit and Integration Tests | ||
run: | | ||
export KUBECONFIG=${HOME}/.kube/config | ||
METALLB_BGP_TYPE=native make test | ||
METALLB_BGP_TYPE=frr DEPLOY_KUBE_RBAC_PROXIES=true make test | ||
e2e: | ||
runs-on: ubuntu-20.04 | ||
env: | ||
built_image: "metallb-operator:ci" # Arbitrary name | ||
needs: | ||
- lint | ||
- unit | ||
defaults: | ||
run: | ||
shell: bash | ||
working-directory: metallboperator | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v2 | ||
- name: Setup | ||
uses: ./.github/workflows/composite/setup | ||
- name: Build image | ||
run: | | ||
IMG=${built_image} make docker-build | ||
- name: Create K8s Kind Cluster | ||
run: | | ||
./hack/kind-cluster-without-registry.sh | ||
kind load docker-image ${built_image} | ||
- name: Deploy Metal LB Operator | ||
run: | | ||
IMG=${built_image} KUSTOMIZE_DEPLOY_DIR="config/kind-ci/" make deploy | ||
- name: E2E Tests | ||
run: | | ||
export KUBECONFIG=${HOME}/.kube/config | ||
make test-validation | ||
make test-e2e | ||
- name: Collect Logs | ||
uses: ./.github/workflows/composite/collectlogs | ||
olm: | ||
runs-on: ubuntu-20.04 | ||
needs: | ||
- lint | ||
- unit | ||
defaults: | ||
run: | ||
shell: bash | ||
working-directory: metallboperator | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v2 | ||
- name: Setup | ||
uses: ./.github/workflows/composite/setup | ||
|
||
- name: Verify release bundle manifests | ||
run: | | ||
make bundle-release | ||
git diff --exit-code -I'^ createdAt: ' bundle | ||
- name: Create and set up K8s Kind Cluster | ||
run: | | ||
./hack/kind-cluster-with-registry.sh | ||
make deploy-olm | ||
- name: Build bundle image | ||
run: | | ||
make build-and-push-bundle-images REPO=localhost:5000 | ||
- name: Deploy Metal LB Operator with OLM | ||
run: | | ||
make deploy-with-olm REPO=localhost:5000 | ||
- name: E2E Tests | ||
run: | | ||
export KUBECONFIG=${HOME}/.kube/config | ||
make test-validation | ||
make test-e2e | ||
- name: Collect Logs | ||
uses: ./.github/workflows/composite/collectlogs | ||
upgrade_version: | ||
runs-on: ubuntu-20.04 | ||
env: | ||
built_image_prev_release: "metallb-operator-prev-rel:ci" # Arbitrary name | ||
built_image: "metallb-operator:ci" # Arbitrary name | ||
name: Go 1.17 -> Go 1.20 | ||
needs: | ||
- lint | ||
- unit | ||
defaults: | ||
run: | ||
shell: bash | ||
working-directory: metallboperator | ||
steps: | ||
- name: Cancel Previous Runs | ||
uses: styfle/[email protected] | ||
with: | ||
access_token: ${{ github.token }} | ||
- name: Checkout Previous Release Metal LB Operator | ||
uses: actions/checkout@v2 | ||
with: | ||
path: metallboperator | ||
fetch-depth: 0 # Fetch all history for all tags and branches | ||
|
||
- uses: actions/setup-go@v2 | ||
with: | ||
go-version: '1.17' | ||
|
||
- name: Build image | ||
run: | | ||
IMG=${built_image_prev_release} make docker-build | ||
- name: Create K8s Kind Cluster | ||
run: | | ||
./hack/kind-cluster-without-registry.sh | ||
kind load docker-image ${built_image_prev_release} | ||
- name: Deploy Previous Release Metal LB Operator | ||
run: | | ||
make deploy-cert-manager | ||
IMG=${built_image_prev_release} KUSTOMIZE_DEPLOY_DIR="config/kind-ci/" ENABLE_OPERATOR_WEBHOOK="true" make deploy | ||
- name: E2E Tests | ||
run: | | ||
export KUBECONFIG=${HOME}/.kube/config | ||
make test-validation | ||
make test-e2e | ||
- name: Collect Logs | ||
uses: ./.github/workflows/composite/collectlogs | ||
|
||
- name: Checkout Latest Metal LB Operator | ||
uses: actions/checkout@v2 | ||
with: | ||
path: metallboperator-latest | ||
fetch-depth: 0 # Fetch all history for all tags and branches | ||
|
||
- uses: actions/setup-go@v2 | ||
with: | ||
go-version: '1.20' | ||
- name: Delete old controller-gen | ||
run: | | ||
rm $(which controller-gen) | ||
- name: Build image | ||
run: | | ||
cd ${GITHUB_WORKSPACE}/metallboperator-latest | ||
IMG=${built_image} make docker-build | ||
kind load docker-image ${built_image} | ||
- name: Deploy Metal LB Operator | ||
run: | | ||
cd ${GITHUB_WORKSPACE}/metallboperator-latest | ||
IMG=${built_image} KUSTOMIZE_DEPLOY_DIR="config/kind-ci/" make deploy | ||
- name: Ensure MetalLB operator is ready | ||
run: | | ||
sleep 5 | ||
while [ "$(kubectl get pods -n metallb-system -l control-plane='controller-manager' -o jsonpath='{.items[*].status.containerStatuses[0].ready}')" != "true" ]; do | ||
sleep 5 | ||
echo "Waiting for operator pod to be ready." | ||
done | ||
- name: E2E Tests | ||
run: | | ||
cd ${GITHUB_WORKSPACE}/metallboperator-latest | ||
export KUBECONFIG=${HOME}/.kube/config | ||
make test-validation | ||
make test-e2e | ||
- name: Collect Logs | ||
uses: ./.github/workflows/composite/collectlogs | ||
metallb_e2e: | ||
runs-on: ubuntu-20.04 | ||
env: | ||
built_image: "metallb-operator:ci" # Arbitrary name | ||
needs: | ||
- lint | ||
- unit | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v2 | ||
- name: Setup | ||
uses: ./.github/workflows/composite/setup | ||
- name: Verify manifests | ||
run: | | ||
make manifests | ||
git diff --exit-code | ||
- name: Read metallb ref | ||
id: metallb_ref | ||
run: | | ||
echo "content=$(cat ./hack/metallb_ref.txt)" >> $GITHUB_OUTPUT | ||
- name: Checkout MetalLB | ||
uses: actions/checkout@v2 | ||
with: | ||
repository: metallb/metallb | ||
path: metallb | ||
ref: "${{ steps.metallb_ref.outputs.content }}" | ||
- name: Checkout MetalLB v0.12 | ||
uses: actions/checkout@v2 | ||
with: | ||
repository: metallb/metallb | ||
path: metallb-0.12 | ||
- name: Install Dependencies | ||
run: | | ||
sudo apt-get update | ||
sudo apt-get install linux-modules-extra-$(uname -r) python3-pip arping ndisc6 | ||
sudo pip3 install -r ${GITHUB_WORKSPACE}/metallb/dev-env/requirements.txt | ||
go install github.com/onsi/ginkgo/v2/[email protected] | ||
- name: Build image | ||
run: | | ||
IMG=${built_image} make docker-build | ||
- name: Create multi-node K8s Kind Cluster | ||
run: | | ||
./hack/kind-multi-node-cluster-without-registry.sh | ||
kind load docker-image ${built_image} | ||
./hack/create_second_interface.sh | ||
- name: Deploy Prometheus | ||
run: | | ||
make deploy-prometheus | ||
- name: Deploy Metal LB Operator | ||
run: | | ||
IMG=${built_image} KUSTOMIZE_DEPLOY_DIR="config/frr-on-ci/" make deploy | ||
- name: Ensure MetalLB operator is ready | ||
run: | | ||
while [ "$(kubectl get pods -n metallb-system -l control-plane='controller-manager' -o jsonpath='{.items[*].status.containerStatuses[0].ready}')" != "true" ]; do | ||
sleep 5 | ||
echo "Waiting for operator pod to be ready." | ||
done | ||
- name: Enable MetalLB | ||
run: | | ||
export KUBECONFIG=${HOME}/.kube/config | ||
kubectl apply -f config/samples/metallb.yaml | ||
- name: MetalLB E2E Tests | ||
run: | | ||
cd ${GITHUB_WORKSPACE}/metallb | ||
sudo -E env "PATH=$PATH" inv e2etest --skip "IPV6|DUALSTACK" -e /tmp/kind_logs | ||
- name: MetalLB E2E Tests - backward compatible | ||
run: | | ||
patch ${GITHUB_WORKSPACE}/metallb-0.12/e2etest/pkg/config/update.go < ${GITHUB_WORKSPACE}/metallb/e2etest/backwardcompatible/patchfile | ||
cat <<EOF | kubectl apply -f - | ||
apiVersion: v1 | ||
kind: ConfigMap | ||
metadata: | ||
namespace: metallb-system | ||
name: config | ||
EOF | ||
cd ${GITHUB_WORKSPACE}/metallb-0.12 | ||
FOCUS="L2.*should work for ExternalTrafficPolicy=Cluster|BGP.*A service of protocol load balancer should work with.*IPV4 - ExternalTrafficPolicyCluster$|BGP.*should work with the given bfd profile.*IPV4 - default" | ||
sudo -E env "PATH=$PATH" inv e2etest --use-operator --focus "$FOCUS" -e /tmp/kind_logs | ||
- name: Change permissions for kind logs | ||
if: ${{ failure() }} | ||
run: | | ||
sudo chmod -R o+r /tmp/kind_logs | ||
- name: Archive kind logs | ||
if: ${{ failure() }} | ||
uses: actions/upload-artifact@v2 | ||
with: | ||
name: kind_logs | ||
path: /tmp/kind_logs |
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,32 @@ | ||
name: "collectlogs" | ||
description: "Collect and upload the logs" | ||
|
||
inputs: | ||
artifact-name: | ||
description: "the name of artifacts to store" | ||
required: true | ||
|
||
runs: | ||
using: "composite" | ||
steps: | ||
- name: Archive E2E Tests logs | ||
if: ${{ failure() }} | ||
uses: actions/upload-artifact@v2 | ||
with: | ||
name: test_e2e_logs | ||
path: /tmp/test_e2e_logs/ | ||
|
||
- name: Export kind logs | ||
shell: bash | ||
if: ${{ failure() }} | ||
run: | | ||
shell: bash | ||
working-directory: metallboperator | ||
kind export logs /tmp/kind_logs | ||
- name: Archive kind logs | ||
if: ${{ failure() }} | ||
uses: actions/upload-artifact@v2 | ||
with: | ||
name: kind_logs | ||
path: /tmp/kind_logs |
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,31 @@ | ||
name: "install-deps" | ||
description: "Install deps required for metallb CI" | ||
|
||
runs: | ||
using: "composite" | ||
steps: | ||
- name: Cancel Previous Runs | ||
uses: styfle/[email protected] | ||
with: | ||
access_token: ${{ github.token }} | ||
- name: Checkout Metal LB Operator | ||
uses: actions/checkout@v2 | ||
with: | ||
path: metallboperator | ||
fetch-depth: 0 # Fetch all history for all tags and branches | ||
|
||
- uses: actions/setup-go@v4 | ||
with: | ||
go-version-file: "go.mod" | ||
cache: true | ||
|
||
- name: Verify modules | ||
shell: bash | ||
run: | | ||
go mod verify | ||
- name: Verify format | ||
shell: bash | ||
run: | | ||
make fmt | ||
git diff --exit-code |
Oops, something went wrong.