1+ name : Build And Run Reusable Workflow
2+
3+ on :
4+ workflow_call :
5+ inputs :
6+ # Optional inputs
7+ app-name :
8+ description : Application name, if different from repo name
9+ type : string
10+ required : false
11+ default : ${{ github.event.repository.name }}
12+ startup-string :
13+ description : Startup string to confirm, default will use "<APP> Initialized."
14+ type : string
15+ required : false
16+ default : ' '
17+ # Currently CFS apps have at most one dependency, so this only handles one for now
18+ dependency :
19+ description : Additional module/library that this app depends on
20+ type : string
21+ required : false
22+ default : ' '
23+ app-entrypoint-suffix :
24+ description : Symbol suffix to use as app entry point
25+ type : string
26+ required : false
27+ default : ' AppMain'
28+
29+ # Force bash to apply pipefail option so pipeline failures aren't masked
30+ defaults :
31+ run :
32+ shell : bash
33+
34+ jobs :
35+ # Checks for duplicate actions. Skips push actions if there is a matching or
36+ # duplicate pull-request action.
37+ checks-for-duplicates :
38+ runs-on : ubuntu-latest
39+ # Map a step output to a job output
40+ outputs :
41+ should_skip : ${{ steps.skip_check.outputs.should_skip }}
42+ steps :
43+ - id : skip_check
44+ uses : fkirc/skip-duplicate-actions@master
45+ with :
46+ concurrent_skipping : ' same_content'
47+ skip_after_successful_duplicate : ' true'
48+ do_not_skip : ' ["pull_request", "workflow_dispatch", "schedule"]'
49+
50+ build-app :
51+ needs : checks-for-duplicates
52+ if : ${{ needs.checks-for-duplicates.outputs.should_skip != 'true' || contains(github.ref, 'main') || contains(github.ref, 'dev') }}
53+ name : Build CFE with app
54+ runs-on : ubuntu-22.04
55+ container : ghcr.io/core-flight-system/cfsbuildenv-linux:latest
56+
57+ steps :
58+ # Note this also sets the APP_UPPER and APP_LOWER environment variables
59+ - name : Set up app source
60+ uses : nasa/cFS/actions/setup-app@dev
61+ with :
62+ app-name : ${{ inputs.app-name }}
63+ dependency : ${{ inputs.dependency }}
64+
65+ - name : Set up start string for verification
66+ run : |
67+ if [[ "${{ inputs.startup-string }}" == '' ]]; then
68+ echo "START_STRING=$APP_UPPER Initialized." >> $GITHUB_ENV
69+ else
70+ echo "START_STRING=${{ inputs.startup-string }}" >> $GITHUB_ENV
71+ fi
72+
73+ - name : Make install
74+ run : make -C build mission-install
75+
76+ - name : Generate Startup Link
77+ run : ln -s core-cpu1 ./build/exe/cpu1/container-start
78+
79+ - name : Replace startup script
80+ run : |
81+ truncate -s 0 ./build/exe/cpu1/cf/cfe_es_startup.scr
82+ if [ "x$APP_DEP_LOWER" != "x" ]
83+ then
84+ echo "CFE_LIB, $APP_DEP_LOWER, ${APP_DEP_UPPER}_Init, $APP_DEP_UPPER, 0, 0, 0x0, 0;" >> ./build/exe/cpu1/cf/cfe_es_startup.scr
85+ fi
86+ echo "CFE_APP, $APP_LOWER, ${APP_UPPER}_${{ inputs.app-entrypoint-suffix }}, $APP_UPPER, 80, 16384, 0x0, 0;" >> ./build/exe/cpu1/cf/cfe_es_startup.scr
87+ cat ./build/exe/cpu1/cf/cfe_es_startup.scr
88+
89+ - name : Archive binaries
90+ run : |
91+ cd $GITHUB_WORKSPACE/build/exe
92+ find -maxdepth 1 -mindepth 1 -type d | while read dir
93+ do
94+ inst=$(basename ${dir})
95+ tar Jcv -f $GITHUB_WORKSPACE/${inst}-bin.tar.xz -C ${inst} .
96+ done
97+
98+ - name : Upload all artifacts
99+ uses : actions/upload-artifact@v4
100+ with :
101+ name : ${{ inputs.app-name }}-bin
102+ path : ./*.tar.xz
103+
104+ run-app :
105+ needs : build-app
106+ name : Run CFE with app, check for startup messages
107+ runs-on : ubuntu-22.04
108+
109+ steps :
110+ - name : Download artifact
111+ uses : actions/download-artifact@v4
112+ with :
113+ name : ${{ inputs.app-name }}-bin
114+ path : ${{ inputs.app-name }}-bin
115+
116+ - name : List Files 1
117+ run : ls -lR .
118+
119+ - name : Unpack artifacts
120+ run : |
121+ for i in cpu1 host
122+ do
123+ mkdir -p "$i"
124+ tar Jxv -C "$i" -f "$GITHUB_WORKSPACE/${{ inputs.app-name }}-bin/$i-bin.tar.xz"
125+ done
126+
127+ - name : List Files 2
128+ run : |
129+ pwd
130+ ls -lR .
131+
132+ - name : Start CPU1 container
133+ id : start-cpu1
134+ uses : nasa/cFS/actions/start-cfs-container@dev
135+ with :
136+ binary-dir : ${{ github.workspace }}/cpu1
137+
138+ - name : Check CPU1 container
139+ id : check-cpu1
140+ uses : nasa/cFS/actions/healthcheck-logs@dev
141+ with :
142+ container-id : ${{ steps.start-cpu1.outputs.container-id }}
143+ healthcheck-regex : ' CFE_ES_Main entering OPERATIONAL state$'
144+
145+ - name : Shut down CFE
146+ if : ${{ steps.check-cpu1.outputs.ip-addr != '' }}
147+ working-directory : ./host
148+ run : |
149+ ./cmd_send -v --host=${{ steps.check-cpu1.outputs.ip-addr }} --endian=LE --pktid=0x1806 --cmdcode=2 --half=0x0002
150+ sleep 2
151+
152+ - name : Capture Logs
153+ if : ${{ always() && steps.start-cpu1.outputs.container-id != '' }}
154+ run : docker logs ${{ steps.start-cpu1.outputs.container-id }} > cFS_startup_cpu1.txt
155+
156+ - name : Stop CPU1 Container
157+ uses : nasa/cFS/actions/stop-cfs-container@dev
158+ with :
159+ container-id : ${{ steps.start-cpu1.outputs.container-id }}
160+
161+ - name : Archive results
162+ if : success() || failure()
163+ uses : actions/upload-artifact@v4
164+ with :
165+ name : cFS_startup_log
166+ path : cFS_startup_cpu1.txt
167+
168+ - name : Confirm startup string
169+ run : |
170+ if [[ -z $(grep "$START_STRING" cFS_startup_cpu1.txt) ]]; then
171+ echo "Startup verification string not found in log: $START_STRING"
172+ echo ""
173+ echo "Possible related event messages:"
174+ grep "/$APP_UPPER " cFS_startup_cpu1.txt
175+ exit -1
176+ fi
177+
178+ - name : Check for cFS Warnings
179+ if : success() || failure()
180+ run : |
181+ if [[ -n $(grep -i "warn\|err\|fail" cFS_startup_cpu1.txt) ]]; then
182+ echo "cFS startup warn|err|fail:"
183+ echo ""
184+ grep -i 'warn\|err\|fail' cFS_startup_cpu1.txt
185+ exit -1
186+ fi
0 commit comments