From afa448db718507cefabc853a1398be6195bcf7bf Mon Sep 17 00:00:00 2001 From: Anil Belur Date: Thu, 14 Sep 2023 10:58:43 +1000 Subject: [PATCH] Chore: Refactor docs and code Add workflow_dispatch to trigger jobs manually. Use inputs to build the flavor of docker image Rename some of the files/dir structure, remove white spaces and tabs. Signed-off-by: Anil Belur --- .github/workflows/build.yaml | 39 ++++++++++++------- .github/workflows/csit-1-node.yaml | 4 +- .github/workflows/maven-build.yaml | 2 +- {Builder => builder}/README.md | 16 +++++++- {Builder/Centos => builder/centos}/dockerfile | 0 {Builder/Ubuntu => builder/ubuntu}/dockerfile | 0 {Robot => robot}/README.md | 22 ++++++++--- {Robot => robot}/dockerfile | 0 8 files changed, 58 insertions(+), 25 deletions(-) rename {Builder => builder}/README.md (93%) rename {Builder/Centos => builder/centos}/dockerfile (100%) rename {Builder/Ubuntu => builder/ubuntu}/dockerfile (100%) rename {Robot => robot}/README.md (92%) rename {Robot => robot}/dockerfile (100%) diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index 4685083..d40be41 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -4,30 +4,39 @@ on: push: branches: - '*' + workflow_dispatch: + inputs: + OS_FLAVOR: + description: "Linux Flavor" + required: false + type: string + default: ubuntu + jobs: - Builder-Docker-Images: + builder-docker-image: runs-on: ubuntu-latest steps: - name: Checkout repository uses: actions/checkout@v3 - - name: Build Docker image - run: docker build -t ${{ vars.REPOSITORY }}/${{ vars.IMAGENAME1 }} Builder/Ubuntu/ + - name: Build Ubuntu Docker image + run: docker build -t ${{ vars.DOCKER_REPOSITORY }}/${{ vars.ODL_BASE_IMAGE_NAME }} builder/${{ vars.OS_FLAVOR }} - - name: Test + - name: Clone and test repo run: | - docker run ${{ vars.REPOSITORY }}/${{ vars.IMAGENAME1 }} \ + docker run ${{ vars.DOCKER_REPOSITORY }}/${{ vars.ODL_BASE_IMAGE_NAME }} \ bash -c 'git clone "https://git.opendaylight.org/gerrit/integration/distribution" && \ cd /distribution && mvn clean install' - - name: Log in to Docker Hub + + - name: Authenticate to Docker Hub uses: docker/login-action@v2 with: username: ${{ secrets.DOCKERHUB_USERNAME }} password: ${{ secrets.DOCKERHUB_TOKEN }} - name: Push Docker image - run: docker push ${{ vars.REPOSITORY }}/${{ vars.IMAGENAME1 }} + run: docker push ${{ vars.DOCKER_REPOSITORY }}/${{ vars.ODL_BASE_IMAGE_NAME }} Build-And-Test-Robot-Docker-Image: runs-on: ubuntu-latest @@ -44,15 +53,15 @@ jobs: uses: actions/checkout@v3 - name: Build Docker image - run: docker build -t ${{ vars.REPOSITORY }}/${{ vars.IMAGENAME2 }} Robot/ + run: docker build -t ${{ vars.DOCKER_REPOSITORY }}/${{ vars.ROBOT_BASE_IMAGE_NAME }} robot/ - name: Test run: | - docker run --network container:odl-container ${{ vars.REPOSITORY }}/${{ vars.IMAGENAME2 }} bash -c ' - yum install -y git python3-pip && - pip3 install robotframework robotframework-extendedrequestslibrary && - git clone https://github.com/opendaylight/integration-test.git && - cd integration-test/csit/suites/integration/basic && + docker run --network container:odl-container ${{ vars.DOCKER_REPOSITORY }}/${{ vars.ROBOT_BASE_IMAGE_NAME }} bash -c ' + yum install -y git python3-pip && + pip3 install robotframework robotframework-extendedrequestslibrary && + git clone https://github.com/opendaylight/integration-test.git && + cd integration-test/csit/suites/integration/basic && robot -L debug \ --variable USER_HOME:/home/centos \ --variable DEFAULT_LINUX_PROMPT:\$ \ @@ -64,6 +73,6 @@ jobs: with: username: ${{ secrets.DOCKERHUB_USERNAME }} password: ${{ secrets.DOCKERHUB_TOKEN }} - + - name: Push Docker image - run: docker push ${{ vars.REPOSITORY }}/${{ vars.IMAGENAME2 }} \ No newline at end of file + run: docker push ${{ vars.DOCKER_REPOSITORY }}/${{ vars.ROBOT_BASE_IMAGE_NAME }} diff --git a/.github/workflows/csit-1-node.yaml b/.github/workflows/csit-1-node.yaml index 6aba452..d001c0f 100644 --- a/.github/workflows/csit-1-node.yaml +++ b/.github/workflows/csit-1-node.yaml @@ -16,7 +16,7 @@ jobs: services: opendaylight: - image: ${{ vars.REPOSITORY }}/${{ vars.ODL_IMAGE }} + image: ${{ vars.DOCKER_REPOSITORY }}/${{ vars.ODL_IMAGE }} env: FEATURES: odl-restconf,odl-daexim-all,odl-netconf-topology,odl-jolokia ports: @@ -46,7 +46,7 @@ jobs: - name: Start robot container run: | # Start the robot container - docker run -d --network container:odl-container --name robot ${{ vars.REPOSITORY }}/${{ vars.ROBOT_IMAGE }} tail -f /dev/null + docker run -d --network container:odl-container --name robot ${{ vars.DOCKER_REPOSITORY }}/${{ vars.ROBOT_IMAGE }} tail -f /dev/null - name: Extract id_rsa.pub from the robot container id: extract_pubkey diff --git a/.github/workflows/maven-build.yaml b/.github/workflows/maven-build.yaml index f1e3ab3..14df242 100644 --- a/.github/workflows/maven-build.yaml +++ b/.github/workflows/maven-build.yaml @@ -16,7 +16,7 @@ jobs: - name: Build and export uses: docker/build-push-action@v4 with: - context: Builder/Ubuntu/ + context: builder/ubuntu/ tags: ${{ vars.ODL_BASE_IMAGE_NAME }}:latest outputs: type=docker,dest=/tmp/${{ vars.ODL_BASE_IMAGE_NAME }}.tar - name: Upload artifact diff --git a/Builder/README.md b/builder/README.md similarity index 93% rename from Builder/README.md rename to builder/README.md index bbe3452..19b0beb 100644 --- a/Builder/README.md +++ b/builder/README.md @@ -11,32 +11,44 @@ You can build the Docker image for the desired base system (Ubuntu or CentOS) us ``` $ docker build -t builder_image_name ./Ubuntu/ ``` + ### CentOS Base Builder Image + ``` -$ docker build -t builder_image_name .\Centos\ +$ docker build -t builder_image_name .\Centos\ ``` + Replace Builder_Image_Name with your preferred image name. -### Using the Builder Image for MVN Builds +### Using the Builder Image for MVN Builds + Once you've built the Builder image, follow these steps to perform MVN builds within a Docker container: 1) Launch a Docker container: + ``` $ docker run --name my-builder-container builder_image_name bash -c "tail -f /dev/null" ``` + 2) Access the Docker container: + ``` $ docker exec -it my-builder-container bash ``` + 3) Inside the Docker container, clone the OpenDaylight repository you want to build: + ``` $ git clone https://git.opendaylight.org/gerrit/integration/distribution $ cd distribution ``` + 4) Run the Maven (MVN) build: + ``` mvn clean install ``` + This will initiate the build process for the OpenDaylight project. Make sure you replace the example Git URL (https://git.opendaylight.org/gerrit/integration/distribution) with the URL of the specific OpenDaylight repository you intend to build. By following these steps, you can use the provided Docker image to build OpenDaylight projects with a consistent development environment. diff --git a/Builder/Centos/dockerfile b/builder/centos/dockerfile similarity index 100% rename from Builder/Centos/dockerfile rename to builder/centos/dockerfile diff --git a/Builder/Ubuntu/dockerfile b/builder/ubuntu/dockerfile similarity index 100% rename from Builder/Ubuntu/dockerfile rename to builder/ubuntu/dockerfile diff --git a/Robot/README.md b/robot/README.md similarity index 92% rename from Robot/README.md rename to robot/README.md index a7b9f60..5827553 100644 --- a/Robot/README.md +++ b/robot/README.md @@ -18,6 +18,7 @@ Begin by cloning this repository to your local machine: git clone https://github.com/askb/releng-docker cd robot-framework-docker ``` + Step 2: Build the Docker Image Execute the following command to build the Docker image: @@ -26,32 +27,43 @@ docker build -t robot-framework:latest . ``` Step 3: Run a Docker Container + Once the image has been successfully constructed, launch a Docker container from it. You have the flexibility to replace 'my-robot-container' with a name of your choice: + ``` docker run -it --network=host --name my-robot-container robot-framework:latest bash -c "tail -f /dev/null" ``` + Ensure that opendaylight and Robot containers are on the same Docker network. -You can now access the container using -`$ docker exec -it my-robot-container bash ` +You can now access the container using + +`$ docker exec -it my-robot-container bash ` Step 4: Run the OpenDaylight container on the same network. + ``` -docker run -d --name opendaylight --network=host opendaylight-image --env FEATURES=odl-restconf,odl-netconf-topology +docker run -d --name opendaylight --network=host opendaylight-image --env FEATURES=odl-restconf,odl-netconf-topology ``` + Step 5: Clone the integration-test repository + ``` docker exec robot-container bash -c 'git clone https://github.com/opendaylight/integration-test.git" ``` + Step 6: Run single integration test + ``` docker exec robot-container bash -c ' robot -L debug --variable KARAF_HOME:/home/user/workspace/netconf/karaf/target/assembly/bin --variable USER_HOME:/home/jenkins --variable DEFAULT_LINUX_PROMPT:\$ --variable ODL_SYSTEM_IP:127.0.0.1 --variable ODL_SYSTEM_1_IP:127.0.0.1 --variable RESTCONFPORT:8181 --variable IS_KARAF_APPL:True ./test.robot' ``` -For Example + +For Example + ``` docker exec robot bash -c 'git clone https://github.com/opendaylight/integration-test.git && - cd integration-test/csit/suites/daexim && + cd integration-test/csit/suites/daexim && robot -L debug --variable USER_HOME:/root \ --variable WORKSPACE:/home/youruser \ -v BUNDLEFOLDER:karaf-0.18.1 \ diff --git a/Robot/dockerfile b/robot/dockerfile similarity index 100% rename from Robot/dockerfile rename to robot/dockerfile