Skip to content

Setup CI Pipeline

Rahul Kumar edited this page Sep 21, 2023 · 14 revisions

Tools & Technologies used

  1. GitHub Actions
  2. Docker and Docker Compose
  3. OEDF and Gradle
  4. DGoss to test Docker image state
  5. Trivy for running Security scans of the Docker containers
  6. Mocha to test PASOE Services
  7. HTML, JavaScript, and JSDO for Web app

Login to the Ubuntu VM

  1. Get the Ubuntu VM details,
    • VM Hostname
    • PEM file
  2. Open Command Prompt terminal and navigate to the directory where PEM file is located. Then run the below command
    ssh -i "<pem-file>" ubuntu@<hostname>
    

Setup the GitHub runner

This is the runner where your CI pipeline will run. Let's configure and set up this runner.

  1. Go to the GitHub repo page in a browser
  2. Navigate to the Settings tab -> Actions -> Runners
  3. Click on the New self-hosted runner
  4. Select Linux on the Runner image section
  5. Go to the Ubuntu VM terminal and perform the below steps
    cd /opt
    sudo mkdir actions-runner/
    sudo chown ubuntu actions-runner/
    cd actions-runner
    
  6. Now, follow the steps from GitHub Add new self-hosted runner page
  7. Confirm that the runner is added in GitHub (Settings -> Actions -> Runners)
  8. Start the runner as a service
    • Check the .env file to have the variables
      • JAVA_HOME=/opt/java/jdk-17.0.8.1+1
      • DLC=/psc/dlc
    • Use the below commands
      sudo ./svc.sh install   // install the runner; only needed for the 1st time
      sudo ./svc.sh start     // then start it
      sudo ./svc.sh status    // to check status
      sudo ./svc.sh stop      // to stop the Gradle runner
      

Now you can start creating Job for your CI pipeline.

Configure GitHub runner to access Nexus Docker repo

  1. Navigate to /home/ubuntu
  2. Copy and update the certificate for the Nexus repo. (Already created and placed in this directory)
    sudo cp nexus.crt /usr/local/share/ca-certificates/nexus.crt
    sudo update-ca-certificates
    sudo systemctl restart docker //restart docker
    
  3. Test by trying docker pull one of the images from Nexus
    • docker pull ec2-54-80-142-101.compute-1.amazonaws.com:9443/openedge-pasoe:12.8.0

(Reference - https://docs.docker.com/registry/insecure/#docker-still-complains-about-the-certificate-when-using-authentication)

Configure env variables and secrets

  1. Configure the below secrets (Settings -> Secrets and variables -> Actions)
    - DOCKER_USER=<user-name>
    - DOCKER_PWD=<password>
    
  2. Configure the below variables (click on the Variables tab)
    - APP_GROUP=<company-name>/<your-name>      //keep the values in small case
    - APP_NAME=sports
    - APP_VERSION=latest
    - DOCKER_REPO_URL=ec2-54-80-142-101.compute-1.amazonaws.com:9443
    - NEXUS_URL=https://ec2-54-80-142-101.compute-1.amazonaws.com:8443/repository/PugChallengeMaven
    - OE_VERSION=12.8.0
    

Create the workflow for all the Jobs

  1. Open the GitHub checked-out folder in VSCode on the Windows VM
  2. Create a file, .github\workflows\development.yml (at the root location of the repo)
  3. Copy the content to this generated file
    • Navigate to .github\workflows\development.yml file in develop branch in the GitHub from browser
    • Copy the content from this file and paste it into the YAML created in your repo

Now let's go through various sections in the YAML file.

Create OpenEdge Compile Job

  1. Check for compile inside jobs
  2. Go through the steps inside this section

Notice the docker run command that brings up the dev PAS container to do compilation.

Build Docker Image for Sports App

  1. Check for build inside jobs
  2. Go through the steps inside this section. Get an understanding of how the Docker image is created for the Sports app, which will get used during deployment

Build Web UI app

  1. Check for buildwebui inside jobs
  2. Update the serviceURI in webui\src\grid.js file to point to the hostname of your GitHub runner instance
    • Should look something like -
        var serviceURI = "https://ec2-3-84-2-121.compute-1.amazonaws.com:8811/Sports";
    
  3. Go through the steps

Deploy and test Job

  1. Check for deploy inside jobs
  2. Update serviceURI and catalogURI in test-app-image\test\testCustomer.js file to point to the hostname of your GitHub runner instance
  3. Go through the steps
    • Check the steps
    • Understand how the deployment is done
    • Understand how the tests are hooked in to run against the deployed app

Docker image security scan Job

  1. Check for securityscans inside jobs
  2. Check the steps and explore reporting

Stage artifacts Job

  1. Check for stage inside jobs
  2. Notice how a tested tag is appended to identify the artifact as tested

Validate the running Sports App

  1. Hit the Service URL https://<ubuntu-hostname>:8811/Sports/rest/SportsService/Customer
  2. Hit the Web App URL http://<ubuntu-hostname>:8080/

Make new changes to the App

  1. Play around with the app
  2. Make new changes to
    • Changes can be in the webui
    • Changes can be in the business logic of the Sports app
  3. Commit to the GitHub repo and let the CI run
  4. Validate the changes