diff --git a/.github/workflows/autotest.yml b/.github/workflows/autotest.yml new file mode 100644 index 0000000000..35c422ed70 --- /dev/null +++ b/.github/workflows/autotest.yml @@ -0,0 +1,42 @@ +name: autotest + +on: + push: + branches: [ main ] + pull_request: + branches: [ main ] + +env: + # Customize the CMake build type here (Release, Debug, RelWithDebInfo, etc.) + BUILD_TYPE: Debug + +jobs: + build: + # The CMake configure and build commands are platform agnostic and should work equally well on Windows or Mac. + # You can convert this to a matrix build if you need cross-platform coverage. + # See: https://docs.github.com/en/free-pro-team@latest/actions/learn-github-actions/managing-complex-workflows#using-a-build-matrix + runs-on: macos-latest + + steps: + - uses: actions/checkout@v2 + with: + fetch-depth: 0 + lfs: true + - name: Run sync_deps script + run: ./sync_deps.sh + shell: bash + - name: Run autotest script + run: | + chmod +x autotest.sh + ./autotest.sh + shell: bash + - uses: actions/upload-artifact@v2 + with: + name: result + path: result + + + + + + diff --git a/.github/workflows/code-format.yml b/.github/workflows/code-format.yml new file mode 100644 index 0000000000..7e3f624e5f --- /dev/null +++ b/.github/workflows/code-format.yml @@ -0,0 +1,21 @@ +name: code-format + +on: [push, pull_request, pull_request_target] + +concurrency: + group: code-format-${{ github.ref }} + cancel-in-progress: true + +jobs: + code-format: + runs-on: ubuntu-20.04 + steps: + - uses: actions/checkout@v2 + + - uses: DoozyX/clang-format-lint-action@v0.13 + with: + source: './src ./test' + exclude: '.' + extensions: 'h,cpp' + clangFormatVersion: 12 + style: google diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml new file mode 100644 index 0000000000..4c3269a212 --- /dev/null +++ b/.github/workflows/codeql-analysis.yml @@ -0,0 +1,83 @@ +# For most projects, this workflow file will not need changing; you simply need +# to commit it to your repository. +# +# You may wish to alter this file to override the set of languages analyzed, +# or to provide custom queries or build logic. +# +# ******** NOTE ******** +# We have attempted to detect the languages in your repository. Please check +# the `language` matrix defined below to confirm you have the correct set of +# supported CodeQL languages. +# +name: "CodeQL" + +on: + push: + branches: [ main ] + pull_request: + # The branches below must be a subset of the branches above + branches: [ main ] + paths: + - 'src/**' + - 'test/**' + schedule: + - cron: '0 20 * * 4' + +jobs: + analyze: + name: Analyze + runs-on: macos-latest + permissions: + actions: read + contents: read + security-events: write + + strategy: + fail-fast: false + matrix: + language: [ 'cpp'] + # CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python', 'ruby' ] + # Learn more about CodeQL language support at https://git.io/codeql-language-support + + steps: + - name: Checkout repository + uses: actions/checkout@v2 + with: + fetch-depth: 0 + lfs: true + - name: Install Dependencies + run: | + pip install diff_cover + brew install gcovr + - name: Run sync_deps script + run: ./sync_deps.sh + shell: bash + + # Initializes the CodeQL tools for scanning. + - name: Initialize CodeQL + uses: github/codeql-action/init@v1 + with: + languages: ${{ matrix.language }} + # If you wish to specify custom queries, you can do so here or in a config file. + # By default, queries listed here will override any specified in a config file. + # Prefix the list here with "+" to use these queries and those in the config file. + # queries: ./path/to/local/query, your-org/your-repo/queries@main + + # Autobuild attempts to build any compiled languages (C/C++, C#, or Java). + # If this step fails, then you should remove it and run the build manually (see below) + - name: Autobuild + uses: github/codeql-action/autobuild@v1 + + # ℹī¸ Command-line programs to run using the OS shell. + # 📚 https://git.io/JvXDl + + # ✏ī¸ If the Autobuild fails above, remove it and uncomment the following three lines + # and modify them (or add more) to build your code if your project + # uses a compiled language + + #- run: | + # make bootstrap + # make release + + - name: Perform CodeQL Analysis + uses: github/codeql-action/analyze@v1 diff --git a/Linux_build.md b/Linux_build.md index 0d3e660e15..65e5e7f430 100644 --- a/Linux_build.md +++ b/Linux_build.md @@ -38,4 +38,4 @@ The library files that the sample project depends on come from the previous step. - \ No newline at end of file + ##test \ No newline at end of file diff --git a/autotest.sh b/autotest.sh new file mode 100755 index 0000000000..122fe4d91f --- /dev/null +++ b/autotest.sh @@ -0,0 +1,52 @@ +#!/usr/bin/env bash + +function make_dir() { + rm -rf $1 + mkdir -p $1 +} + +echo "shell log - autotest start begin " + +echo `pwd` + +WORKSPACE=$(pwd) + +cd $WORKSPACE + +make_dir result +make_dir build + +cd build + +cmake -DcppFlags="-fprofile-arcs -ftest-coverage -g -O0" ../ +if test $? -eq 0 +then +echo "~~~~~~~~~~~~~~~~~~~CMakeLists OK~~~~~~~~~~~~~~~~~~" +else +echo "~~~~~~~~~~~~~~~~~~~CMakeLists error~~~~~~~~~~~~~~~~~~" +exit -1 +fi + +cmake --build . --target PAGFullTest -- -j 12 +if test $? -eq 0 +then +echo "~~~~~~~~~~~~~~~~~~~PAGFullTest make successed~~~~~~~~~~~~~~~~~~" +else +echo "~~~~~~~~~~~~~~~~~~~PAGFullTest make error~~~~~~~~~~~~~~~~~~" +exit -1 +fi + +./PAGFullTest --gtest_output=json > $WORKSPACE/result/autotest.json + +if test $? -eq 0 + +then +echo "~~~~~~~~~~~~~~~~~~~PAGFullTest successed~~~~~~~~~~~~~~~~~~" +else +echo "~~~~~~~~~~~~~~~~~~~PAGFullTest Failed~~~~~~~~~~~~~~~~~~" +cp -a $WORKSPACE/test/out/*.json $WORKSPACE/result/ +cp -a $WORKSPACE/test/out/*.png $WORKSPACE/result/ +exit -1 +fi + +cp -a $WORKSPACE/build/test_detail.json $WORKSPACE/result/ diff --git a/codeformat.sh b/codeformat.sh new file mode 100644 index 0000000000..2718bf9288 --- /dev/null +++ b/codeformat.sh @@ -0,0 +1,11 @@ +#!/usr/bin/env bash + +# we run clang-format and astyle twice to get stable format output + +find src/ test/ -type f -name '*.c' -o -name '*.cpp' -o -name '*.cc' -o -name '*.h' xargs -i clang-format -i {} +astyle -n -r "src/*.h,*.cpp,*.cc" +astyle -n -r "test/*.h,*.cpp,*.cc" + +find src/ test/ -type f -name '*.c' -o -name '*.cpp' -o -name '*.cc' -o -name '*.h' xargs -i clang-format -i {} +astyle -n -r "src/*.h,*.cpp,*.cc" +astyle -n -r "test/*.h,*.cpp,*.cc"