-
Notifications
You must be signed in to change notification settings - Fork 10
137 lines (119 loc) · 5.69 KB
/
build-test.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
# This workflow will build and test a Java project with Gradle
name: build
on:
pull_request:
push:
workflow_dispatch:
jobs:
dupe_check:
name: Check for Duplicate Workflow Run
runs-on: ubuntu-latest
outputs:
should_skip: ${{ steps.skip_check.outputs.should_skip }}
steps:
- id: skip_check
uses: fkirc/[email protected]
with:
concurrent_skipping: same_content
do_not_skip: '["pull_request", "workflow_dispatch", "schedule"]'
build:
needs:
- dupe_check
if: needs.dupe_check.outputs.should_skip != 'true' || (github.event_name == 'push' && github.ref == 'refs/heads/master' && github.repository_owner == 'SolaceProducts')
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
with:
submodules: recursive
- name: Cache Gradle
uses: actions/cache@v2
with:
path: |
~/.gradle/caches
~/.gradle/wrapper
key: ${{ runner.os }}-gradle-build-test-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }}
restore-keys: |
${{ runner.os }}-gradle-build-test-
- name: Setup JDK 11
uses: actions/setup-java@v2
with:
distribution: zulu
java-version: 11
- name: Validate Gradle wrapper
uses: gradle/wrapper-validation-action@v1
- name: Install Test Support
working-directory: solace-integration-test-support
run: ./mvnw clean install -DskipTests -Dchangelist=
- name: Build and test with Gradle
run: ./gradlew clean test integrationTest jacocoFullReport --info
- name: Upload Test Artifacts
if: always()
uses: actions/upload-artifact@v2
with:
name: Test Results
path: |
**/build/jacoco/*.exec
**/build/reports/
**/build/test-results/**/*.xml
- name: Publish artifacts
# Security Measure: Do not publish artifacts from dependabot builds
if: github.event_name == 'push' && (github.actor != 'dependabot[bot]' || !contains(github.ref, 'dependabot'))
run: |
if [ ${{ github.ref }} == 'refs/heads/master' ] && [ ${{ github.repository_owner }} == 'SolaceProducts' ] ; then
echo "Using master on SolaceProducts"
git config --global user.name "GitHub Actions Automation"
git config --global user.email "<>"
mkdir gh-pages; # Now update gh-pages
git clone --quiet --branch=gh-pages https://${{ secrets.GH_TOKEN }}@github.com/SolaceProducts/pubsubplus-connector-kafka-sink gh-pages > /dev/null 2>&1;
rm gh-pages/downloads/pubsubplus-connector-kafka-sink*
mv build/distributions/pubsubplus-connector-kafka-sink* gh-pages/downloads
cd gh-pages;
pushd downloads
cp index.template index.html; FILENAME=`find . | grep *.zip | cut -d'/' -f2 | sed 's/.\{4\}$//'`; sed -i "s/CONNECTOR_NAME/$FILENAME/g" index.html;
popd;
git add -f .;
git commit -m "Latest connector distribution on successful build ${{ github.run_number }} auto-pushed to gh-pages";
git remote add origin-pages https://${{ secrets.GH_TOKEN }}@github.com/SolaceProducts/pubsubplus-connector-kafka-sink.git > /dev/null 2>&1;
git push --quiet --set-upstream origin-pages gh-pages;
echo "Updated and pushed GH pages!";
elif [ ${{ github.ref }} != 'refs/heads/gh-pages' ] && [ ${{ github.repository_owner }} != 'SolaceProducts' ] ; then
echo "Using ${{ github.ref }} on ${{ github.repository_owner }}"
git config --global user.name "GitHub Actions Automation"
git config --global user.email "<>"
mkdir gh-pages; # Now update gh-pages
git clone --quiet --branch=gh-pages https://${{ secrets.GH_TOKEN }}@github.com/${{ github.repository }} gh-pages > /dev/null 2>&1;
rm gh-pages/downloads/pubsubplus-connector-kafka-sink*
mv build/distributions/pubsubplus-connector-kafka-sink* gh-pages/downloads
cd gh-pages;
pushd downloads
cp index.template index.html; FILENAME=`find . | grep *.zip | cut -d'/' -f2 | sed 's/.\{4\}$//'`; sed -i "s/CONNECTOR_NAME/$FILENAME/g" index.html;
popd;
git add -f .;
git commit -m "Latest connector distribution on successful build ${{ github.run_number }} auto-pushed to gh-pages";
git remote add origin-pages https://${{ secrets.GH_TOKEN }}@github.com/${{ github.repository }}.git > /dev/null 2>&1;
git push --quiet --set-upstream origin-pages gh-pages;
echo "Updated and pushed GH pages!";
fi
- name: Cleanup Gradle Cache
# Remove some files from the Gradle cache, so they aren't cached by GitHub Actions.
# Restoring these files from a GitHub Actions cache might cause problems for future builds.
run: |
rm -f ~/.gradle/caches/modules-2/modules-2.lock
rm -f ~/.gradle/caches/modules-2/gc.properties
- name: Publish Unit Test Results
if: github.actor != 'dependabot[bot]' || (github.event_name == 'push' && !contains(github.ref, 'dependabot'))
uses: EnricoMi/publish-unit-test-result-action@v1
continue-on-error: true
with:
check_name: Unit Test Results
comment_mode: create new
fail_on: nothing
hide_comments: orphaned commits
files: |
**/build/test-results/**/*.xml
- name: Publish Test Coverage Results
if: github.event_name == 'pull_request' && github.actor != 'dependabot[bot]' && github.event.pull_request.head.repo.full_name == github.repository
uses: madrapps/[email protected]
with:
paths: build/reports/jacoco/jacocoFullReport/jacocoFullReport.xml
token: ${{ secrets.GITHUB_TOKEN }}