From 3c8ff54fd61530a2882270d08d956beb706e7101 Mon Sep 17 00:00:00 2001 From: Jheng-Hao Lin Date: Thu, 5 Oct 2023 16:27:20 +0100 Subject: [PATCH] PIMOB-2183: Add github actions and remove duplicated steps from bitrise.yml --- .github/workflows/send-sonar-qube-report.yml | 38 +++++++++++++++ .github/workflows/setup-env.yml | 19 ++++++++ .github/workflows/verify-pr.yml | 49 ++++++++++++++++++++ bitrise.yml | 14 ------ 4 files changed, 106 insertions(+), 14 deletions(-) create mode 100644 .github/workflows/send-sonar-qube-report.yml create mode 100644 .github/workflows/setup-env.yml create mode 100644 .github/workflows/verify-pr.yml diff --git a/.github/workflows/send-sonar-qube-report.yml b/.github/workflows/send-sonar-qube-report.yml new file mode 100644 index 000000000..25e456679 --- /dev/null +++ b/.github/workflows/send-sonar-qube-report.yml @@ -0,0 +1,38 @@ +name: Send SonarQube Report + +on: + push: + branches: [ master ] + pull_request: + # The branches below must be a subset of the branches above + types: [ opened, synchronize, reopened ] + branches: [ master, "bugfix/*", "feature/*", "release/*" ] + +concurrency: + group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} + cancel-in-progress: true + +jobs: + build: + name: Build Jacoco Test Report for :checkout + runs-on: ubuntu-latest + steps: + - name: Setup Environment + uses: ./.github/workflows/setup-env.yml + + - name: Build Jacoco Test Report for :checkout + run: ./gradlew :checkout:jacocoTestReport + + - name: Build Jacoco Test Report for :frames + run: ./gradlew :frames:jacocoTestReport + + - name: Send SonarQube Report + run: | + #!/usr/bin/env bash + # fail if any commands fails + set -e + # debug log + set -x + + # Run sonarqube script + ./scripts/sonar.sh| \ No newline at end of file diff --git a/.github/workflows/setup-env.yml b/.github/workflows/setup-env.yml new file mode 100644 index 000000000..84c3490fa --- /dev/null +++ b/.github/workflows/setup-env.yml @@ -0,0 +1,19 @@ +name: Setup Environment + +jobs: + setup: + name: Setup Environment + runs-on: ubuntu-latest + steps: + - name: Checkout Code + uses: actions/checkout@v3 + + - name: Set up JDK 11 + uses: actions/setup-java@v3 + with: + java-version: 11 + distribution: corretto + cache: gradle + + - name: Grant execute permission for gradlew + run: chmod +x gradlew \ No newline at end of file diff --git a/.github/workflows/verify-pr.yml b/.github/workflows/verify-pr.yml new file mode 100644 index 000000000..d22625c52 --- /dev/null +++ b/.github/workflows/verify-pr.yml @@ -0,0 +1,49 @@ +name: Verify Pull Request + +on: + push: + branches: [ master ] + pull_request: + # The branches below must be a subset of the branches above + types: [ opened, synchronize, reopened ] + branches: [ master, "bugfix/*", "feature/*", "release/*" ] + +concurrency: + group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} + cancel-in-progress: true + +jobs: + lint: + name: Code Lint + runs-on: ubuntu-latest + steps: + - name: Setup Environment + uses: ./.github/workflows/setup-env.yml + + - name: Run Ktlint + run: ./gradlew ktlintCheck + + - name: Run Android Lint + run: ./gradlew lint + + build: + name: Build the App + runs-on: ubuntu-latest + needs: lint + steps: + - name: Setup Environment + uses: ./.github/workflows/setup-env.yml + + - name: Build with Gradle + run: ./gradlew build + + test: + name: Unit Tests + runs-on: ubuntu-latest + needs: lint + steps: + - name: Setup Environment + uses: ./.github/workflows/setup-env.yml + + - name: Run unit tests + run: ./gradlew test diff --git a/bitrise.yml b/bitrise.yml index 1cfce942e..455c54842 100644 --- a/bitrise.yml +++ b/bitrise.yml @@ -39,33 +39,19 @@ workflows: description: First steps to initialise the workflow verification-full: steps: - - android-lint@0: - inputs: - - variant: "$VARIANT" - is_always_run: true - - android-unit-test@1: - inputs: - - project_location: "$PROJECT_LOCATION" - - variant: "$VARIANT" - is_always_run: true - gradle-runner@2: inputs: - gradle_task: assembleAndroidTest is_always_run: true title: Gradle Runner - Build Android Test after_run: - - steps-sonar - steps-finish description: |2- ## Performs all validation checks The following checks are performed - - Build - - Lint Checks (if PR is ready for review) - - Unit Tests - Instrumentation Tests (if PR is ready for review) - - SonarQube Analysis (if PR is ready for review) before_run: - steps-start steps-sonar: