Skip to content

Commit 4c875f8

Browse files
authored
Added separate CI workflow for push. (#75)
1 parent c33b521 commit 4c875f8

2 files changed

Lines changed: 93 additions & 8 deletions

File tree

Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
name: OnMergeRelease
2+
3+
on:
4+
push:
5+
branches:
6+
- 'main'
7+
- 'release/*'
8+
tags:
9+
- '**'
10+
11+
permissions: read-all
12+
13+
jobs:
14+
setup:
15+
runs-on: ubuntu-latest
16+
outputs:
17+
runner: ${{ steps.step1.outputs.runner }}
18+
steps:
19+
- name: Check repository
20+
id: step1
21+
run: |
22+
if [ ${{ github.repository }} == 'intel/trustauthority-client-for-java' ]; then
23+
echo "runner=ubuntu-latest" >> $GITHUB_OUTPUT
24+
else
25+
echo "runner=self-hosted" >> $GITHUB_OUTPUT
26+
fi
27+
28+
build-test:
29+
needs: [setup]
30+
runs-on: ${{ needs.setup.outputs.runner }}
31+
env:
32+
http_proxy: ${{ secrets.HTTP_PROXY }}
33+
https_proxy: ${{ secrets.HTTPS_PROXY }}
34+
no_proxy: ${{ secrets.NO_PROXY }}
35+
steps:
36+
- uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 # v3.6.0
37+
with:
38+
fetch-depth: 0
39+
40+
- name: Setup Java JDK
41+
uses: actions/setup-java@387ac29b308b003ca37ba93a6cab5eb57c8f5f93 # v4.0.0
42+
with:
43+
distribution: 'temurin'
44+
java-version: '17'
45+
46+
- name: Install Maven manually
47+
run: |
48+
curl -LO https://archive.apache.org/dist/maven/maven-3/3.6.3/binaries/apache-maven-3.6.3-bin.tar.gz
49+
tar -xzf apache-maven-3.6.3-bin.tar.gz
50+
51+
- name: Update Maven proxy settings
52+
run: |
53+
# Fetch MAVEN_PROXY_HOST and MAVEN_PROXY_PORT from secrets.HTTP_PROXY
54+
export HTTP_PROXY_VALUE=$(echo "${{ secrets.HTTP_PROXY }}" | sed 's|^http://||;s|^https://||')
55+
export MAVEN_PROXY_HOST=$(echo $HTTP_PROXY_VALUE | cut -d':' -f1)
56+
export MAVEN_PROXY_PORT=$(echo $HTTP_PROXY_VALUE | cut -d':' -f2 | sed 's/\///')
57+
58+
# Update Maven with the proxy settings
59+
if [ -n "${MAVEN_PROXY_HOST}" -a -n "${MAVEN_PROXY_PORT}" ]; then \
60+
mkdir -p ~/.m2 && \
61+
echo "<settings><proxies><proxy><id>example-proxy</id><active>true</active><protocol>http</protocol><host>${MAVEN_PROXY_HOST}</host><port>${MAVEN_PROXY_PORT}</port></proxy></proxies></settings>" > ~/.m2/settings.xml; \
62+
fi
63+
64+
- name: Unit Test Coverage
65+
run: |
66+
# Add maven binary location to PATH
67+
export PATH="$PWD/apache-maven-3.6.3/bin:$PATH"
68+
# Compile, build and install the package
69+
# This also runs the unit tests internally
70+
mvn -X -e clean compile install package
71+
if [ $? -ne 0 ]; then
72+
echo "Build failed..."
73+
exit 1
74+
fi
75+
76+
# Fetch coverage for unit tests
77+
COVERAGE=$(cd connector && \
78+
awk -F, \
79+
'{ instructions += $4 + $5; covered += $5 } END \
80+
{ print covered, "/", instructions, " instructions covered"; \
81+
print 100*covered/instructions, "% covered" }' \
82+
target/site/jacoco/jacoco.csv)
83+
result=$(echo "$COVERAGE" | grep -oE "[0-9]+\.[0-9]+")
84+
echo "Unit test coverage for Client is - $result%"
85+
if (( $(echo "$result < 80" | bc -l) )); then
86+
echo "Unit test coverage must be above 80%"
87+
exit 1
88+
fi

.github/workflows/onpullrequest.yml

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,7 @@
1-
name: CI
1+
name: OnPullRequest
22

33
on:
44
pull_request:
5-
push:
6-
branches:
7-
- 'main'
8-
- 'release/*'
9-
tags:
10-
- '**'
115

126
permissions: read-all
137

@@ -49,6 +43,9 @@ jobs:
4943
https_proxy: ${{ secrets.HTTPS_PROXY }}
5044
no_proxy: ${{ secrets.NO_PROXY }}
5145
steps:
46+
- uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 # v3.6.0
47+
with:
48+
fetch-depth: 0
5249

5350
- name: Setup Java JDK
5451
uses: actions/setup-java@387ac29b308b003ca37ba93a6cab5eb57c8f5f93 # v4.0.0
@@ -60,7 +57,7 @@ jobs:
6057
run: |
6158
curl -LO https://archive.apache.org/dist/maven/maven-3/3.6.3/binaries/apache-maven-3.6.3-bin.tar.gz
6259
tar -xzf apache-maven-3.6.3-bin.tar.gz
63-
60+
6461
- name: Update Maven proxy settings
6562
run: |
6663
# Fetch MAVEN_PROXY_HOST and MAVEN_PROXY_PORT from secrets.HTTP_PROXY

0 commit comments

Comments
 (0)