diff --git a/.github/actions/cookiecutter-check/bootstrap.expect b/.github/actions/cookiecutter-check/bootstrap.expect new file mode 100644 index 0000000000..45155b52b4 --- /dev/null +++ b/.github/actions/cookiecutter-check/bootstrap.expect @@ -0,0 +1,5 @@ +set timeout 180 +spawn fprime-bootstrap project +expect -re {.*Project name.*} +send "MyProject\r" +expect eof diff --git a/.github/actions/cookiecutter-check/component.expect b/.github/actions/cookiecutter-check/component.expect new file mode 100644 index 0000000000..23271780a9 --- /dev/null +++ b/.github/actions/cookiecutter-check/component.expect @@ -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 diff --git a/.github/actions/cookiecutter-check/deployment.expect b/.github/actions/cookiecutter-check/deployment.expect new file mode 100644 index 0000000000..fa2b647186 --- /dev/null +++ b/.github/actions/cookiecutter-check/deployment.expect @@ -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 diff --git a/.github/workflows/cookiecutters-test.yml b/.github/workflows/cookiecutters-test.yml new file mode 100644 index 0000000000..aab0abf3a3 --- /dev/null +++ b/.github/workflows/cookiecutters-test.yml @@ -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' + + - 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