Skip to content

Commit

Permalink
Chore: Refactor docs and code
Browse files Browse the repository at this point in the history
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 <abelur@linuxfoundation.org>
  • Loading branch information
askb committed Sep 14, 2023
1 parent 5cd1427 commit afa448d
Show file tree
Hide file tree
Showing 8 changed files with 58 additions and 25 deletions.
39 changes: 24 additions & 15 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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:\$ \
Expand All @@ -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 }}
run: docker push ${{ vars.DOCKER_REPOSITORY }}/${{ vars.ROBOT_BASE_IMAGE_NAME }}
4 changes: 2 additions & 2 deletions .github/workflows/csit-1-node.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/maven-build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
16 changes: 14 additions & 2 deletions Builder/README.md → builder/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
File renamed without changes.
File renamed without changes.
22 changes: 17 additions & 5 deletions Robot/README.md → robot/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:

Expand All @@ -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 \
Expand Down
File renamed without changes.

0 comments on commit afa448d

Please sign in to comment.