8000 IT Setup · applibgroup/applibgroup Wiki · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

IT Setup

sundaravadivelcp edited this page Jul 15, 2021 · 6 revisions

Github Action CI Setup

I. Configure project on Sonar Cloud

Open https://sonarcloud.io/organizations/applibgroup/projects as admin

1. For New Projects

Press '+' button near profile icon > Analyze new project

Select a project in applib group repo > Set Up

With GitHub actions > Under GitHub Secret, Copy the Name and Value Fields

2. If project is already Set up

Select Project > Configure Analysis > With GitHub actions > Copy the Name and Value Fields

3. Setup Secret in GitHub

Open https://github.com/applibgroup/circularprogressview as admin Go to Project > Settings > Secrets > New Repository Secret

Enter the copied values from Sonarcloud

 

II. Add the changes to build.gradle

Edit build.gradle in the root directory and add the below lines of code

apply plugin: 'org.sonarqube'
apply plugin: 'checkstyle'

buildscript {
  dependencies {
        classpath "org.sonarsource.scanner.gradle:sonarqube-gradle-plugin:3.3"
    }
}

allprojects {
    repositories {
        maven {
            url 'https://mirrors.huaweicloud.com/repository/maven/'
        }
        maven {
            url 'https://developer.huawei.com/repo/'
        }
        jcenter()
    }
    task checkstyle(type: Checkstyle) {
       showViolations = true
       configFile file("huawei/config/checkstyle.xml")
  
       source 'entry/src/main/java'
       source 'circularprogressview/src/main/java'
       include '**/*.java'
  
       // empty classpath
       classpath = files()
	}
}

checkstyle {
	toolVersion "8.43"
}

sonarqube {
  properties {
    property "sonar.projectKey", "applibgroup_CircularProgressView"
    property "sonar.organization", "applibgroup"
    property "sonar.host.url", "https://sonarcloud.io"
    property "sonar.sources", "entry,circularprogressview"
    property "sonar.java.binaries", "entry/build,circularprogressview/build"
  }
}

Make sure to replace your project name and source paths accordingly

 

III. Create Github Actions workflow

After repo is created and all the code is added. click on the Actions in Project page and select "set up a work flow yourself"

Add the below code to main.yml file

# This workflow will build a Harmony OS project with Gradle and analyse the code using Sonar cloud.

name: Build

on:
  push:
    branches: [ main ]
  pull_request:
    branches: [ main ]

jobs:
  Hmos_Build:

    runs-on: windows-latest

    steps:
    - uses: actions/checkout@v2
    - name: Set up JDK 11
      uses: actions/setup-java@v2
      with:
        java-version: '11'
        distribution: 'adopt'
    - name: Grant execute permission for gradlew
      run: chmod +x gradlew
      
    - name: set environment variables
      uses: allenevans/set-env@v2.0.0
      with:
          OHOS_SDK_HOME: '${{ github.workspace }}\huawei'
           
    - name: Download HMOS SDK
      uses: actions/checkout@main
      with:
        repository: applibgroup/HarmonyOsSdk
        path: huawei
    - name: Cache SonarCloud packages
      uses: actions/cache@v1
      with:
        path: ~/.sonar/cache
        key: ${{ runner.os }}-sonar
        restore-keys: ${{ runner.os }}-sonar
    - name: Cache Gradle packages
      uses: actions/cache@v1
      with:
        path: ~/.gradle/caches
        key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle') }}
        restore-keys: ${{ runner.os }}-gradle
    - name: Hmos Build and analyze code
      env:
        GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}  # Needed to get PR information, if any
        SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
      run: ./gradlew assembleDebug checkstyle sonarqube --info
    - name: Upload Artifact
      uses: actions/upload-artifact@v2
      with: 
        name: assets-for-download
        path: build\outputs\hap\debug\phone

Once committed, you can find the code in "CircularProgressView/.github/workflows/main.yml"

 

IV. After Every commit the build will be triggered. Click on the Actions to see the build status.

 

V. On successful run, reports generated can be viewed in Sonar Cloud under your project name.

SonarCloud and Quality gate Setup

SonarCloud and Quality gate Setup steps

Clone this wiki locally
0