/
action.yml
62 lines (58 loc) · 2.23 KB
/
action.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
name: 'Maven BOM Validation'
description: 'Validation for the content of a Maven BOM'
inputs:
bom-path:
description: "The relative path from the repository root to the pom.xml file"
required: true
runs:
using: "composite"
steps:
- uses: actions/setup-java@v4
with:
distribution: temurin
java-version: 11
cache: maven
- name: Set up Maven
uses: stCarolas/setup-maven@v4.5
with:
maven-version: 3.8.4
- name: Create temporary directory /tmp/bom-validation
shell: bash
run: mkdir -p /tmp/bom-validation
- name: Create a canary project that uses the BOM
shell: bash
run: |
if [ ! -r "${{ inputs.bom-path }}" ]; then
echo "The input bom-path ${{ inputs.bom-path }} is not readable"
exit 1
fi
bom_absolute_path=$(realpath "${{ inputs.bom-path }}")
# Before this "cd", the working directory is the repository that calls
# this action. To use validate-bom classes, it needs to change directory
# to the directory that defines this action.
cd ${{ github.action_path }}
echo "Compiling CreateBomCanaryProject.java in $(pwd)"
mvn -V -ntp compile
echo "Running CreateBomCanaryProject with ${bom_absolute_path}"
mvn -V -ntp -B exec:java -DoutputPath=/tmp/bom-validation -DbomPath="${bom_absolute_path}"
- name: Build the canary project that uses the BOM
shell: bash
working-directory: /tmp/bom-validation
run: |
echo "working directory: $(pwd)"
mvn -ntp -B install
- name: Examine dependency tree for any error
shell: bash
working-directory: /tmp/bom-validation
run: |
echo "working directory: $(pwd)"
# This dependency tree check can detect errors that pass "mvn install".
# For example, an invalid group ID in one of pom.xml files:
# [ERROR] 'dependencies.dependency.groupId' for $com.google.protobuf:protobuf-java:jar with value '$com.google.protobuf' does not match a valid id pattern.
# https://github.com/googleapis/java-cloud-bom/issues/5936
ERROR_MESSAGE=$(mvn dependency:tree -X |grep "ERROR" || true)
echo "ERROR_MESSAGE: ${ERROR_MESSAGE}"
if [ -n "${ERROR_MESSAGE}" ]; then
echo "${ERROR_MESSAGE}"
exit 1
fi