Add a small test project to run codechecker_bazel on #12
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: codechecker-bazel-tests | |
| # Triggers the workflow on push or pull request events. | |
| on: [push, pull_request] | |
| permissions: read-all | |
| concurrency: | |
| group: ${{ github.workflow }}-${{ github.ref }} | |
| cancel-in-progress: true | |
| jobs: | |
| rules_test: | |
| name: Unit tests | |
| runs-on: ubuntu-24.04 | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| - name: Setup environment | |
| uses: ./.github/actions/env_setup | |
| - name: Print versions | |
| run: | | |
| bazel version | |
| CodeChecker version | |
| echo "[NOTE]: If you are debugging, its possible that " \ | |
| "CodeChecker finds different analyzers when running in " \ | |
| "bazel's sandbox environment!" | |
| CodeChecker analyzers | |
| - name: Run tests | |
| run: | | |
| cd test | |
| python3 test.py -vvv | |
| # Prepares matrix used to generate jobs in project_test_runner | |
| # This job assumes that every project patch file is in the .github/workflows/patches directory | |
| # and the name of these scripts follows this rule: patch-project_name.sh | |
| # patches must clone their repository into folder: test-proj | |
| prepare_project_matrix: | |
| runs-on: ubuntu-24.04 | |
| name: Collecting Projects | |
| outputs: | |
| project_configurations: ${{ steps.generate_matrix.outputs.matrix_json }} | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| - name: Generate dynamic project matrix | |
| id: generate_matrix | |
| run: | | |
| PATCH_DIR="./test/foss/" | |
| TEMP_JSON_FILE=$(mktemp) | |
| find "$PATCH_DIR" -maxdepth 1 -mindepth 1 -type d ! -name "templates" -print0 | while IFS= read -r -d $'\0' PROJECT_FOLDER; do | |
| # Extract project name from folder name | |
| PROJECT_NAME=$(basename "$PROJECT_FOLDER") | |
| jq -n -c \ | |
| --arg name "$PROJECT_NAME" \ | |
| --arg folder "$PROJECT_FOLDER" \ | |
| '{ name: $name, folder: $folder }' >> "$TEMP_JSON_FILE" | |
| echo "Added $PROJECT_NAME to matrix." | |
| done | |
| if [ -s "$TEMP_JSON_FILE" ]; then | |
| FINAL_MATRIX_JSON="[$(paste -s -d ',' "$TEMP_JSON_FILE")]" | |
| else | |
| FINAL_MATRIX_JSON="[]" | |
| fi | |
| echo "Generated matrix: $FINAL_MATRIX_JSON" | |
| echo "matrix_json=$FINAL_MATRIX_JSON" >> "$GITHUB_OUTPUT" | |
| shell: bash | |
| project_test_runner: | |
| # Test the bazel rules introduced by repository on an independent open-source projects. | |
| runs-on: ubuntu-24.04 | |
| needs: prepare_project_matrix | |
| strategy: | |
| fail-fast: false | |
| max-parallel: 2 # limit number of concurrent jobs | |
| matrix: | |
| project: ${{ fromJson(needs.prepare_project_matrix.outputs.project_configurations) }} | |
| name: "Test On Project: ${{ matrix.project.name }}" | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| - name: Setup environment | |
| uses: ./.github/actions/env_setup | |
| - name: Initializing test | |
| run: | | |
| cd ${{ matrix.project.folder }} | |
| sh ./init.sh | |
| # Running bazel with test will signal failure because CodeChecker found problems | |
| - name: Run Monolithic Bazel CodeChecker | |
| run: | | |
| cd ${{ matrix.project.folder }}/test-proj | |
| bazel test :codechecker_test || [ $? -eq 3 ] && exit 0 || exit $? | |
| # Running bazel with test will signal failure because CodeChecker found problems | |
| - name: Run Per File Bazel CodeChecker | |
| run: | | |
| cd ${{ matrix.project.folder }}/test-proj | |
| bazel test :code_checker_test || [ $? -eq 3 ] && exit 0 || exit $? |