Skip to content

Commit 4756b6a

Browse files
committed
add github action CI
1 parent 45b3529 commit 4756b6a

File tree

3 files changed

+112
-0
lines changed

3 files changed

+112
-0
lines changed

.github/workflows/build.yml

+57
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
# This workflow will build a Java project with Maven
2+
# For more information see: https://help.github.com/actions/language-and-framework-guides/building-and-testing-java-with-maven
3+
4+
name: github CI
5+
6+
on:
7+
push:
8+
branches:
9+
- master
10+
- dev
11+
- coverity_scan
12+
- final_gtihub_action
13+
pull_request:
14+
branches:
15+
- master
16+
- dev
17+
- coverity_scan
18+
19+
jobs:
20+
build:
21+
runs-on: ubuntu-latest
22+
steps:
23+
- uses: actions/checkout@v2
24+
- name: Set up JDK 8
25+
uses: actions/setup-java@v2
26+
with:
27+
java-version: '8'
28+
distribution: 'adopt'
29+
30+
# - name: buildcahe
31+
# run: |
32+
# git clone https://github.com/ctripcorp/x-pipe.git
33+
# cd x-pipe
34+
# git checkout mvn_repo
35+
# sh install.sh
36+
37+
- name: Cache Maven packages
38+
uses: actions/cache@v2
39+
with:
40+
path: ~/.m2
41+
key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }}
42+
restore-keys: ${{ runner.os }}-m2
43+
44+
- name: Build with Maven
45+
run: mvn install -DskipTests=true -Dmaven.javadoc.skip=true -B -V
46+
47+
- name: generate report
48+
run: mvn -Dlog.console.close=true clean generate-resources --no-transfer-progress cobertura:cobertura -Dcobertura.report.format=xml
49+
50+
- name: codecov
51+
uses: codecov/[email protected]
52+
with:
53+
token: 50484ce1-6e23-4309-87ac-e2cf9d3a3b4f
54+
file: ${{ github.workspace }}/**/target/site/jacoco/jacoco.xml
55+
56+
- name: Upload coverage to codecov
57+
run: curl -s https://codecov.io/bash | bash

codecov.yml

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
codecov:
2+
require_ci_to_pass: yes
3+
max_report_age: off

pom.xml

+52
Original file line numberDiff line numberDiff line change
@@ -938,6 +938,58 @@
938938
</pluginRepository>
939939
</pluginRepositories>
940940
</profile>
941+
<profile>
942+
<id>githubAction</id>
943+
<build>
944+
<plugins>
945+
<plugin>
946+
<groupId>org.jacoco</groupId>
947+
<artifactId>jacoco-maven-plugin</artifactId>
948+
<!-- <version>${build-plugin.jacoco.version}</version>-->
949+
<configuration>
950+
<destFile>target/coverage-reports/jacoco-unit.exec</destFile>
951+
<dataFile>target/coverage-reports/jacoco-unit.exec</dataFile>
952+
<includes>
953+
<include>**/service/**</include>
954+
<include>**/controller/**</include>
955+
<include>**/*Tests.java</include>
956+
<include>**/*Test.java</include>
957+
<!--<include>**/service/impl/*.class</include>-->
958+
</includes>
959+
</configuration>
960+
<executions>
961+
<!-- Prepares the property pointing to the JaCoCo runtime agent
962+
which is passed as VM argument when Maven the Surefire plugin is executed. -->
963+
<execution>
964+
<goals>
965+
<goal>prepare-agent</goal>
966+
</goals>
967+
</execution>
968+
<!-- Ensures that the code coverage report is created after
969+
all tests have been run. -->
970+
<execution>
971+
<id>generate-report</id>
972+
<goals>
973+
<goal>report</goal>
974+
</goals>
975+
</execution>
976+
</executions>
977+
</plugin>
978+
<plugin>
979+
<groupId>org.codehaus.mojo</groupId>
980+
<artifactId>cobertura-maven-plugin</artifactId>
981+
<version>${cobertura-maven-plugin.version}</version>
982+
<configuration>
983+
<formats>
984+
<format>html</format>
985+
<format>xml</format>
986+
</formats>
987+
<check />
988+
</configuration>
989+
</plugin>
990+
</plugins>
991+
</build>
992+
</profile>
941993
</profiles>
942994

943995
<distributionManagement>

0 commit comments

Comments
 (0)