generated from pds-data-dictionaries/ldd-template
-
Notifications
You must be signed in to change notification settings - Fork 1
208 lines (173 loc) · 6.46 KB
/
ldd-ci.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
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
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
# This workflow will build a package using Maven and then publish it to GitHub packages when a release is created
# For more information see: https://github.com/actions/setup-java#apache-maven-with-a-settings-path
---
name: PDS4 LDD Automation
on:
push:
branches:
- '**'
- '!main'
- '!gh-pages'
paths:
- src/**
- .github/**
- pds4_versions.txt
workflow_dispatch:
env:
REGRESSION_TEST_PATH: ${{ format('{0}/{1}/', github.workspace, 'test') }}
# TODO - Have to hard-code this for now since Actions don't yet allow the use of env here.
LOGS_PATH: ${{ format('{0}/{1}', github.workspace, 'logs') }}
DEPLOY_PATH: ${{ format('{0}/{1}/{2}/{3}', github.workspace, 'build', 'development', github.sha) }}
jobs:
get_versions:
name: Get PDS4 Versions
runs-on: ubuntu-latest
if: github.actor != 'pdsen-ci'
outputs:
matrix: ${{ steps.set-matrix.outputs.matrix }}
steps:
- uses: actions/checkout@v4
with:
token: ${{ secrets.ADMIN_GITHUB_TOKEN || github.token }}
ssh-key: ${{ secrets.SSH_KEY }}
- id: set-matrix
run: |
# Look through lines and pull out the versions
while read -r line; do
if [[ ! -z "$line" ]]; then
versions=$versions'"'$line'"',
fi
done < pds4_versions.txt
versions="[${versions::-1}]"
echo "{\"pds4_version\":${versions}}"
# Baseline: Set pds4 version to versions from file
echo "matrix={\"pds4_version\": $versions}" >> $GITHUB_OUTPUT
build:
name: 'Generate and Validate'
needs: get_versions
runs-on: ubuntu-latest
if: github.actor != 'pdsen-ci'
strategy:
matrix: ${{fromJson(needs.get_versions.outputs.matrix)}}
steps:
- uses: actions/checkout@v4
with:
token: ${{ secrets.ADMIN_GITHUB_TOKEN || github.token }}
ssh-key: ${{ secrets.SSH_KEY }}
- name: Set up Python 3
uses: actions/setup-python@v5
with:
python-version: '3.9'
- name: Generate LDDs
id: generate
uses: NASA-PDS/ldd-gen-action@main
with:
data_path: ${{ format('{0}/{1}', env.DEPLOY_PATH, matrix.pds4_version) }}
pds4_im_version: ${{ matrix.pds4_version }}
pds4_development_release: ${{ matrix.pds4_development_release }}
lddtool_development_release: ${{ matrix.lddtool_development_release }}
test_path: ${{ env.REGRESSION_TEST_PATH }}
logs_path: ${{ env.LOGS_PATH }}
token: ${{ secrets.ADMIN_GITHUB_TOKEN }}
- name: Check logs
run: |
ls -R ${{ env.LOGS_PATH }}
- name: Upload LDDs to Github Action Artifacts
uses: actions/upload-artifact@v4
with:
name: v${{matrix.pds4_version}}_LDDs
path: ${{ env.DEPLOY_PATH }}
if: ${{ always() }}
- name: Upload Logs to Github Action Artifacts
uses: actions/upload-artifact@v4
with:
name: v${{matrix.pds4_version}}_execution_logs
path: ${{ env.LOGS_PATH }}
if: ${{ always() }}
upload_logs_only: # job 3
name: 'Add Run Logs to Github'
runs-on: ubuntu-latest
needs: build
if: ${{ failure() && github.actor != 'pdsen-ci' }}
steps:
- uses: actions/checkout@v4
with:
token: ${{ secrets.ADMIN_GITHUB_TOKEN || github.token }}
ssh-key: ${{ secrets.SSH_KEY }}
- uses: actions/download-artifact@v4
with:
path: /tmp/artifacts
- name: Display structure of downloaded files
run: ls -R /tmp/artifacts
- name: Clean out old logs
run: |
path=$(dirname ${{ env.LOGS_PATH }})
rm -fr $path/*
- name: Move the execution logs to their new home
run: |
rm -fr ${{ env.LOGS_PATH }}
mkdir -p ${{ env.LOGS_PATH }}
cp -R /tmp/artifacts/*logs ${{ env.LOGS_PATH }}/
- name: Display structure of downloaded files
run: ls -R ${{ env.LOGS_PATH }}
- name: Push logs to Github
run: |
git config --local user.email "pdsen-ci@jpl.nasa.gov"
git config --local user.name "PDSEN CI Bot"
git add -A ${{ env.LOGS_PATH }}
git commit -m "Add logs from failed LDD generation"
git push origin HEAD
upload_all: # job 3
name: 'Add LDDs and Logs to Github'
runs-on: ubuntu-latest
needs: build
if: ${{ github.actor != 'pdsen-ci' }}
steps:
- uses: actions/checkout@v4
with:
token: ${{ secrets.ADMIN_GITHUB_TOKEN || github.token }}
ssh-key: ${{ secrets.SSH_KEY }}
- uses: actions/download-artifact@v4
with:
path: /tmp/artifacts
- name: Display structure of downloaded files
run: |
ls -R /tmp/artifacts
- name: Clean previous dev/snapshot tags
run: |
git fetch --prune --unshallow --tags
git tag -l | grep 'dev' | xargs -t -I arg sh -c 'git tag -d arg;git push --delete origin arg;'
- name: Clean out old LDDs and logs
run: |
path=$(dirname ${{ env.DEPLOY_PATH }})
rm -fr $path/*
path=${{ env.LOGS_PATH }}
rm -fr $path/*
- name: Move the LDDs to their new home
run: |
mkdir -p ${{ env.DEPLOY_PATH }}
ls -R /tmp/artifacts/*LDDs/*
rsync -av /tmp/artifacts/*LDDs/* ${{ env.DEPLOY_PATH }}
- name: Display structure of downloaded files
run: ls -R ${{ env.DEPLOY_PATH }}
- name: If Release Branch, move to release dir
shell: bash
run: |
if [[ "${{github.ref}}" == *"release"* ]]; then
rsync -av /tmp/artifacts/*LDDs/* ${{github.workspace}}/build/release/
ls -R ${{github.workspace}}/build/release/
fi
- name: Move the execution logs to their new home
run: |
rm -fr ${{ env.LOGS_PATH }}
mkdir -p ${{ env.LOGS_PATH }}
rsync -av /tmp/artifacts/*logs ${{ env.LOGS_PATH }}/
- name: Display structure of downloaded files
run: ls -R ${{ env.LOGS_PATH }}
- name: Push LDDs and Logs to Github
run: |
git config --local user.email "pdsen-ci@jpl.nasa.gov"
git config --local user.name "PDSEN CI Bot"
git add -A $(dirname ${{ env.DEPLOY_PATH }}) ${{ env.LOGS_PATH }} ${{github.workspace}}/build/release/
git commit -m "Auto-generated LDDs by PDSEN CI Bot"
git push origin HEAD