Skip to content

Commit a5a75fe

Browse files
Add a test to check that all dependencies are shaded (#2320)
* Add a test to check that all dependencies are shaded * Add test. * Add comments. * Run shading separately. * Skip javadoc generation.
1 parent 2d29fc5 commit a5a75fe

2 files changed

Lines changed: 25 additions & 0 deletions

File tree

.github/workflows/test.yml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,20 @@ jobs:
9393
run: mvn javadoc:javadoc
9494
shell: bash
9595

96+
shading:
97+
runs-on: ubuntu-latest
98+
if: (github.event.pull_request.draft == false && !contains(github.event.pull_request.labels.*.name, 'ci/skip') && !contains(github.event.pull_request.head.ref, 'datadog-api-spec/test/')) || github.event_name == 'schedule'
99+
steps:
100+
- uses: actions/checkout@v3
101+
- name: Install Java
102+
uses: actions/setup-java@v3
103+
with:
104+
java-version: "8"
105+
distribution: "temurin"
106+
cache: "maven"
107+
- name: Check all dependencies shaded
108+
run: ./shade-test.sh
109+
96110
test:
97111
strategy:
98112
matrix:

shade-test.sh

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# Create the package. Skip tests since this is just for testing the contents of the jar. We've already run the tests in another step.
2+
mvn package -DskipTests -Dmaven.javadoc.skip=true
3+
# List everything in the shaded jar. Anything in com/datadog is good since that's either shaded or our own code.
4+
# We intentionally avoid shading anything in META-INF in the pom.xml.
5+
# And there are some native libraries in other directories that we don't shade so we only want to check for .class files.
6+
if unzip -Z1 target/datadog-api-client-*-shaded-jar.jar | grep -v "^com/datadog" | grep -v "^META-INF" | grep "\.class$"; then
7+
exit 1
8+
else
9+
exit 0
10+
fi
11+

0 commit comments

Comments
 (0)