Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Validate Templates (#2387) #2990

Merged
merged 11 commits into from
Dec 5, 2024
5 changes: 5 additions & 0 deletions .github/actions/cookiecutter-check/bootstrap.expect
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
set timeout 180
LeStarch marked this conversation as resolved.
Show resolved Hide resolved
spawn fprime-bootstrap project
expect -re {.*Project name.*}
send "MyProject\r"
expect eof
24 changes: 24 additions & 0 deletions .github/actions/cookiecutter-check/component.expect
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
set timeout 60
spawn fprime-util new --component
expect -re {.*Component name.*}
send "MyComponent\r"
expect -re {.*Component short description.*}
send "test component\r"
expect -re {.*Component namespace.*}
send "Components\r"
expect -re {.*Select component kind}
send "1\r"
expect -re {.*Enable Commands.*}
send "1\r"
expect -re {.*Enable Telemetry.*}
send "1\r"
expect -re {.*Enable Events.*}
send "1\r"
expect -re {.*Enable Parameters.*}
send "1\r"
expect -re {Add MyComponent to.*}
send "yes\r"
expect -re {Generate implementation files.*}
send "yes\r"
expect -re {.*Created new component.*}
expect eof
9 changes: 9 additions & 0 deletions .github/actions/cookiecutter-check/deployment.expect
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
set timeout 60
spawn fprime-util new --deployment
expect -re {Deployment name.*}
send "MyDeployment\r"
expect -re {.*Select communication driver type}
send "1\r"
expect -re "Add .*MyDeployment.*"
send "yes\r"
expect eof
93 changes: 93 additions & 0 deletions .github/workflows/cookiecutters-test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
name: Cookiecutters Tests

on:
push:
branches: [ devel, release/** ]
pull_request:
# The branches below must be a subset of the branches above
branches: [ devel, release/** ]
paths-ignore:
- 'docs/**'
- '**.md'
- '.github/actions/spelling/**'
- '.github/ISSUE_TEMPLATE/**'



# This workflow tests the project bootstrapping and cookiecutter templates by creating
# a new project, deployment and component and building them
# This uses the `expect` utility to feed input into the various cookiecutter prompts

jobs:

Validate:
runs-on: ubuntu-latest
steps:
# Checkout only the bootstrap.expect file, since the full F´ repo will be
# checked out as part of the fprime-bootstrap process
- name: "Retrieve bootstrap.expect file"
uses: actions/checkout@v4
with:
sparse-checkout: |
.github/actions/cookiecutter-check/bootstrap.expect
sparse-checkout-cone-mode: false
fetch-depth: 0

- name: "Setup Python"
uses: actions/setup-python@v5
with:
python-version: '3.11'
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why pick this version in particular? Why not just use python?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No reason for this specific version, I just like to lock versions down so that there is not one additional variable in case of failure. The goal is to test the cookiecutter templates.


- name: "Install expect and fprime-bootstrap@devel"
run: |
sudo apt-get install expect
pip install git+https://github.com/fprime-community/fprime-bootstrap@devel

- name: "Bootstrap Project"
run: |
expect .github/actions/cookiecutter-check/bootstrap.expect

# Overlay fprime@current_rev in new project so that we build with it in the tests
# current_rev is devel on the devel branch and the PR revision in PR checks
- name: "Overlay fprime@current_rev in new project"
uses: actions/checkout@v4
with:
submodules: true
path: ./MyProject/fprime
fetch-depth: 0

- name: "Update dependencies and install fprime-tools@devel"
run: |
cd MyProject
. fprime-venv/bin/activate
pip install -U -r ./fprime/requirements.txt
pip install git+https://github.com/nasa/fprime-tools@devel

- name: "Version Check"
run: |
cd MyProject
. fprime-venv/bin/activate
fprime-util version-check

- name: "Test Generate and Build Project"
run: |
cd MyProject
. fprime-venv/bin/activate
fprime-util generate
fprime-util build -j4

- name: "Test New Deployment and Build"
run: |
cd MyProject
. fprime-venv/bin/activate
expect ./fprime/.github/actions/cookiecutter-check/deployment.expect
cd MyDeployment
fprime-util build -j4

- name: "Test New Component and Build"
run: |
cd MyProject
. fprime-venv/bin/activate
expect ./fprime/.github/actions/cookiecutter-check/component.expect
cd MyComponent
fprime-util build -j4
Loading