add(forward): adding forward declaration for the error system utilities #15
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 Build | |
| on: | |
| push: | |
| branches: [ main ] | |
| paths: | |
| - 'source/**' | |
| - 'thirdparty/**' | |
| - 'toolchain/**' | |
| - 'cmake/**' | |
| - 'CMakeLists.txt' | |
| pull_request: | |
| branches: [ main ] | |
| paths: | |
| - 'source/**' | |
| - 'thirdparty/**' | |
| - 'toolchain/**' | |
| - 'cmake/**' | |
| - 'CMakeLists.txt' | |
| workflow_call: | |
| inputs: | |
| package-artifacts: | |
| description: 'Whether to package and upload the compiled binaries' | |
| type: boolean | |
| required: false | |
| default: false | |
| target-os: | |
| description: 'Comma-separated list of OS to build (e.g., linux,windows). Leave empty for all.' | |
| type: string | |
| required: false | |
| default: '' | |
| concurrency: | |
| group: ${{ github.workflow }}-${{ github.ref }} | |
| cancel-in-progress: true | |
| permissions: | |
| contents: read | |
| jobs: | |
| setup-matrix: | |
| name: Determine Build Matrix | |
| runs-on: ubuntu-latest | |
| outputs: | |
| matrix: ${{ steps.set-matrix.outputs.matrix }} | |
| should_run: ${{ steps.set-matrix.outputs.should_run }} | |
| steps: | |
| - name: Parse Tags and Inputs | |
| id: set-matrix | |
| uses: actions/github-script@v8 | |
| env: | |
| EVENT_NAME: ${{ github.event_name }} | |
| COMMIT_MESSAGE: ${{ github.event.head_commit.message }} | |
| INPUT_TARGET_OS: ${{ inputs.target-os }} | |
| with: | |
| script: | | |
| const eventName = process.env.EVENT_NAME; | |
| const commitMsg = (process.env.COMMIT_MESSAGE || '').toLowerCase(); | |
| const inputOs = (process.env.INPUT_TARGET_OS || '').toLowerCase(); | |
| const allOs = ['ubuntu-latest', 'windows-latest', 'macos-latest']; | |
| const osMap = { | |
| 'linux': 'ubuntu-latest', | |
| 'ubuntu': 'ubuntu-latest', | |
| 'windows': 'windows-latest', | |
| 'macos': 'macos-latest' | |
| }; | |
| let selectedOs = new Set(allOs); | |
| if (eventName === 'push') { | |
| // Note: GitHub actions natively skips runs with [skip ci], | |
| // but we handle it here just in case native skip is bypassed. | |
| if (commitMsg.includes('[skip ci]')) { | |
| selectedOs.clear(); | |
| } else { | |
| const runMatch = commitMsg.match(/\[run\s+([^\]]+)\]/); | |
| const skipMatch = commitMsg.match(/\[skip\s+([^\]]+)\]/); | |
| if (runMatch) { | |
| selectedOs.clear(); | |
| runMatch[1].split(',').forEach(t => { | |
| const key = t.trim(); | |
| if (osMap[key]) selectedOs.add(osMap[key]); | |
| }); | |
| } else if (skipMatch) { | |
| skipMatch[1].split(',').forEach(t => { | |
| const key = t.trim(); | |
| if (osMap[key]) selectedOs.delete(osMap[key]); | |
| }); | |
| } | |
| } | |
| } else if (eventName === 'workflow_call') { | |
| if (inputOs) { | |
| selectedOs.clear(); | |
| inputOs.split(',').forEach(t => { | |
| const key = t.trim(); | |
| if (osMap[key]) selectedOs.add(osMap[key]); | |
| else if (allOs.includes(key)) selectedOs.add(key); // Fallback if they type exact runner name | |
| }); | |
| } | |
| } | |
| // For 'pull_request', it bypasses the above blocks and defaults to allOs. | |
| const finalOs = Array.from(selectedOs); | |
| core.setOutput('matrix', finalOs); | |
| core.setOutput('should_run', finalOs.length > 0); | |
| build: | |
| name: Build on ${{ matrix.os }} | |
| needs: setup-matrix | |
| if: needs.setup-matrix.outputs.should_run == 'true' | |
| runs-on: ${{ matrix.os }} | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| os: ${{ fromJson(needs.setup-matrix.outputs.matrix) }} | |
| build-type: [Release] | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v5 | |
| with: | |
| fetch-depth: 0 | |
| - name: Set up MSVC Dev Cmd | |
| if: runner.os == 'Windows' | |
| uses: ilammy/msvc-dev-cmd@v1 | |
| - name: Setup Dependencies | |
| uses: ./.github/actions/setup-deps | |
| with: | |
| os: ${{ matrix.os }} | |
| build-dir: build | |
| - name: Setup Ccache | |
| uses: hendrikmuhs/ccache-action@v1.2.23 | |
| with: | |
| key: ${{ matrix.os }}-${{ matrix.build-type }} | |
| - name: Cache CMake FetchContent | |
| uses: actions/cache@v5 | |
| with: | |
| path: ~/.cache/cmake_deps | |
| key: ${{ runner.os }}-cmake-deps-${{ hashFiles('**/CMakeLists.txt', '**/*.cmake') }} | |
| restore-keys: | | |
| ${{ runner.os }}-cmake-deps- | |
| - name: Configure CMake | |
| shell: bash | |
| run: | | |
| cmake -S . -B build \ | |
| -G Ninja \ | |
| -DCMAKE_BUILD_TYPE=${{ matrix.build-type }} \ | |
| -DCMAKE_C_COMPILER_LAUNCHER=ccache \ | |
| -DCMAKE_CXX_COMPILER_LAUNCHER=ccache \ | |
| -DFETCHCONTENT_BASE_DIR="$HOME/.cache/cmake_deps" | |
| - name: Build | |
| run: cmake --build build --config ${{ matrix.build-type }} --parallel --verbose | |
| - name: Install Release Artifacts | |
| if: inputs.package-artifacts | |
| run: cmake --install build --config ${{ matrix.build-type }} --prefix install_staging | |
| - name: Determine Version | |
| if: inputs.package-artifacts | |
| id: get_version | |
| shell: bash | |
| run: | | |
| if [[ "${{ github.ref_type }}" == "tag" ]]; then | |
| # If the workflow was triggered by a tag (e.g., v1.0.0), use it | |
| GP_VERSION="${{ github.ref_name }}" | |
| else | |
| # Otherwise, read the first line of the VERSION file and strip whitespaces/newlines | |
| GP_VERSION=$(head -n 1 VERSION | tr -d '\r\n ') | |
| fi | |
| # Save it to GITHUB_ENV so subsequent steps can access it | |
| echo "VERSION=$GP_VERSION" >> $GITHUB_ENV | |
| echo "Resolved version: $GP_VERSION" | |
| - name: Package Artifacts (Unix) | |
| if: ${{ inputs.package-artifacts && (matrix.os == 'ubuntu-latest' || matrix.os == 'macos-latest') }} | |
| run: tar -czvf gp-engine-${{ matrix.os }}-${{ env.VERSION }}.tar.gz -C install_staging . | |
| - name: Package Artifacts (Windows) | |
| if: ${{ inputs.package-artifacts && matrix.os == 'windows-latest' }} | |
| run: powershell Compress-Archive -Path install_staging\* -DestinationPath gp-engine-${{ matrix.os }}-${{ env.VERSION }}.zip | |
| - name: Upload Artifacts | |
| if: ${{ inputs.package-artifacts }} | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: release-${{ matrix.os }} | |
| path: gp-engine-${{ matrix.os }}-${{ env.VERSION }}.* | |
| if-no-files-found: error | |
| retention-days: 14 |