Skip to content

Commit

Permalink
add github action CI
Browse files Browse the repository at this point in the history
  • Loading branch information
songyuyuyu committed Aug 25, 2021
1 parent 45b3529 commit 4756b6a
Show file tree
Hide file tree
Showing 3 changed files with 112 additions and 0 deletions.
57 changes: 57 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
# This workflow will build a Java project with Maven
# For more information see: https://help.github.com/actions/language-and-framework-guides/building-and-testing-java-with-maven

name: github CI

on:
push:
branches:
- master
- dev
- coverity_scan
- final_gtihub_action
pull_request:
branches:
- master
- dev
- coverity_scan

jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Set up JDK 8
uses: actions/setup-java@v2
with:
java-version: '8'
distribution: 'adopt'

# - name: buildcahe
# run: |
# git clone https://github.com/ctripcorp/x-pipe.git
# cd x-pipe
# git checkout mvn_repo
# sh install.sh

- name: Cache Maven packages
uses: actions/cache@v2
with:
path: ~/.m2
key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }}
restore-keys: ${{ runner.os }}-m2

- name: Build with Maven
run: mvn install -DskipTests=true -Dmaven.javadoc.skip=true -B -V

- name: generate report
run: mvn -Dlog.console.close=true clean generate-resources --no-transfer-progress cobertura:cobertura -Dcobertura.report.format=xml

- name: codecov
uses: codecov/codecov-action@v2.0.1
with:
token: 50484ce1-6e23-4309-87ac-e2cf9d3a3b4f
file: ${{ github.workspace }}/**/target/site/jacoco/jacoco.xml

- name: Upload coverage to codecov
run: curl -s https://codecov.io/bash | bash
3 changes: 3 additions & 0 deletions codecov.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
codecov:
require_ci_to_pass: yes
max_report_age: off
52 changes: 52 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -938,6 +938,58 @@
</pluginRepository>
</pluginRepositories>
</profile>
<profile>
<id>githubAction</id>
<build>
<plugins>
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<!-- <version>${build-plugin.jacoco.version}</version>-->
<configuration>
<destFile>target/coverage-reports/jacoco-unit.exec</destFile>
<dataFile>target/coverage-reports/jacoco-unit.exec</dataFile>
<includes>
<include>**/service/**</include>
<include>**/controller/**</include>
<include>**/*Tests.java</include>
<include>**/*Test.java</include>
<!--<include>**/service/impl/*.class</include>-->
</includes>
</configuration>
<executions>
<!-- Prepares the property pointing to the JaCoCo runtime agent
which is passed as VM argument when Maven the Surefire plugin is executed. -->
<execution>
<goals>
<goal>prepare-agent</goal>
</goals>
</execution>
<!-- Ensures that the code coverage report is created after
all tests have been run. -->
<execution>
<id>generate-report</id>
<goals>
<goal>report</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>cobertura-maven-plugin</artifactId>
<version>${cobertura-maven-plugin.version}</version>
<configuration>
<formats>
<format>html</format>
<format>xml</format>
</formats>
<check />
</configuration>
</plugin>
</plugins>
</build>
</profile>
</profiles>

<distributionManagement>
Expand Down

0 comments on commit 4756b6a

Please sign in to comment.