-
Notifications
You must be signed in to change notification settings - Fork 2
107 lines (99 loc) · 4.87 KB
/
buildandtest.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
name: Build and Test
on:
push:
branches: [develop]
paths:
- "core-customize/hybris/bin/custom/sapcxtools/**/*.java"
- "core-customize/hybris/bin/custom/sapcxtools/**/*-beans.xml"
- "core-customize/hybris/bin/custom/sapcxtools/**/*-items.xml"
- "core-customize/hybris/bin/custom/sapcxtools/**/extensioninfo.xml"
- "core-customize/hybris/bin/custom/sapcxtools/**/external-dependencies.xml"
pull_request:
branches: [main, develop]
schedule:
- cron: "0 15 * * 0,3"
workflow_dispatch:
jobs:
build-and-test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Set up JDK 17
uses: actions/setup-java@v3
with:
distribution: "adopt"
java-version: "17"
cache: "gradle"
- name: Validate Gradle wrapper
uses: gradle/wrapper-validation-action@v1
- name: Set up cache for SAP artifacts
uses: actions/cache@v3
with:
key: sap-artifacts-cache-${{ hashFiles('core-customize/manifest.json') }}
path: dependencies
- name: SAP download config
env:
SAPCX_ARTEFACT_BASEURL: ${{ secrets.SAPCX_ARTEFACT_BASEURL }}
SAPCX_ARTEFACT_USER: ${{ secrets.SAPCX_ARTEFACT_USER }}
SAPCX_ARTEFACT_PASSWORD: ${{ secrets.SAPCX_ARTEFACT_PASSWORD }}
shell: bash
run: |
mkdir -p ${HOME}/.gradle
echo "GRADLE_USER_HOME=${HOME}/.gradle" >> $GITHUB_ENV
echo "SAPCX_ARTEFACT_BASEURL=${SAPCX_ARTEFACT_BASEURL}" >> ${HOME}/.gradle/gradle.properties
echo "SAPCX_ARTEFACT_USER=${SAPCX_ARTEFACT_USER}" >> ${HOME}/.gradle/gradle.properties
echo "SAPCX_ARTEFACT_PASSWORD=${SAPCX_ARTEFACT_PASSWORD}" >> ${HOME}/.gradle/gradle.properties
- name: SAP Commerce environment
run: |
echo "HYBRIS_OPT_CONFIG_DIR=$GITHUB_WORKSPACE/core-customize/hybris/config/local-config" >> $GITHUB_ENV
echo "HYBRIS_BIN_DIR=$GITHUB_WORKSPACE/core-customize/hybris/bin" >> $GITHUB_ENV
echo "HYBRIS_CONF_DIR=$GITHUB_WORKSPACE/core-customize/hybris/config" >> $GITHUB_ENV
echo "HYBRIS_LOG_DIR=$GITHUB_WORKSPACE/core-customize/hybris/log" >> $GITHUB_ENV
- name: Bootstrap platform
run: ./gradlew setupLocalDevelopment
- name: Build platform
run: ./gradlew yall
- name: Run unit tests
run: |
cat $GITHUB_WORKSPACE/ci/config/testing-unit.properties > $HYBRIS_CONF_DIR/local-config/99-local.properties
./gradlew yunittests
# Target never fails, therefore, check for test errors and fail if errors were found
for file in $HYBRIS_LOG_DIR/junit/test-results/unit/*.xml; do if [ "$(grep -cE '<(error|failure)' "${file}")" -gt 0 ]; then exit 1; fi; done
if [ ! -f "$HYBRIS_LOG_DIR/junit/jacoco-unit.exec" ]; then
mkdir -p "$HYBRIS_LOG_DIR/junit"
touch "$HYBRIS_LOG_DIR/junit/jacoco-unit.exec"
fi
- name: Run integration tests
run: |
cat $GITHUB_WORKSPACE/ci/config/testing-integration.properties > $HYBRIS_CONF_DIR/local-config/99-local.properties
./gradlew yintegrationtests
# Target never fails, therefore, check for test errors and fail if errors were found
for file in $HYBRIS_LOG_DIR/junit/test-results/integration/*.xml; do if [ "$(grep -cE '<(error|failure)' "${file}")" -gt 0 ]; then exit 1; fi; done
if [ ! -f "$HYBRIS_LOG_DIR/junit/jacoco-integration.exec" ]; then
mkdir -p "$HYBRIS_LOG_DIR/junit"
touch "$HYBRIS_LOG_DIR/junit/jacoco-integration.exec"
fi
- name: Coverage Report
env:
TOKEN: ${{ secrets.CODECOV_TOKEN }}
run: |
# Generate codecov report
mkdir -p "$HYBRIS_BIN_DIR/custom"
java -jar $GITHUB_WORKSPACE/ci/lib/jacococli.jar merge $HYBRIS_LOG_DIR/junit/jacoco-unit.exec $HYBRIS_LOG_DIR/junit/jacoco-integration.exec --destfile $HYBRIS_LOG_DIR/junit/jacoco.exec
java -jar $GITHUB_WORKSPACE/ci/lib/jacococli.jar report $HYBRIS_LOG_DIR/junit/jacoco.exec --classfiles $HYBRIS_BIN_DIR/custom --sourcefiles $HYBRIS_BIN_DIR/custom --xml $HYBRIS_LOG_DIR/junit/jacoco.xml
# Download codecov uploader
curl -Os https://uploader.codecov.io/latest/linux/codecov
chmod +x codecov
# Upload report to codecov
if [ $GITHUB_REF_TYPE -eq "branch" ]; then
./codecov -f $HYBRIS_LOG_DIR/junit/jacoco.xml -Z --build $GITHUB_RUN_ID --branch GITHUB_REF_NAME -t $TOKEN
else
./codecov -f $HYBRIS_LOG_DIR/junit/jacoco.xml -Z --build $GITHUB_RUN_ID --tag GITHUB_REF_NAME -t $TOKEN
fi
- name: SonarCloud Scan
uses: SonarSource/sonarcloud-github-action@master
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}