Skip to content
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

ci fix #40

Merged
merged 7 commits into from
Feb 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
145 changes: 68 additions & 77 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -47,18 +47,13 @@ jobs:
run: |
echo "version=v$(head ./version | cut -d' ' -f1)" >> $GITHUB_OUTPUT

- name: Check tag for current version
uses: mukunku/tag-exists-action@v1.0.0
id: check_tag
with:
tag: ${{ steps.get_version.outputs.version }}
env:
GITHUB_TOKEN: ${{ secrets.ENV_GITHUB_PAT }}

- name: Publishing Artifacts
if: steps.check_tag.outputs.exists == 'false'
- name: Generate Artifacts
run: |
GITHUB_USER=${{ secrets.ENV_GITHUB_USER }} GITHUB_PAT=${{ secrets.ENV_GITHUB_PAT }} ./ci.sh publish ${{ steps.get_branch.outputs.branch }}
chmod u+x ./ci.sh
./ci.sh gen_artifacts

- uses: actions/upload-artifact@master
with:
Expand All @@ -85,7 +80,9 @@ jobs:

- name: Copy Artifacts
run: |
cp release/ixiatg-operator.yaml tests/deployments
cp release/ixiatg-operator.yaml tests/deployments \
&& cp release/keng-operator.tar.gz tests/deployments \
&& ls tests/deployments

- name: Setup KNE cluster
run: |
Expand Down Expand Up @@ -132,6 +129,7 @@ jobs:
- name: Copy Artifacts
run: |
cp release/ixiatg-operator.yaml tests/deployments
cp release/keng-operator.tar.gz tests/deployments

- name: Setup KNE cluster
run: |
Expand Down Expand Up @@ -177,6 +175,7 @@ jobs:
- name: Copy Artifacts
run: |
cp release/ixiatg-operator.yaml tests/deployments
cp release/keng-operator.tar.gz tests/deployments

- name: Setup KNE cluster
run: |
Expand Down Expand Up @@ -221,6 +220,7 @@ jobs:
- name: Copy Artifacts
run: |
cp release/ixiatg-operator.yaml tests/deployments
cp release/keng-operator.tar.gz tests/deployments

- name: Setup KNE cluster
run: |
Expand Down Expand Up @@ -266,6 +266,7 @@ jobs:
- name: Copy Artifacts
run: |
cp release/ixiatg-operator.yaml tests/deployments
cp release/keng-operator.tar.gz tests/deployments

- name: Setup KNE cluster
run: |
Expand All @@ -290,50 +291,49 @@ jobs:
run: |
./ci.sh destroy_setup

# miscellaneous:
# needs: build
# runs-on: ubuntu-22.04
# steps:
# - name: Checkout source
# uses: actions/checkout@v3
# - name: Setup docker
# uses: docker-practice/actions-setup-docker@master
# - name: Setup Go
# uses: actions/setup-go@v3
# with:
# go-version: ${{ env.GO_VERSION }}
# - name: Get Artifacts
# uses: actions/download-artifact@master
# with:
# name: release-artifact
# path: release/

# - name: Copy Artifacts
# run: |
# cp release/ixiatg-operator.yaml tests/deployments

# - name: Setup KNE cluster
# run: |
# GITHUB_USER=${{ secrets.ENV_GITHUB_USER }} GITHUB_PAT=${{ secrets.ENV_GITHUB_PAT }} ./ci.sh create_setup
# - name: Setup Python
# uses: actions/setup-python@v4
# with:
# python-version: ${{ env.PYTHON_VERSION }}
# - name: Setup Prerequisites
# run: |
# ./ci.sh setup_pre_test
# - name: Run Tests
# run: |
# ./ci.sh run_test miscellaneous
# - name: Archive logs
# if: always()
# uses: actions/upload-artifact@v3
# with:
# name: miscellaneous
# path: tests/logs-miscellaneous
# - name: Destroy KNE cluster
# run: |
# ./ci.sh destroy_setup
miscellaneous:
needs: build
runs-on: ubuntu-22.04
steps:
- name: Checkout source
uses: actions/checkout@v3
- name: Setup docker
uses: docker-practice/actions-setup-docker@master
- name: Setup Go
uses: actions/setup-go@v3
with:
go-version: ${{ env.GO_VERSION }}
- name: Get Artifacts
uses: actions/download-artifact@master
with:
name: release-artifact
path: release/
- name: Copy Artifacts
run: |
cp release/ixiatg-operator.yaml tests/deployments
cp release/keng-operator.tar.gz tests/deployments
- name: Setup KNE cluster
run: |
GITHUB_USER=${{ secrets.ENV_GITHUB_USER }} GITHUB_PAT=${{ secrets.ENV_GITHUB_PAT }} ./ci.sh create_setup
- name: Setup Python
uses: actions/setup-python@v4
with:
python-version: ${{ env.PYTHON_VERSION }}
- name: Setup Prerequisites
run: |
./ci.sh setup_pre_test
- name: Run Tests
run: |
./ci.sh run_test miscellaneous
- name: Archive logs
if: always()
uses: actions/upload-artifact@v3
with:
name: miscellaneous
path: tests/logs-miscellaneous
- name: Destroy KNE cluster
run: |
./ci.sh destroy_setup

negative:
needs: build
Expand All @@ -356,6 +356,7 @@ jobs:
- name: Copy Artifacts
run: |
cp release/ixiatg-operator.yaml tests/deployments
cp release/keng-operator.tar.gz tests/deployments

- name: Setup KNE cluster
run: |
Expand Down Expand Up @@ -401,6 +402,7 @@ jobs:
- name: Copy Artifacts
run: |
cp release/ixiatg-operator.yaml tests/deployments
cp release/keng-operator.tar.gz tests/deployments

- name: Setup KNE cluster
run: |
Expand Down Expand Up @@ -446,6 +448,7 @@ jobs:
- name: Copy Artifacts
run: |
cp release/ixiatg-operator.yaml tests/deployments
cp release/keng-operator.tar.gz tests/deployments

- name: Setup KNE cluster
run: |
Expand Down Expand Up @@ -490,7 +493,8 @@ jobs:

- name: Copy Artifacts
run: |
cp release/ixiatg-operator.yaml tests/deployments/ixiatg-operator.yaml
cp release/ixiatg-operator.yaml tests/deployments
cp release/keng-operator.tar.gz tests/deployments

- name: Setup KNE cluster
run: |
Expand All @@ -517,8 +521,7 @@ jobs:

release:
runs-on: ubuntu-latest
#needs: [b2b, dut, lag, license, liveness, miscellaneous, negative, performance, resource, rest]
needs: [b2b, dut, lag, license, liveness, negative, performance, resource, rest]
needs: [b2b, dut, lag, license, liveness, miscellaneous, negative, performance, resource, rest]
steps:
- name: Checkout
if: always()
Expand All @@ -540,7 +543,12 @@ jobs:
id: get_version
run: |
echo "version=v$(head ./version | cut -d' ' -f1)" >> $GITHUB_OUTPUT
echo "package_version=$(head ./version | cut -d' ' -f1)" >> $GITHUB_OUTPUT

- name: Get Artifacts
uses: actions/download-artifact@master
with:
name: release-artifact
path: release/

- name: Check tag for current version
if: always()
Expand All @@ -551,27 +559,10 @@ jobs:
env:
GITHUB_TOKEN: ${{ secrets.ENV_GITHUB_PAT }}

- name: Get Version ID from the Versions List
id: get_version_id
if: always()
run: |
curl -X GET -H "Authorization: Bearer ${{secrets.ENV_GITHUB_PAT}}" https://api.github.com/orgs/open-traffic-generator/packages/container/keng-operator/versions >> $HOME/versionIds.json
echo "version_id=$(jq -r '.[] | select(.name == "${{ steps.get_version.outputs.package_version }}").id' $HOME/versionIds.json)" >> $GITHUB_OUTPUT

- name: Delete Non-Main Branch Images
if: steps.get_branch.outputs.branch != 'main' && always()
- name: Publishing Artifacts
if: steps.check_tag.outputs.exists == 'false'
run: |
curl -i \
-X DELETE \
-H 'Authorization: Bearer ${{secrets.ENV_GITHUB_PAT}}' \
-H "Accept: application/vnd.github.v3+json" \
https://api.github.com/orgs/open-traffic-generator/packages/container/keng-operator/versions/173317052

- name: Get Artifacts
uses: actions/download-artifact@master
with:
name: release-artifact
path: release/
GITHUB_USER=${{ secrets.ENV_GITHUB_USER }} GITHUB_PAT=${{ secrets.ENV_GITHUB_PAT }} ./ci.sh publish ${{ steps.get_branch.outputs.branch }}

- name: Create Release
if: steps.check_tag.outputs.exists == 'false' && steps.get_branch.outputs.branch == 'main'
Expand Down
33 changes: 20 additions & 13 deletions ci.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ GO_VERSION=1.17.9
export DEBIAN_FRONTEND=noninteractive


IXIA_C_OPERATOR_IMAGE=keng-operator
KENG_OPERATOR_IMAGE=keng-operator
GO_TARGZ=""

GITHUB_REPO="ghcr.io/open-traffic-generator"
Expand Down Expand Up @@ -74,7 +74,7 @@ get_docker_build() {
# Generating docker build using Makefile
echo "Generating docker build ..."
export VERSION=$(get_version)
export IMAGE_TAG_BASE=${IXIA_C_OPERATOR_IMAGE}
export IMAGE_TAG_BASE=${KENG_OPERATOR_IMAGE}
make docker-build
docker rmi -f $(docker images | grep '<none>') 2> /dev/null || true
}
Expand Down Expand Up @@ -143,9 +143,9 @@ publish() {
branch=${1}
docker images
version=$(get_version)
img="${IXIA_C_OPERATOR_IMAGE}:${version}"
github_img="${GITHUB_REPO}/${IXIA_C_OPERATOR_IMAGE}:${version}"
github_img_latest="${GITHUB_REPO}/${IXIA_C_OPERATOR_IMAGE}:latest"
docker load -i release/keng-operator.tar.gz
github_img="${GITHUB_REPO}/${KENG_OPERATOR_IMAGE}:${version}"
github_img_latest="${GITHUB_REPO}/${KENG_OPERATOR_IMAGE}:latest"
docker tag ${img} "${github_img}"
if [ "$branch" = "main" ]
then
Expand All @@ -164,16 +164,23 @@ publish() {
push_github_docker_image ${github_img_latest}
verify_github_images ${github_img_latest}
fi
cicd_gen_release_art
}

cicd_gen_release_art() {
gen_artifacts() {
version=$(get_version)
mkdir -p ${release}
rm -rf ./ixiatg-operator.yaml
rm -rf ${release}/*.yaml
gen_ixia_c_op_dep_yaml "${GITHUB_REPO}/${IXIA_C_OPERATOR_IMAGE}"

rm -rf ./keng-operator.tar.gz
rm -rf ${release}/*.tar.gz
img="${KENG_OPERATOR_IMAGE}:${version}"
github_img="${GITHUB_REPO}/${KENG_OPERATOR_IMAGE}:${version}"
docker tag $img $github_img
docker save ${github_img} | gzip > ${release}/keng-operator.tar.gz


gen_ixia_c_op_dep_yaml "${GITHUB_REPO}/${KENG_OPERATOR_IMAGE}"
mv ./ixiatg-operator.yaml ${release}/
echo "Files in ./release: $(ls -lht ${release})"
echo "Files in ./release: $(ls -lht ${release})"
}

gen_operator_artifacts() {
Expand All @@ -183,12 +190,12 @@ gen_operator_artifacts() {
rm -rf ${art}/*.yaml
rm -rf ${art}/*.tar.gz
mv ./ixiatg-operator.yaml ${art}/
docker save ${IXIA_C_OPERATOR_IMAGE}:${version} | gzip > ${art}/keng-operator.tar.gz
docker save ${KENG_OPERATOR_IMAGE}:${version} | gzip > ${art}/keng-operator.tar.gz
}

build() {
mkdir -p ${art}
gen_ixia_c_op_dep_yaml ${IXIA_C_OPERATOR_IMAGE} \
gen_ixia_c_op_dep_yaml ${KENG_OPERATOR_IMAGE} \
&& get_docker_build \
&& gen_operator_artifacts ${art}
version=$(get_version)
Expand Down
15 changes: 14 additions & 1 deletion tests/setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ KIND_VERSION=v0.20.0
METALLB_VERSION=v0.13.11
MESHNET_COMMIT=d7c306c
MESHNET_IMAGE="networkop/meshnet\:v0.3.0"
KENG_OPERATOR_IMAGE_FILE="deployments/keng-operator.tar.gz"
KENG_OPERATOR_YAML="deployments/ixiatg-operator.yaml"
ARISTA_CEOS_OPERATOR_VERSION="2.0.1"
ARISTA_CEOS_OPERATOR_YAML="https://github.com/aristanetworks/arista-ceoslab-operator/config/default?ref=v${ARISTA_CEOS_OPERATOR_VERSION}"
Expand Down Expand Up @@ -202,10 +203,22 @@ get_meshnet() {
&& cd ${oldpwd}
}

get_keng_operator_image() {
if [ -f "$KENG_OPERATOR_IMAGE_FILE" ];
then
echo "Operator tar found...."
docker load -i $KENG_OPERATOR_IMAGE_FILE
kind load docker-image "$(keng_operator_image)"
else
echo "Operator tar not found!!!"\
load_image_to_kind $(keng_operator_image)
fi
}

get_keng_operator() {
echo "Installing keng-operator ${KENG_OPERATOR_YAML} ..."
cat ${KENG_OPERATOR_YAML}
load_image_to_kind $(keng_operator_image) \
get_keng_operator_image \
&& kubectl apply -f ${KENG_OPERATOR_YAML} \
&& wait_for_pods ixiatg-op-system \
&& kubectl get pods -A
Expand Down
Loading