From 94f118f0f978d10d196ff93eeebd0d99b0e135f1 Mon Sep 17 00:00:00 2001 From: Muhammad Nawaz Date: Tue, 5 Dec 2023 14:51:21 +0500 Subject: [PATCH] Updated github action workflows --- .github/workflows/common-build.yml | 43 +++++++++++++ .github/workflows/deploy-docs.yml | 82 +++++++++++++++++++++++++ .github/workflows/linux-build.yml | 8 +++ .github/workflows/linux_build.yml | 93 ----------------------------- .github/workflows/mac-build.yml | 8 +++ .github/workflows/mac_build.yml | 90 ---------------------------- .github/workflows/win_build.yml | 84 -------------------------- .github/workflows/windows-build.yml | 8 +++ 8 files changed, 149 insertions(+), 267 deletions(-) create mode 100644 .github/workflows/common-build.yml create mode 100644 .github/workflows/deploy-docs.yml create mode 100644 .github/workflows/linux-build.yml delete mode 100644 .github/workflows/linux_build.yml create mode 100644 .github/workflows/mac-build.yml delete mode 100644 .github/workflows/mac_build.yml delete mode 100644 .github/workflows/win_build.yml create mode 100644 .github/workflows/windows-build.yml diff --git a/.github/workflows/common-build.yml b/.github/workflows/common-build.yml new file mode 100644 index 0000000..340ee36 --- /dev/null +++ b/.github/workflows/common-build.yml @@ -0,0 +1,43 @@ +name: Common build and test steps +on: + workflow_call: + inputs: + os: + required: true + type: string + +jobs: + build-and-test: + runs-on: ${{ inputs.os }} + steps: + - name: Set EXT variable + shell: bash + run: | + if [[ "${{ runner.os }}" == "Windows" ]]; then + echo "EXT=.exe" >> $GITHUB_ENV + else + echo "EXT=" >> $GITHUB_ENV + fi + + - name: Checkout cpp-oasvalidator + uses: actions/checkout@v4 + with: + submodules: true + fetch-depth: 0 + + - uses: lukka/get-cmake@latest + + - name: Run CMake Ninja build all release preset including example, unittests, perftests + uses: lukka/run-cmake@v10 + id: runcmake + with: + workflowPreset: 'build-example-and-run-unittests' + + - name: Run Example + run: ./build/release/example/oasvalidator-example${{ env.EXT }} + + - name: Run Unit Tests + run: ./build/release/test/unittest/oasvalidator-unittests${{ env.EXT }} + + - name: Run Performance Tests + run: ./build/release/test/perftest/oasvalidator-perftests${{ env.EXT }} \ No newline at end of file diff --git a/.github/workflows/deploy-docs.yml b/.github/workflows/deploy-docs.yml new file mode 100644 index 0000000..47195c1 --- /dev/null +++ b/.github/workflows/deploy-docs.yml @@ -0,0 +1,82 @@ +name: Deploy docs and code coverage +on: + push: + branches: [ main ] + pull_request: + branches: [ main ] + +jobs: + build-and-deploy-docs-and-codecov: + runs-on: ubuntu-latest + + steps: + - name: Checkout cpp-oasvalidator + uses: actions/checkout@v4 + with: + submodules: true + fetch-depth: 0 + + - name: Set up Python + uses: actions/setup-python@v4 + with: + python-version: '3.x' + + - name: Set up latest Oracle JDK 21 + uses: oracle-actions/setup-java@v1 + with: + website: oracle.com + release: 21 + + - name: Install dependencies + run: | + sudo apt-get update + sudo apt-get install doxygen graphviz plantuml lcov -y + + - name: Install python dependencies + run: | + pip3 install gcovr sphinx breathe exhale furo sphinx-plantuml + + - uses: lukka/get-cmake@latest + + - name: Configure code coverage code coverage and docs + uses: lukka/run-cmake@v10 + with: + configurePreset: 'debug' + + - name: Build performance tests in release mode + uses: lukka/run-cmake@v10 + with: + configurePreset: 'release' + buildPreset: 'perftests-build' + + - name: Run performance tests + run: build/release/test/perftest/oasvalidator-perftests --benchmark_format=json > build/debug/docs/benchmark.json + + - name: Convert benchmark.json to benchmark.rst + run: python .github/workflows/convert_json_to_rst.py build/debug/docs/benchmark.json build/debug/docs/benchmark.rst + + - name: Build docs and code coverage + uses: lukka/run-cmake@v10 + with: + workflowPreset: 'build-docs-and-codecov' + + - name: Copy code coverage to docs + run: cp -r build/debug/covhtml-oasvalidator build/debug/docs/html + + - name: Deploy docs + uses: peaceiris/actions-gh-pages@v3 + with: + github_token: ${{ secrets.MY_PAT }} + publish_dir: build/debug/docs/html + + - name: Generate Coverage Report + if: github.ref == 'refs/heads/main' + run: | + lcov --capture --directory . --output-file coverage.info + lcov --remove coverage.info '/usr/*' --output-file coverage.info + lcov --list coverage.info + + - name: Upload coverage to Codecov + uses: codecov/codecov-action@v3 + env: + CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} \ No newline at end of file diff --git a/.github/workflows/linux-build.yml b/.github/workflows/linux-build.yml new file mode 100644 index 0000000..09077f8 --- /dev/null +++ b/.github/workflows/linux-build.yml @@ -0,0 +1,8 @@ +name: Ubuntu build and test +on: [push, workflow_dispatch] + +jobs: + linux-build-and-test: + uses: ./.github/workflows/common-build.yml + with: + os: ubuntu-latest \ No newline at end of file diff --git a/.github/workflows/linux_build.yml b/.github/workflows/linux_build.yml deleted file mode 100644 index d314e27..0000000 --- a/.github/workflows/linux_build.yml +++ /dev/null @@ -1,93 +0,0 @@ -name: Linux Build - -on: - push: - branches: - - main - #- '**' - pull_request: - branches: [ main ] - -jobs: - build: - runs-on: ubuntu-latest - - steps: - - name: Checkout cpp-oasvalidator - uses: actions/checkout@v4 - with: - submodules: 'recursive' - - - name: Set up Python - uses: actions/setup-python@v4 - with: - python-version: '3.x' - - - name: Setup Java 17 - uses: actions/setup-java@v3 - with: - java-version: '17' - distribution: 'adopt' - - - name: Install dependencies - run: | - sudo apt-get update - sudo apt-get install -y gcc g++ cmake lcov gcovr - sudo apt-get install -y plantuml - sudo apt-get install -yq doxygen - - - name: Install python dependencies - run: | - pip install sphinx breathe exhale furo sphinxcontrib-plantuml - - - name: Build and install libbenchmark - run: | - cd ./thirdparty/benchmark - mkdir build - cmake -E chdir "build" cmake -DBENCHMARK_ENABLE_TESTING=OFF -DBENCHMARK_ENABLE_GTEST_TESTS=OFF -DCMAKE_BUILD_TYPE=Release ../ - sudo cmake --build "build" --config Release --target install -- -j $(nproc) - - - name: Configure CMake - run: cmake -S . -B build -DBUILD_TESTS=ON -DBUILD_COVERAGE=ON -DBUILD_PERF=ON -DBUILD_DOCS=ON -DBUILD_EXAMPLE=ON - - - name: Build oasvalidator - run: cmake --build build --target oasvalidator --config Release -j $(nproc) - - - name: Build oasvalidator-unittests - run: cmake --build build --target oasvalidator-unittests --config Release -j $(nproc) - - - name: Build oasvalidator-perftests - run: cmake --build build --target oasvalidator-perftests --config Release -j $(nproc) - - - name: Run oasvalidator-perftests - run: build/test/perftest/oasvalidator-perftests --benchmark_format=json > build/test/perftest/benchmark.json - - - name: Convert benchmark.json to benchmark.rst - run: python .github/workflows/convert_json_to_rst.py build/test/perftest/benchmark.json build/docs/benchmark.rst - - - name: Build covhtml-oasvalidator - run: cmake --build build --target covhtml-oasvalidator --config Release -j $(nproc) - - - name: Build docs - run: cmake --build build --target docs --config Release -j $(nproc) - - - name: Copy covhtml-oasvalidator to docs - run: cp -r build/covhtml-oasvalidator build/docs/html - - - name: Deploy docs - uses: peaceiris/actions-gh-pages@v3 - with: - github_token: ${{ secrets.MY_PAT }} - publish_dir: build/docs/html - - - name: Generate Coverage Report - if: github.ref == 'refs/heads/main' - run: | - lcov --capture --directory . --output-file coverage.info - lcov --remove coverage.info '/usr/*' --output-file coverage.info - lcov --list coverage.info - - - name: Upload coverage to Codecov - uses: codecov/codecov-action@v3 - env: - CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} \ No newline at end of file diff --git a/.github/workflows/mac-build.yml b/.github/workflows/mac-build.yml new file mode 100644 index 0000000..e7ee6f5 --- /dev/null +++ b/.github/workflows/mac-build.yml @@ -0,0 +1,8 @@ +name: Mac build and test +on: [push, workflow_dispatch] + +jobs: + macos-build-and-test: + uses: ./.github/workflows/common-build.yml + with: + os: macos-latest diff --git a/.github/workflows/mac_build.yml b/.github/workflows/mac_build.yml deleted file mode 100644 index 916ffa6..0000000 --- a/.github/workflows/mac_build.yml +++ /dev/null @@ -1,90 +0,0 @@ -name: Mac Build - -on: - push: - branches: - - main - #- '**' - pull_request: - branches: [ main ] - -jobs: - build: - runs-on: macos-latest - - steps: - - uses: actions/checkout@v4 - with: - submodules: 'true' - - - name: Set up Python - uses: actions/setup-python@v4 - with: - python-version: '3.x' - - - name: Install dependencies - run: | - brew install cmake - brew install ccache - brew install doxygen - brew install lcov - brew install gcovr - - - name: Install python dependencies - run: | - pip install sphinx breathe exhale furo sphinxcontrib-plantuml - - - name: Configure CMake - run: cmake -S . -B build -DBUILD_TESTS=ON -DBUILD_COVERAGE=ON -DBUILD_PERF=ON -DBUILD_DOCS=ON -DBUILD_EXAMPLE=ON - - - name: Build oasvalidator - run: cmake --build build --target oasvalidator --config Release - - - name: Build oasvalidator-unittests - run: cmake --build build --target oasvalidator-unittests --config Release - - - name: Build oasvalidator-perftests - run: cmake --build build --target oasvalidator-perftests --config Release - - - name: Run oasvalidator-perftests - run: build/test/perftest/oasvalidator-perftests --benchmark_format=json > build/test/perftest/benchmark.json - - - name: Convert benchmark.json to benchmark.rst - run: python .github/workflows/convert_json_to_rst.py build/test/perftest/benchmark.json build/docs/benchmark.rst - - - name: Build covhtml-oasvalidator - run: cmake --build build --target covhtml-oasvalidator --config Release - - - name: Set up JDK 21 - uses: actions/setup-java@v3 - with: - distribution: 'temurin' - java-version: '21' - - - name: Install PlantUML - run: | - brew install plantuml - - - name: Build docs - run: cmake --build build --target docs --config Release - - - name: Copy covhtml-oasvalidator to docs - run: cp -r build/covhtml-oasvalidator build/docs/html - - - name: Deploy docs - uses: peaceiris/actions-gh-pages@v3 - with: - github_token: ${{ secrets.MY_PAT }} - publish_dir: build/docs/html - - - name: Generate Coverage Report - if: github.ref == 'refs/heads/main' - run: | - lcov --capture --directory . --output-file coverage.info - lcov --remove coverage.info '/usr/*' --output-file coverage.info - lcov --list coverage.info - - - name: Upload coverage to Codecov - uses: codecov/codecov-action@v3 - env: - CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} diff --git a/.github/workflows/win_build.yml b/.github/workflows/win_build.yml deleted file mode 100644 index bdd7743..0000000 --- a/.github/workflows/win_build.yml +++ /dev/null @@ -1,84 +0,0 @@ -name: Win Build - -on: - push: - branches: - - main - - '**' - pull_request: - branches: [ main ] - -jobs: - build: - runs-on: windows-latest - - steps: - - name: Checkout cpp-oasvalidator - uses: actions/checkout@v4 - with: - submodules: 'recursive' - - - name: Set up Python - uses: actions/setup-python@v4 - with: - python-version: '3.x' - - - name: Setup Java 17 - uses: actions/setup-java@v3 - with: - java-version: '17' - distribution: 'adopt' - - - name: Install doxygen - uses: ssciwr/doxygen-install@v1 - - - name: Install dependencies - run: | - choco install cmake --installargs 'ADD_CMAKE_TO_PATH=System' - choco install graphviz - choco install plantuml - choco install sphinx - - - name: Install python dependencies - run: | - pip install sphinx breathe exhale furo sphinxcontrib-plantuml - - - name: Configure CMake - run: cmake -S . -B build -DBUILD_TESTS=ON -DBUILD_PERF=ON -DBUILD_DOCS=ON -DBUILD_EXAMPLE=ON -DBUILD_SHARED_LIB=OFF - - name: List recusrive build artifacts - run: ls -R build - - name: Build oasvalidator - run: cmake --build build --target oasvalidator --config Release - - -# - name: Build example -# run: cmake --build build --target oasvalidator-example --config Release - -# - name: Run example -# run: build/example/Release/oasvalidator-example.exe - - - name: Build oasvalidator-unittests - run: cmake --build build --target oasvalidator-unittests --config Release - - - name: Run oasvalidator-unittests - run: build/test/unittest/Release/oasvalidator-unittests.exe - - - name: Build oasvalidator-perftests - run: cmake --build build --target oasvalidator-perftests --config Release -j $(nproc) - - - name: Run oasvalidator-perftests - run: build/test/perftest/Release/oasvalidator-perftests.exe --benchmark_format=json > build/test/perftest/Release/benchmark.json - - - name: List recusrive build - run: ls -R build - - name: Convert benchmark.json to benchmark.rst - run: python .github/workflows/convert_json_to_rst.py build/test/perftest/Release/benchmark.json build/docs/benchmark.rst - - - name: Build docs - run: cmake --build build --target docs - - - name: Deploy docs - uses: peaceiris/actions-gh-pages@v3 - with: - github_token: ${{ secrets.MY_PAT }} - publish_dir: build/docs/html diff --git a/.github/workflows/windows-build.yml b/.github/workflows/windows-build.yml new file mode 100644 index 0000000..d1cdf16 --- /dev/null +++ b/.github/workflows/windows-build.yml @@ -0,0 +1,8 @@ +name: Windows build and test +on: [push, workflow_dispatch] + +jobs: + windows-build-and-test: + uses: ./.github/workflows/common-build.yml + with: + os: windows-latest \ No newline at end of file