Clarify implicit conversion rules #23
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: "CI tests" | |
| on: [ push, workflow_dispatch ] | |
| jobs: | |
| build-mingw: | |
| name: Tests and application run on Windows Latest MinGW | |
| runs-on: windows-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Create CMake cache | |
| run: | | |
| cmake -S . -B cmake-build-release -DCMAKE_BUILD_TYPE=Release -G "Unix Makefiles" | |
| cmake -S . -B cmake-build-debug -DCMAKE_BUILD_TYPE=Debug -G "Unix Makefiles" | |
| - name: Build main target | |
| shell: bash | |
| run: | | |
| cmake --build cmake-build-release || echo Built with errors | |
| - name: Build tests target | |
| shell: bash | |
| run: | | |
| cmake --build cmake-build-debug --target ovum_tests || echo Built with errors | |
| - name: Run program | |
| working-directory: .\cmake-build-release | |
| run: | | |
| .\ovum.exe --help | |
| - name: Run tests | |
| working-directory: .\cmake-build-debug | |
| run: | | |
| echo "Currently unable to run tests on Windows Latest MinGW. See https://gitmemories.com/cristianadam/HelloWorld/issues/12 and https://github.com/microsoft/vscode-cmake-tools/issues/2451" | |
| % .\ovum_tests.exe | |
| build-matrix: | |
| name: Tests and application run on ${{ matrix.config.name }} | |
| runs-on: ${{ matrix.config.os }} | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| config: | |
| - { | |
| name: "Windows Latest MSVC", artifact: "Windows-MSVC.tar.xz", | |
| os: windows-latest, | |
| build_type: "Release", cc: "cl", cxx: "cl", | |
| environment_script: "C:/Program Files (x86)/Microsoft Visual Studio/2019/Enterprise/VC/Auxiliary/Build/vcvars64.bat" | |
| } | |
| - { | |
| name: "Ubuntu Latest GCC", artifact: "Linux.tar.xz", | |
| os: ubuntu-latest, | |
| build_type: "Release", cc: "gcc", cxx: "g++" | |
| } | |
| - { | |
| name: "macOS Latest Clang", artifact: "macOS.tar.xz", | |
| os: macos-latest, | |
| build_type: "Release", cc: "clang", cxx: "clang++" | |
| } | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Create CMake cache | |
| shell: bash | |
| run: | | |
| cmake -S . -B cmake-build-release -DCMAKE_BUILD_TYPE=Release | |
| cmake -S . -B cmake-build-debug -DCMAKE_BUILD_TYPE=Debug | |
| - name: Build main target | |
| shell: bash | |
| run: | | |
| cmake --build cmake-build-release --target ovum || echo "Built with errors" | |
| - name: Build tests target | |
| shell: bash | |
| run: | | |
| cmake --build cmake-build-debug --target ovum_tests || echo "Built with errors" | |
| - name: Run program | |
| shell: bash | |
| working-directory: ./cmake-build-release | |
| run: | | |
| if [ "$RUNNER_OS" == "Windows" ]; then | |
| ./ovum.exe --help | |
| else | |
| cd bin | |
| ./ovum --help | |
| fi | |
| - name: Run tests | |
| shell: bash | |
| working-directory: ./cmake-build-debug | |
| run: | | |
| if [ "$RUNNER_OS" == "Windows" ]; then | |
| ./ovum_tests.exe | |
| else | |
| cd tests | |
| ./ovum_tests | |
| fi | |
| memory-leaks: | |
| name: Find memory leaks in tests | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Install valgrind | |
| run: | | |
| sudo apt-get update && sudo apt-get -y install valgrind | |
| - name: Create CMake cache | |
| run: | | |
| cmake -S . -B cmake-build -DCMAKE_BUILD_TYPE=Debug | |
| - name: Build tests target | |
| run: | | |
| cmake --build cmake-build --target ovum_tests | |
| - name: Run valgrind | |
| working-directory: ./cmake-build/tests | |
| run: | | |
| valgrind --leak-check=full --track-origins=yes --error-exitcode=1 ./ovum_tests | |
| style-check: | |
| name: Code style check with clang-format | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Install clang-format | |
| run: | | |
| sudo apt-get update && sudo apt-get -y install clang-format | |
| - name: Check code style | |
| run: | | |
| # Find all C++ source files | |
| find . -name "*.cpp" -o -name "*.hpp" -o -name "*.c" -o -name "*.h" | \ | |
| grep -v "./build/" | grep -v "./cmake-build" | grep -v "./_deps/" | \ | |
| xargs clang-format --dry-run --Werror | |
| - name: Comment on style issues | |
| if: failure() | |
| uses: actions/github-script@v7 | |
| with: | |
| script: | | |
| const fs = require('fs'); | |
| const { execSync } = require('child_process'); | |
| try { | |
| // Get list of files that need formatting | |
| const files = execSync('find . -name "*.cpp" -o -name "*.hpp" -o -name "*.c" -o -name "*.h" | grep -v "./build/" | grep -v "./cmake-build" | grep -v "./_deps/"', { encoding: 'utf8' }).trim().split('\n'); | |
| let comment = '## 🎨 Code Style Issues Found\n\n'; | |
| comment += 'The following files have formatting issues:\n\n'; | |
| for (const file of files) { | |
| try { | |
| const result = execSync(`clang-format --dry-run --Werror "${file}" 2>&1`, { encoding: 'utf8' }); | |
| } catch (error) { | |
| comment += `- \`${file}\`: Formatting issues detected\n`; | |
| } | |
| } | |
| comment += '\nPlease run `clang-format -i <file>` to fix formatting issues.'; | |
| github.rest.issues.createComment({ | |
| issue_number: context.issue.number, | |
| owner: context.repo.owner, | |
| repo: context.repo.repo, | |
| body: comment | |
| }); | |
| } catch (error) { | |
| console.log('Could not create comment:', error.message); | |
| } | |
| code-quality-check: | |
| name: Code quality check with clang-tidy | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Install clang-tidy | |
| run: | | |
| sudo apt-get update && sudo apt-get -y install clang-tidy | |
| - name: Create CMake cache | |
| run: | | |
| cmake -S . -B cmake-build-tidy -DCMAKE_BUILD_TYPE=Debug -DCMAKE_EXPORT_COMPILE_COMMANDS=ON | |
| - name: Run clang-tidy | |
| run: | | |
| # Find all C++ source files | |
| find . -name "*.cpp" -o -name "*.hpp" | \ | |
| grep -v "./build/" | grep -v "./cmake-build" | grep -v "./_deps/" | \ | |
| xargs clang-tidy -p cmake-build-tidy --warnings-as-errors=* --format-style=file || true | |
| - name: Count warnings and errors | |
| id: count_issues | |
| run: | | |
| # Run clang-tidy and capture output | |
| find . -name "*.cpp" -o -name "*.hpp" | \ | |
| grep -v "./build/" | grep -v "./cmake-build" | grep -v "./_deps/" | \ | |
| xargs clang-tidy -p cmake-build-tidy --format-style=file > tidy_output.txt 2>&1 || true | |
| # Count errors and warnings | |
| errors=$(grep -c "error:" tidy_output.txt || echo "0") | |
| warnings=$(grep -c "warning:" tidy_output.txt || echo "0") | |
| echo "errors=$errors" >> $GITHUB_OUTPUT | |
| echo "warnings=$warnings" >> $GITHUB_OUTPUT | |
| # Fail if more than 3 warnings or any errors | |
| if [ "$errors" -gt 0 ] || [ "$warnings" -gt 3 ]; then | |
| echo "clang-tidy found $errors errors and $warnings warnings" | |
| exit 1 | |
| fi | |
| - name: Comment on quality issues | |
| if: failure() | |
| uses: actions/github-script@v7 | |
| with: | |
| script: | | |
| const fs = require('fs'); | |
| try { | |
| let comment = '## 🔍 Code Quality Issues Found\n\n'; | |
| if (fs.existsSync('tidy_output.txt')) { | |
| const output = fs.readFileSync('tidy_output.txt', 'utf8'); | |
| const lines = output.split('\n'); | |
| let currentFile = ''; | |
| let hasIssues = false; | |
| for (const line of lines) { | |
| if (line.includes('error:') || line.includes('warning:')) { | |
| const parts = line.split(':'); | |
| if (parts.length >= 4) { | |
| const file = parts[0]; | |
| const lineNum = parts[1]; | |
| const message = parts.slice(3).join(':').trim(); | |
| if (file !== currentFile) { | |
| if (hasIssues) comment += '\n'; | |
| comment += `### \`${file}\`\n\n`; | |
| currentFile = file; | |
| hasIssues = true; | |
| } | |
| const issueType = line.includes('error:') ? '❌ Error' : '⚠️ Warning'; | |
| comment += `- **Line ${lineNum}**: ${issueType} - ${message}\n`; | |
| } | |
| } | |
| } | |
| if (!hasIssues) { | |
| comment += 'No specific issues found in the output.'; | |
| } | |
| } else { | |
| comment += 'Could not read clang-tidy output.'; | |
| } | |
| comment += '\n\nPlease review and fix the issues above.'; | |
| github.rest.issues.createComment({ | |
| issue_number: context.issue.number, | |
| owner: context.repo.owner, | |
| repo: context.repo.repo, | |
| body: comment | |
| }); | |
| } catch (error) { | |
| console.log('Could not create comment:', error.message); | |
| } |