name: 'Action test' on: pull_request: paths-ignore: - '**.md' push: branches: - master - 'releases/*' paths-ignore: - '**.md' jobs: fetch-tests: strategy: fail-fast: false matrix: include: - os: ubuntu-18.04 install-custom: true version: v6.16.0 llvm-version: '12' - os: ubuntu-20.04 install-custom: false version: 6.17.0 llvm-version: '13' - os: ubuntu-20.04 install-custom: true version: master llvm-version: 'latest' - os: ubuntu-20.04 install-custom: false version: master llvm-version: 'latest' name: "Fetch: ${{ matrix.os }}, LLVM ${{ matrix.llvm-version }}, ${{ matrix.install-custom && 'repository' || 'pip' }} ${{ matrix.version }}" runs-on: ${{ matrix.os }} steps: - uses: actions/checkout@v2 - uses: ./ id: codechecker with: install-custom: ${{ matrix.install-custom }} version: ${{ matrix.version }} llvm-version: ${{ matrix.llvm-version }} logfile: "test/empty/compile_commands.json" simple-analysis-tests: strategy: fail-fast: false matrix: logfile: ['', 'test/simple/compile_commands.json'] build-command: ['', 'cd test/simple; g++ -c main.cpp -o main.o'] analyze-output: ['', 'my-output-dir'] name: "Simple analysis: ${{ matrix.logfile && 'logfile' || 'no logfile' }}, ${{ matrix.build-command && 'build-command' || 'no build-command' }}, ${{ matrix.analyze-output && 'analyze-output' || 'no analyze-output'}}" runs-on: ubuntu-20.04 steps: - uses: actions/checkout@v2 - run: test/fix_compile_json_paths.sh - uses: ./ id: codechecker # Allow continuing the build, we check "expected failure" for misconfiguration. continue-on-error: ${{ (matrix.logfile != '') == (matrix.build-command != '') }} with: logfile: ${{ matrix.logfile }} build-command: ${{ matrix.build-command }} analyze-output: ${{ matrix.analyze-output }} - name: "Check and reject job if previous test should have failed, but did not" if: ${{ steps.codechecker.continue-on-error && steps.codechecker.outcome != 'failure' }} run: | echo "::error title=Step with expected failure passed::" exit 1 analyze-cfg: name: "Analyze: Custom configuration" runs-on: ubuntu-20.04 steps: - uses: actions/checkout@v2 - run: test/fix_compile_json_paths.sh - uses: ./ with: config: 'test/codechecker.verbose.json' logfile: 'test/simple/compile_commands.json' analyze-ctu: name: "Analyze: CTU shortcut" runs-on: ubuntu-20.04 steps: - uses: actions/checkout@v2 - run: test/fix_compile_json_paths.sh - uses: ./ id: codechecker with: logfile: 'test/ctu/compile_commands.json' ctu: true - name: "Reject test if previous step did not produce CTU finding" run: cat ${{ steps.codechecker.outputs.result-log }} | grep "Dereference of null pointer" reports-errors: name: "Parse: Findings are reported" runs-on: ubuntu-20.04 steps: - uses: actions/checkout@v2 - run: test/fix_compile_json_paths.sh - uses: ./ id: codechecker continue-on-error: true with: logfile: 'test/simple/compile_commands.json' # FIXME: 6.18 release on PyPI is broken when it comes to the "parse" # command. See Ericsson/CodeChecker#3515. install-custom: true version: "v6.18.0" - name: "Reject test if output isn't as expected" if: ${{ steps.codechecker.outputs.warnings != 'true' }} run: | echo "::error title=fail-on-error test passed::Expected the 'parse' step to report findings." exit 1 parse-html: name: "Parse: Generate and upload report HTML artefact" runs-on: ubuntu-20.04 steps: - uses: actions/checkout@v2 - run: test/fix_compile_json_paths.sh - uses: ./ id: codechecker with: logfile: 'test/simple/compile_commands.json' # FIXME: 6.18 release on PyPI is broken when it comes to the "parse" # command. See Ericsson/CodeChecker#3515. install-custom: true version: "v6.18.0" - uses: actions/upload-artifact@v2 with: name: "Parse HTML test results" path: ${{ steps.codechecker.outputs.result-html-dir }} if-no-files-found: error store: name: "Store: Authenticated local store of single result" runs-on: ubuntu-20.04 env: CODECHECKER_VERSION: '6.18.0' steps: - uses: actions/checkout@v2 # Need to do this manually because the server for this test has to have # authentication on, with a known username and password. - name: "Set up CodeChecker server" run: | set -x sudo apt-get -y update sudo apt-get -y install --no-install-recommends \ netcat \ wget mkdir -pv ~/codechecker-server-data chmod 1777 ~/codechecker-server-data cp test/codechecker.server.json ~/codechecker-server-data/server_config.json test/prepare-docker-server.sh echo "::group::CodeChecker server configuration" cd ~/codechecker-server-data chown 950:950 server_config.json && chmod 0600 server_config.json chown 950:950 root.user && chmod 0600 root.user ls -alh cat docker-compose.yml cat root.user cat server_config.json echo "::endgroup::" docker-compose up -d wget -qO- http://raw.githubusercontent.com/eficode/wait-for/v2.1.3/wait-for | sh -s -- --timeout=30 http://0.0.0.0:8001/ -- echo "CodeChecker up" docker ps -a echo "::group::CodeChecker server initial log output" docker logs codechecker-server echo "::endgroup::" - run: test/fix_compile_json_paths.sh - uses: ./ id: codechecker continue-on-error: true with: version: "${{ env.CODECHECKER_VERSION }}" logfile: 'test/simple/compile_commands.json' store: true store-url: 'http://0.0.0.0:8001/Default' store-username: 'root' store-password: 'root' - name: "Test if server logged store action" id: test continue-on-error: true run: docker logs codechecker-server | grep "stored results" - name: "Tear down CodeChecker server" run: | set -x echo "::group::CodeChecker server log output" docker logs codechecker-server echo "::endgroup::" cd ~/codechecker-server-data docker-compose down docker ps -a - name: "Fail the build if the test execution failed" if: ${{ steps.test.outcome == 'failure' || steps.codechecker.outcome == 'failure' || steps.codechecker.outputs.store-successful != 'true' }} run: exit 1