forked from cdisc-org/DDF-RA
-
Notifications
You must be signed in to change notification settings - Fork 0
108 lines (107 loc) · 5.77 KB
/
diff-and-data-dict.yml
File metadata and controls
108 lines (107 loc) · 5.77 KB
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
name: Generate Diff and Data Dict
on:
workflow_dispatch:
inputs:
prev-branch:
description: "Previous Branch/Tag"
required: false
default: "main"
push:
branches-ignore:
- "main"
paths:
- Deliverables/UML/USDM_UML.xmi
- Deliverables/CT/USDM_CT.xlsx
- Deliverables/API/USDM_API.json
jobs:
Diff_And_Data_Dict:
name: Generate Diff and Data Dict
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Set prev-branch to main for automated workflows
id: prev-branch
run: |
USER_INPUT=${{ inputs.prev-branch }}
echo "value=${USER_INPUT:-"main"}" >> "$GITHUB_OUTPUT"
- name: Checkout selected or current branch to currRelease dir
uses: actions/checkout@v4
with:
path: currRelease
- name: Checkout specified or main branch to prevRelease dir
uses: actions/checkout@v4
with:
path: prevRelease
ref: ${{ steps.prev-branch.outputs.value }}
- name: Checkout the usdm dictionary generator to DDF-RA-Tools dir
uses: actions/checkout@v4
with:
repository: cdisc-org/DDF-RA-Tools
path: DDF-RA-Tools
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: "3.12"
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r DDF-RA-Tools/requirements.txt
- name: Install XML Starlet
run: sudo apt-get install -y xmlstarlet
- name: Get the previous and current version numbers
run: |
echo "PREVIOUS_VERSION=$(jq -r '.info.version' prevRelease/Deliverables/API/USDM_API.json | cut -d ' ' -f1 | tr . -)" >> $GITHUB_ENV
echo "CURRENT_VERSION=${GITHUB_REF_NAME//release-/}" >> $GITHUB_ENV
echo "CURRENT_API_VERSION=$(jq -r '.info.version' currRelease/Deliverables/API/USDM_API.json | cut -d ' ' -f1 | tr . -)" >> $GITHUB_ENV
echo "CURRENT_UML_VERSION=$(xmlstarlet sel -t -v '//diagram/properties[@name="USDM" and @type="Logical"]/../project/@version' currRelease/Deliverables/UML/USDM_UML.xmi | cut -d ' ' -f1 | tr . -)" >> $GITHUB_ENV
- name: Fail due to unexpected version numbers
if: ${{ !(contains(env.PREVIOUS_VERSION,'-') && contains(env.CURRENT_VERSION,'-') && contains(env.CURRENT_API_VERSION,'-') && contains(env.CURRENT_UML_VERSION,'-') && env.PREVIOUS_VERSION != env.CURRENT_VERSION && env.CURRENT_API_VERSION == env.CURRENT_VERSION && startsWith(env.CURRENT_VERSION, env.CURRENT_UML_VERSION))}}
run: |
echo "Previous and current version numbers are not as expected!"
echo "- PREVIOUS_VERSION comes from the info/version value in USDM_API.json in the previous branch"
echo "- CURRENT_VERSION comes from the name of the current branch"
echo "- CURRENT_API_VERSION comes from the info/version value in USDM_API.json in the current branch"
echo "- CURRENT_UML_VERSION comes from the version property of the UML diagram called 'USDM'"
echo "Dots in any extracted version numbers are changed to hyphens, and it is expected that:"
echo "- A value is found for every version number"
echo "- PREVIOUS_VERSION and CURRENT_VERSION are different"
echo "- CURRENT_API_VERSION is the same as CURRENT_VERSION"
echo "- The value of CURRENT_UML_VERSION is found at the start of CURRENT_VERSION"
exit 1
- name: Copy the files needed by the usdm dictionary generator
run: |
cp prevRelease/Deliverables/UML/USDM_UML.xmi DDF-RA-Tools/resources/prevRelease/.
cp currRelease/Deliverables/UML/USDM_UML.xmi DDF-RA-Tools/resources/currRelease/.
cp prevRelease/Deliverables/CT/USDM_CT.xlsx DDF-RA-Tools/resources/prevRelease/.
cp currRelease/Deliverables/CT/USDM_CT.xlsx DDF-RA-Tools/resources/currRelease/.
cp prevRelease/Deliverables/API/USDM_API.json DDF-RA-Tools/resources/prevRelease/.
cp currRelease/Deliverables/API/USDM_API.json DDF-RA-Tools/resources/currRelease/.
- name: Run the usdm dictionary generator
run: |
cd DDF-RA-Tools
python3 ./main.py
cd ../
- name: Copy the generated dataDictionary to the current branch
run: cp DDF-RA-Tools/dataDictionary.MD "currRelease/Deliverables/UML/."
- name: Copy and rename the generated diff to the current branch
run: |
cp DDF-RA-Tools/UML_DELTA.csv "currRelease/Deliverables/UML/UML_DELTA_${{ env.PREVIOUS_VERSION}}_${{ env.CURRENT_VERSION}}.csv"
cp DDF-RA-Tools/CT_DELTA.csv "currRelease/Deliverables/CT/CT_DELTA_${{ env.PREVIOUS_VERSION}}_${{ env.CURRENT_VERSION}}.csv"
cp DDF-RA-Tools/API_DELTA.csv "currRelease/Deliverables/API/API_DELTA_${{ env.PREVIOUS_VERSION}}_${{ env.CURRENT_VERSION}}.csv"
- name: Copy the generated dataStructure to the current branch
run: cp DDF-RA-Tools/dataStructure.yml "currRelease/Deliverables/UML/."
- name: Copy the generated alignments to the current branch
run: cp DDF-RA-Tools/alignment.csv "currRelease/Deliverables/UML/."
- name: Copy the generated test data template to the current branch
run: cp "DDF-RA-Tools/CORE Test Data Template.xlsx" "currRelease/Documents/CORE Test Data Template/."
- name: Commit and push the new files to the current branch
run: |
cd currRelease
git config user.name github-actions
git config user.email github-actions@cdisc.org
git add .
git diff-index --quiet HEAD || git commit -m "Generate Diff and Data Dict"
git push
# Running locally:
# gh act workflow_dispatch -P ubuntu-latest=catthehacker/ubuntu:act-latest --secret-file ../DDF-RA-Actions/my.secrets