Skip to content

AI: Add SPDX 3.1 (draft) for Example 02 #236

AI: Add SPDX 3.1 (draft) for Example 02

AI: Add SPDX 3.1 (draft) for Example 02 #236

Workflow file for this run

name: SPDX validation
on:
- pull_request
- push
jobs:
SPDX_Validation:
runs-on: ubuntu-latest
steps:
- name: Checkout spdx-examples
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 #v4.2.2
- name: Look for files with the wrong location
run: |
find . \( -name '*.spdx' -o -name '*.json' \) \
-not -path './presentations/*' \
-not -path '*/content/*' \
-not -path './tools-java/*' \
-not -path '*/spdx2.2/*' \
-not -path '*/spdx2.3/*' \
-not -path '*/spdx3.0/*' > flist.txt
if [ "$(cat flist.txt | wc -l)" != "0" ]; then
echo "SPDX JSON files are only expected in these locations:"
echo "./presentations/"
echo "./tools-java/"
echo "*/spdx2.2/"
echo "*/spdx2.3/"
echo "*/spdx3.0/"
echo ""
echo "The following files are in the wrong location and will not be checked:"
cat flist.txt
exit 1
fi
- name: Look for files with the wrong extension
run: |
find . -name '*.jsonld' > flist.txt
if [ "$(cat flist.txt | wc -l)" != "0" ]; then
echo "SPDX JSON can only has these extensions:"
echo "*.spdx"
echo "*.json"
echo ""
echo "The following files have the wrong extension and will not be checked:"
cat flist.txt
exit 1
fi
- name: Setup Java
uses: actions/setup-java@c5195efecf7bdfc987ee8bae7a71cb8b11521c00 #v4.7.1
with:
distribution: 'temurin'
java-version: '21'
- name: Setup Java tools
env:
TOOLS_JAVA_VER: 2.0.1
run: |
curl --location https://repo1.maven.org/maven2/org/spdx/tools-java/${TOOLS_JAVA_VER}/tools-java-${TOOLS_JAVA_VER}-jar-with-dependencies.jar --output tools-java.jar
- name: Setup Python tools
run: |
python3 -m pip install -U pip
python3 -m pip install spdx3-validate
- name: Validate SPDX 2.2 & SPDX 2.3 Documents
run: |
set +e
FAIL_COUNT=0
FAIL_FILES=""
for f in $(find . \( -path '*/spdx2.2/*' -o -path '*/spdx2.3/*' \) \( -name *.spdx -o -name *.json \)); do
echo "$f"
java -jar tools-java.jar Verify "$f"
if [ $? -ne 0 ]; then
FAIL_COUNT=$((FAIL_COUNT + 1))
FAIL_FILES="$FAIL_FILES\n$f"
fi
done
if [ $FAIL_COUNT -ne 0 ]; then
echo ""
echo "Files failed: $FAIL_COUNT"
echo -e "$FAIL_FILES"
exit 1
fi
- name: Validate SPDX 3.0 Documents
run: |
set +e
FAIL_COUNT=0
FAIL_FILES=""
for f in $(find . -type f -path '*/spdx3.0/*.json'); do
echo "$f"
spdx3-validate --quiet --json $f
if [ $? -ne 0 ]; then
FAIL_COUNT=$((FAIL_COUNT + 1))
FAIL_FILES="$FAIL_FILES\n$f"
EXIT_CODE=1
fi
done
if [ $FAIL_COUNT -ne 0 ]; then
echo ""
echo "Files failed: $FAIL_COUNT"
echo -e "$FAIL_FILES"
exit 1
fi