Skip to content

Commit 938ce08

Browse files
authored
Merge pull request #961 from arielswalker/part-cfs/workflows#177-update-existing-workflows-internal-logic
Part cFS/workflows#177, Update Existing Workflows with Internal Logic
2 parents c808d4b + 5130b5a commit 938ce08

12 files changed

Lines changed: 614 additions & 218 deletions

File tree

.gitattributes

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
simple_defs export-ignore
2+
simple.mk export-ignore
3+
distbuild.mk export-ignore
4+
apps/sbn_f_remap export-ignore
5+
apps/sbn_udp export-ignore
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
name: Static Analysis Reusable Workflow
2+
3+
on:
4+
workflow_call:
5+
inputs:
6+
# Optional inputs
7+
source-dir:
8+
description: Directory containing source files
9+
type: string
10+
default: 'fsw'
11+
12+
# Force bash to apply pipefail option so pipeline failures aren't masked
13+
defaults:
14+
run:
15+
shell: bash
16+
17+
jobs:
18+
static-analysis:
19+
name: Run Static Analysis
20+
runs-on: ubuntu-22.04
21+
container: ghcr.io/core-flight-system/cfsbuildenv-linux:latest
22+
timeout-minutes: 15
23+
24+
steps:
25+
- name: Checkout Source
26+
uses: actions/checkout@v4
27+
with:
28+
path: source
29+
30+
- name: Run cppcheck
31+
uses: nasa/cFS/actions/cppcheck@dev
32+
id: run-cppcheck
33+
with:
34+
source-dir: source/${{ inputs.source-dir }}
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Build Document
1+
name: Build Document Reusable Workflow
22

33
on:
44
workflow_call:
@@ -23,17 +23,20 @@ on:
2323
description: Build the PDF
2424
type: boolean
2525
required: false
26-
default: true
27-
deploy:
28-
description: Deploy archived PDF to gh-pages
29-
type: boolean
30-
required: false
31-
default: true
26+
default: false
3227
needs_osal_api:
3328
description: Whether this depends on the osal public api (compatibility bridge)
3429
type: boolean
3530
required: false
3631
default: true
32+
defs:
33+
description: '*_defs directory'
34+
type: string
35+
required: false
36+
default: 'sample_defs'
37+
38+
env:
39+
WORK_PATH: ${{ github.workspace }}
3740

3841
# Force bash to apply pipefail option so pipeline failures aren't masked
3942
defaults:
@@ -58,62 +61,28 @@ jobs:
5861

5962
build-doc:
6063
needs: checks-for-duplicates
61-
if: ${{ needs.checks-for-duplicates.outputs.should_skip != 'true' || contains(github.ref, 'main') }}
64+
if: ${{ needs.checks-for-duplicates.outputs.should_skip != 'true' || contains(github.ref, 'main') || contains(github.ref, 'dev') }}
6265
name: Build Documentation
6366
runs-on: ubuntu-22.04
67+
container: ghcr.io/core-flight-system/cfsbuildenv-doxygen:latest
6468

6569
strategy:
6670
fail-fast: false
6771
matrix:
6872
target: ${{ fromJson(inputs.target) }}
6973

7074
steps:
71-
- name: Reject non-compatible deployment settings
72-
if: ${{ inputs.deploy == true && inputs.cache-key != '' }}
73-
run: |
74-
echo "Deployment when using cache not supported due to password fail issue"
75-
exit -1
76-
7775
- name: Get cache if supplied
7876
id: cache-src-bld
7977
if: ${{ inputs.cache-key != '' }}
8078
uses: actions/cache@v4
8179
with:
82-
path: /home/runner/work/${{ github.event.repository.name }}/${{ github.event.repository.name }}/*
80+
path: ${{ env.WORK_PATH }}/
8381
key: ${{ inputs.cache-key }}
8482

85-
- name: Checkout Bundle Main
86-
if: ${{ inputs.app-name != '' }}
87-
uses: actions/checkout@v4
88-
with:
89-
submodules: true
90-
repository: nasa/cFS
91-
92-
- name: Checkout Repo
93-
if: ${{ inputs.app-name != '' }}
94-
uses: actions/checkout@v4
95-
with:
96-
path: apps/${{ inputs.app-name }}
97-
98-
- name: Copy Files
99-
run: |
100-
cp ./cfe/cmake/Makefile.sample Makefile
101-
cp -r ./cfe/cmake/sample_defs sample_defs
102-
103-
- name: Add Repo To Build
104-
if: ${{ inputs.app-name != '' }}
105-
run: echo 'set(MISSION_GLOBAL_APPLIST ${{ inputs.app-name }})' >> sample_defs/targets.cmake
106-
107-
- name: Make Prep
108-
run: make prep
109-
110-
- name: Install Doxygen Dependencies
111-
run: sudo apt-get update && sudo apt-get install doxygen graphviz -y
112-
113-
- name: Install PDF Generation Dependencies
114-
if: ${{ inputs.buildpdf == true }}
115-
run: |
116-
sudo apt-get install texlive-latex-base texlive-fonts-recommended texlive-fonts-extra texlive-latex-extra
83+
- name: Set up app source
84+
if: steps.cache-src-bld.outputs.cache-hit != 'true'
85+
uses: nasa/cFS/actions/setup-app@dev
11786

11887
- name: Generate OSAL header list
11988
if: ${{ inputs.needs_osal_api == true }}
@@ -137,21 +106,25 @@ jobs:
137106
run: |
138107
if [[ -s ${{ matrix.target }}_stderr.txt ]]; then
139108
cat ${{ matrix.target }}_stderr.txt
140-
exit -1
109+
exit 1
141110
fi
142111
143112
- name: Check For Document Warnings
144113
run: |
145114
if [[ -s ${{ matrix.target }}-warnings.log ]]; then
146115
cat ${{ matrix.target }}-warnings.log
147-
exit -1
116+
exit 1
148117
fi
149118
150119
- name: Generate PDF
151120
if: ${{ inputs.buildpdf == true }}
152121
run: |
153-
make -C ./build/docs/${{ matrix.target }}/latex
154-
mkdir deploy
122+
if ! make LATEX_CMD="pdflatex -file-line-error -halt-on-error" -C ./build/docs/${{ matrix.target }}/latex > pdflatex.log; then
123+
echo "Errors reported, tail of latex output follows"
124+
tail -100 pdflatex.log
125+
exit -1
126+
fi
127+
mkdir -p deploy
155128
mv ./build/docs/${{ matrix.target }}/latex/refman.pdf ./deploy/${{ matrix.target }}.pdf
156129
# Could add pandoc and convert to github markdown
157130
# pandoc ${{ matrix.target }}.pdf -t gfm
@@ -161,13 +134,4 @@ jobs:
161134
uses: actions/upload-artifact@v4
162135
with:
163136
name: ${{ matrix.target }}_pdf
164-
path: ./deploy/${{ matrix.target }}.pdf
165-
166-
- name: Deploy to GitHub
167-
if: ${{ inputs.deploy == true }}
168-
uses: JamesIves/github-pages-deploy-action@v4
169-
with:
170-
token: ${{ secrets.GITHUB_TOKEN }}
171-
branch: gh-pages
172-
folder: deploy
173-
single-commit: true
137+
path: ./deploy/${{ matrix.target }}.pdf
Lines changed: 186 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,186 @@
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

Comments
 (0)