From a758c426dd0741302edf32732d6086a8a45d7b5d Mon Sep 17 00:00:00 2001 From: mrognor Date: Fri, 10 Jan 2025 19:39:37 +0300 Subject: [PATCH] Improve ci pipeline --- .github/workflows/sast.yml | 39 ++++++++++++++++++ .github/workflows/static.yml | 30 ++------------ .github/workflows/tests.yml | 79 ++++++++++++++++++++++++++++++++++++ ReadMe.md | 5 --- 4 files changed, 121 insertions(+), 32 deletions(-) create mode 100644 .github/workflows/sast.yml create mode 100644 .github/workflows/tests.yml diff --git a/.github/workflows/sast.yml b/.github/workflows/sast.yml new file mode 100644 index 0000000..7865dd4 --- /dev/null +++ b/.github/workflows/sast.yml @@ -0,0 +1,39 @@ +# Simple workflow for running static code analysis on GitHub Pages +name: Run static code analysis + +on: + # Runs on pushes targeting the default branch + push: + branches: ["master"] + + # Allows you to run this workflow manually from the Actions tab + workflow_dispatch: + +# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages +permissions: + contents: read + pages: write + id-token: write + +jobs: + # Single sast job + sast: + runs-on: ubuntu-24.04 + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Install packages + run: sudo apt-get update && sudo apt-get upgrade && sudo apt-get -y install clang clang-tidy cppcheck + + - name: Install CodeChecker + run: sudo pipx install CodeChecker --force + + - name: Run sast + run: ./Scripts/RunSast.sh + + # Upload sast artifacts + - uses: actions/upload-artifact@v4 + with: + name: SastArtifacts + path: ./Sast diff --git a/.github/workflows/static.yml b/.github/workflows/static.yml index 65fe02e..dcdf9ac 100644 --- a/.github/workflows/static.yml +++ b/.github/workflows/static.yml @@ -1,5 +1,5 @@ -# Simple workflow for deploying static content to GitHub Pages -name: Deploy static content to Pages +# Simple workflow for deploying generated documentation to GitHub Pages +name: Deploy documentation to Pages on: # Runs on pushes targeting the default branch @@ -35,35 +35,11 @@ jobs: uses: actions/configure-pages@v5 - name: Install packages - run: sudo apt-get update && sudo apt-get upgrade && sudo DEBIAN_FRONTEND=noninteractive TZ=Etc/UTC apt-get -y install doxygen graphviz lcov cmake pipx clang clang-tidy cppcheck python3 + run: sudo apt-get update && sudo apt-get upgrade && sudo apt-get -y install doxygen graphviz - - name: Install CodeChecker - run: sudo pipx install CodeChecker --force - - name: Create documentation run: ./Docs/Gendoc.sh - - name: Run tests - run: ./Scripts/RunTests.sh - - - name: Test coverage - run: ./Scripts/TestCoverage.sh - - - name: Move coverage artifact - run: mv ./Coverage ./Docs/Generated/html - - - name: Run sast - run: ./Scripts/RunSast.sh - - - name: Move sast artifacts - run: | - mv ./Sast/html_clang_tidy ./Docs/Generated/html - mv ./Sast/html_clangsa ./Docs/Generated/html - mv ./Sast/html_cppcheck ./Docs/Generated/html - - - name: Send report to telegram - run: ./.github/TelegramReport/SendCiReportToTelegram.sh ${{ secrets.BOT_ID }} ${{ secrets.CHAT_ID }} ${{ secrets.TOPIC_ID }} - - name: Upload artifact uses: actions/upload-pages-artifact@v3 with: diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml new file mode 100644 index 0000000..729c1bf --- /dev/null +++ b/.github/workflows/tests.yml @@ -0,0 +1,79 @@ +# Simple workflow for run tests on GitHub Actions +name: Run tests + +on: + # Runs on pushes targeting the default branch + push: + branches: ["master"] + + # Allows you to run this workflow manually from the Actions tab + workflow_dispatch: + +permissions: + contents: read + pages: write + id-token: write + +jobs: + # Run project tests + tests: + name: Build and run tests + runs-on: ubuntu-24.04 + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Install packages + run: sudo apt-get update && sudo apt-get upgrade && sudo apt-get -y install cmake lcov + + - name: Build and run tests + run: ./Scripts/RunTests.sh + + # Upload artifacts to reuse it in next jobs + - uses: actions/upload-artifact@v4 + with: + name: TestArtifacts + path: ./Build + + # Send report with tests result to telegram + telegram: + name: Send report to telegram + needs: tests + runs-on: ubuntu-24.04 + steps: + - name: Checkout + uses: actions/checkout@v4 + + - uses: actions/download-artifact@v4 + with: + name: TestArtifacts + path: ./Build + + - name: Send report to telegram + run: ./.github/TelegramReport/SendCiReportToTelegram.sh ${{ secrets.BOT_ID }} ${{ secrets.CHAT_ID }} ${{ secrets.TOPIC_ID }} + + # Run tests coverage + coverage: + name: Run tests coverage + needs: tests + runs-on: ubuntu-24.04 + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Install packages + run: sudo apt-get update && sudo apt-get upgrade && sudo apt-get -y install lcov + + - uses: actions/download-artifact@v4 + with: + name: TestArtifacts + path: ./Build + + - name: Run test coverage + run: ./Scripts/TestCoverage.sh + + # Upload coverage artifacts + - uses: actions/upload-artifact@v4 + with: + name: CoverageArtifacts + path: ./Coverage \ No newline at end of file diff --git a/ReadMe.md b/ReadMe.md index 1ee8fb6..c34247a 100644 --- a/ReadMe.md +++ b/ReadMe.md @@ -1,9 +1,4 @@ Full documentation available [here](https://mrognor.github.io/MVault/index.html) -Test coverage available [here](https://mrognor.github.io/MVault/Coverage/CodeCoverage.html) -Sast clang_tidy available [here](https://mrognor.github.io/MVault/html_clang_tidy/index.html#sort=file-path&asc=1) -Sast clangsa available [here](https://mrognor.github.io/MVault/html_clangsa/index.html#sort=file-path&asc=1) -Sast cppcheck available [here](https://mrognor.github.io/MVault/html_cppcheck/index.html#sort=file-path&asc=1) - # Configure project Cmake is used to configure the project. It is called via the **Configure** script.