forked from NASA-PDS/ldd-gen-action
-
Notifications
You must be signed in to change notification settings - Fork 0
/
action.yaml
137 lines (117 loc) · 4.88 KB
/
action.yaml
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
# PDS: Git Action for LDD Generation
# =====================================
#
# This is a GitHub action that generates LDD for the current LDD Github Repo
---
name: '✅ PDS LDD Generation'
author: 'Jordan Padams <[email protected]>'
branding:
icon: 'archive'
color: 'green'
inputs:
data_path:
description: |
Absolute path to data to validate
required: true
pds4_im_version:
description: |
PDS4 Information Model Version. Defaults to the latest version. Use the semantic version, e.g. 1.14.0.0
required: false
default: 'latest'
pds4_development_release:
description: |
Flag to signify if this is a development release of the PDS4 Information Model
required: false
default: False
lddtool_development_release:
description: |
Flag to signify if the software should use the LDD Development release version
required: false
default: False
test_path:
description: |
Path to regression test data containing PDS4 labels.
required: false
logs_path:
description: |
Path to output software run logs
required: false
default: '/tmp/logs'
token:
description: |
Github token
required: true
enable_content_validation:
description: |
Flag to signify if validate should include content validation. By default, this is disabled.
required: false
default: False
runs:
using: 'composite'
steps:
- run: |
python -m pip install --upgrade pip setuptools wheel
python -m pip install pds-github-util
shell: bash
- run: |
dev_release=""
if [ "${{inputs.lddtool_development_release}}" == "true" ]; then
dev_release="--use_lddtool_unstable --with_pds4_version ${{inputs.pds4_im_version}}"
fi
ldd-gen --ingest_ldd_src_dir $GITHUB_WORKSPACE/src --ldd_output_path "${{inputs.data_path}}" --with_pds4_version "${{inputs.pds4_im_version}}" --token ${{inputs.token}} --output_log_path ${{inputs.logs_path}} $dev_release
shell: bash
- run: |
dev_release=""
if [ "${{inputs.pds4_development_release}}" == "true" ]; then
dev_release="--development_release"
fi
pds4-validate --datapath "${{inputs.data_path}}/*.xml" --skip_content_validation --with_pds4_version ${{inputs.pds4_im_version}} --schemas "${{inputs.data_path}}/*.xsd" --schematrons "${{inputs.data_path}}/*.sch" --token ${{inputs.token}} --output_log_path ${{inputs.logs_path}} $dev_release
shell: bash
- run: |
# Perform regression testing for VALID tests
if ls ${{inputs.test_path}}/*VALID.xml 1> /dev/null 2>&1 ; then
filepath="${{inputs.test_path}}/*VALID.xml"
elif ls ${{inputs.test_path}}/*/*VALID.xml 1> /dev/null 2>&1 ; then
filepath="${{inputs.test_path}}/*/*VALID.xml"
else
echo 'Regression Tests do not exist, skipping'
exit 0
fi
# Update info in examples
sed -i "s/\[IM_VERSION\]/${{inputs.pds4_im_version}}/g" $filepath
dev_release=""
if [ "${{inputs.pds4_development_release}}" == "true" ]; then
dev_release="--development_release"
fi
skip_content_validation=""
if [ "${{inputs.enable_content_validation}}" == "false" ]; then
skip_content_validation="--skip_content_validation"
fi
for file in $(find $filepath -type f); do
pds4-validate --datapath $file $skip_content_validation --with_pds4_version ${{inputs.pds4_im_version}} --schemas "${{inputs.data_path}}/*.xsd" --schematrons "${{inputs.data_path}}/*.sch" --token ${{inputs.token}} --output_log_path ${{inputs.logs_path}} $dev_release
done
shell: bash
- run: |
# Perform regression testing for FAIL tests
if ls ${{inputs.test_path}}/*FAIL.xml 1> /dev/null 2>&1 ; then
filepath="${{inputs.test_path}}/*FAIL.xml"
elif ls ${{inputs.test_path}}/*/*FAIL.xml 1> /dev/null 2>&1 ; then
filepath="${{inputs.test_path}}/*/*FAIL.xml"
else
echo 'Regression Tests do not exist, skipping'
exit 0
fi
# Update info in examples
sed -i "s/\[IM_VERSION\]/${{inputs.pds4_im_version}}/g" $filepath
dev_release=""
if [ "${{inputs.pds4_development_release}}" == "true" ]; then
dev_release="--development_release"
fi
skip_content_validation=""
if [ "${{inputs.enable_content_validation}}" == "false" ]; then
skip_content_validation="--skip_content_validation"
fi
for file in $(find $filepath -type f); do
pds4-validate --failure_expected --datapath "$file" $skip_content_validation --with_pds4_version ${{inputs.pds4_im_version}} --schemas "${{inputs.data_path}}/*.xsd" --schematrons "${{inputs.data_path}}/*.sch" --token ${{inputs.token}} --output_log_path ${{inputs.logs_path}} $dev_release
done
shell: bash