From fee851f0a11af5501fe6e028a3face49d680f4bb Mon Sep 17 00:00:00 2001 From: Jacob Date: Sat, 19 Oct 2024 10:28:02 -0500 Subject: [PATCH] Automatically run unit tests --- .github/workflows/all-tests.yaml | 89 ++++++++++++++++++++++++++++ .github/workflows/documentation.yaml | 46 -------------- .vscode/tasks.json | 4 +- docs/software/coverage.md | 2 +- 4 files changed, 92 insertions(+), 49 deletions(-) create mode 100644 .github/workflows/all-tests.yaml delete mode 100644 .github/workflows/documentation.yaml diff --git a/.github/workflows/all-tests.yaml b/.github/workflows/all-tests.yaml new file mode 100644 index 0000000..869bd62 --- /dev/null +++ b/.github/workflows/all-tests.yaml @@ -0,0 +1,89 @@ +name: All Tests + +on: + push: + branches: + - main + +jobs: + build-test-document: + runs-on: ubuntu-latest + container: + image: osrf/ros:iron-desktop-full + + steps: + - name: Create colcon workspace + shell: bash + run: | + apt-get update + apt-get install -y python3-colcon-common-extensions python3-colcon-lcov-result python3-rosdep git lcov cloc doxygen nodejs + mkdir -p ~/ekf_cal_ws/src + + - uses: actions/checkout@v4 + with: + path: 'ekf_cal_ws/src/ekf_cal' + + - name: Build in ekf_cal_ws + shell: bash + working-directory: ./ekf_cal_ws + run: | + rosdep update + source /opt/ros/$ROS_DISTRO/setup.bash + rosdep install --from-paths src --ignore-src --rosdistro=$ROS_DISTRO -y + colcon build --symlink-install --packages-select ekf_cal --event-handlers console_cohesion+ --cmake-args -DCMAKE_C_FLAGS='--coverage' -DCMAKE_CXX_FLAGS='--coverage' + echo "Compile complete." + + - name: Run tests + shell: bash + working-directory: ./ekf_cal_ws + run: | + source /opt/ros/$ROS_DISTRO/setup.bash + colcon test --packages-select ekf_cal --pytest-with-coverage --pytest-args --cov-report=term --event-handlers console_direct+ + + - name: Test Summary + uses: test-summary/action@v2 + with: + paths: "./ekf_cal_ws/build/ekf_cal/test_results/ekf_cal/*.xml" + output: ./ekf_cal_ws/src/ekf_cal/docs/doxygen/html/test-summary.md + if: always() + + - name: Count Lines of Code + working-directory: ./ekf_cal_ws/src/ekf_cal + shell: bash + run: | + echo 'Count Lines of Code {#cloc}\n============' > docs/software/cloc.md + cloc src eval --md | tail -n +4 >> docs/software/cloc.md + sed -i 's/--------|--------|--------|--------|--------/| | | | | |/' docs/software/cloc.md + + - name: Run Doxygen + working-directory: ./ekf_cal_ws/src/ekf_cal + shell: bash + run: | + doxygen .doxyfile + + - name: Generate lcov report + shell: bash + working-directory: ./ekf_cal_ws + run: | + source /opt/ros/$ROS_DISTRO/setup.bash + colcon lcov-result --packages-select ekf_cal --filter '*_test.cpp' '*_main.cpp' --lcov-config-file src/ekf_cal/.lcovrc + cp -r lcov/ ./src/ekf_cal/docs/doxygen/html/ + + - name: Upload Artifact + uses: actions/upload-pages-artifact@v1 + with: + path: ./ekf_cal_ws/src/ekf_cal/docs/doxygen/html + + deploy-documentation: + needs: build-test-document + permissions: + pages: write + id-token: write + environment: + name: github-pages + url: ${{ steps.deployment.outputs.page_url }} + runs-on: ubuntu-latest + steps: + - name: Deploy to GitHub Pages + id: deployment + uses: actions/deploy-pages@v2 \ No newline at end of file diff --git a/.github/workflows/documentation.yaml b/.github/workflows/documentation.yaml deleted file mode 100644 index 7c067b8..0000000 --- a/.github/workflows/documentation.yaml +++ /dev/null @@ -1,46 +0,0 @@ -name: Documentation - -on: - push: - branches: - - main - -jobs: - build-documentation: - runs-on: ubuntu-latest - steps: - - name: Checkout - uses: actions/checkout@v4 - with: - submodules: 'true' - - name: Count Lines of Code - uses: djdefi/cloc-action@6 - with: - options: --exclude-lang=CSS,CSV,HTML,JavaScript,make,SVG,TeX,YAML --md --report-file=cloc.md - - name: Format and move cloc.md - run: | - echo -e 'Count Lines of Code {#cloc}\n============\n' > docs/software/cloc.md - cat cloc.md | tail -n +4 >> docs/software/cloc.md - sed -i 's/--------|--------|--------|--------|--------/| | | | | |/' docs/software/cloc.md - rm cloc.md - - name: Run Doxygen - uses: mattnotmitt/doxygen-action@1.9.5 - with: - doxyfile-path: .doxyfile - - name: Upload Artifact - uses: actions/upload-pages-artifact@v1 - with: - path: docs/doxygen/html - deploy-documentation: - needs: build-documentation - permissions: - pages: write - id-token: write - environment: - name: github-pages - url: ${{ steps.deployment.outputs.page_url }} - runs-on: ubuntu-latest - steps: - - name: Deploy to GitHub Pages - id: deployment - uses: actions/deploy-pages@v2 \ No newline at end of file diff --git a/.vscode/tasks.json b/.vscode/tasks.json index 153df7f..996c99a 100644 --- a/.vscode/tasks.json +++ b/.vscode/tasks.json @@ -41,7 +41,7 @@ "label": "test coverage", "detail": "Run coverage tests of ekf_cal", "type": "shell", - "command": "rm -r lcov; colcon test --packages-select ekf_cal --pytest-with-coverage --pytest-args --cov-report=term --event-handlers console_direct+", + "command": "rm -r lcov; rm -r ${workspaceFolder}/docs/doxygen/html/lcov; colcon test --packages-select ekf_cal --pytest-with-coverage --pytest-args --cov-report=term --event-handlers console_direct+", "group": "test", "problemMatcher": "$gcc", "dependsOn": "build coverage", @@ -53,7 +53,7 @@ "label": "report coverage", "detail": "Generate coverage report of ekf_cal tests", "type": "shell", - "command": "colcon lcov-result --packages-select ekf_cal --filter '*_test.cpp' '*_main.cpp' --lcov-config-file ${workspaceFolder}/.lcovrc", + "command": "colcon lcov-result --packages-select ekf_cal --filter '*_test.cpp' '*_main.cpp' --lcov-config-file ${workspaceFolder}/.lcovrc; cp -r lcov/ src/ekf_cal/docs/doxygen/html/lcov", "group": "test", "problemMatcher": "$gcc", "dependsOn": "test coverage", diff --git a/docs/software/coverage.md b/docs/software/coverage.md index b993e5c..c11e750 100644 --- a/docs/software/coverage.md +++ b/docs/software/coverage.md @@ -9,6 +9,6 @@ p {height:100%;} - + \endhtmlonly \ No newline at end of file