diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 0000000..d4ceba1 --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,196 @@ +name: Build and test + +permissions: + contents: write + +on: + pull_request: + push: + paths-ignore: + - '.github/workflows/coverage.yml' + - '.gitignore' + - 'LICENSE' + - 'CHANGELOG.md' + - 'README.md' + +jobs: + build: + strategy: + fail-fast: false + matrix: + confs: + # - { name: Windows, runner: windows-latest, shell: bash, plat: windows, arch: x86, mode: debug, package: true, test: true, } + # - { name: Windows, runner: windows-latest, shell: bash, plat: windows, arch: x86, mode: releasedbg, package: true, test: true, } + - { name: Windows, runner: windows-latest, shell: bash, plat: windows, arch: x64, mode: debug, package: true, test: true, } + - { name: Windows, runner: windows-latest, shell: bash, plat: windows, arch: x64, mode: releasedbg, package: true, test: true, } + # - { name: Windows, runner: windows-latest, shell: bash, plat: windows, arch: arm64, mode: debug, package: true, test: false, } + # - { name: Windows, runner: windows-latest, shell: bash, plat: windows, arch: arm64, mode: releasedbg, package: true, test: false, } + - { name: Linux, runner: ubuntu-latest, shell: bash, plat: linux, arch: x86_64, mode: debug, package: true, test: true, } + - { name: Linux, runner: ubuntu-latest, shell: bash, plat: linux, arch: x86_64, mode: debug, package: false, test: true, config: --asan=y } + - { name: Linux, runner: ubuntu-latest, shell: bash, plat: linux, arch: x86_64, mode: debug, package: false, test: true, config: --lsan=y } + - { name: Linux, runner: ubuntu-latest, shell: bash, plat: linux, arch: x86_64, mode: debug, package: false, test: true, config: --tsan=y } + - { name: Linux, runner: ubuntu-latest, shell: bash, plat: linux, arch: x86_64, mode: releasedbg, package: true, test: true, } + - { name: macOS, runner: macos-latest, shell: bash, plat: macosx, arch: x86_64, mode: debug, package: true, test: true, } + - { name: macOS, runner: macos-latest, shell: bash, plat: macosx, arch: x86_64, mode: releasedbg, package: true, test: true, } + - { name: macOS, runner: macos-14, shell: bash, plat: macosx, arch: arm64, mode: debug, package: true, test: true, } + - { name: macOS, runner: macos-14, shell: bash, plat: macosx, arch: arm64, mode: releasedbg, package: true, test: true, } + # - { name: iOS, runner: macos-latest, shell: bash, plat: iphoneos, arch: arm64, mode: debug, package: true, test: false, } + # - { name: iOS, runner: macos-latest, shell: bash, plat: iphoneos, arch: arm64, mode: releasedbg, package: true, test: false, } + kind: [shared, static] + + defaults: + run: + shell: ${{ matrix.confs.shell }} + + name: ${{ matrix.confs.name }} ${{ matrix.confs.arch }} (${{ matrix.kind }} ${{ matrix.confs.mode }}) + runs-on: ${{ matrix.confs.runner }} + if: ${{ !contains(github.event.head_commit.message, 'ci skip') }} + + steps: + - name: Checkout repository + uses: actions/checkout@v6 + + # Install system dependencies + - name: Setup Linux + if: ${{ matrix.confs.plat == 'linux' }} + run: | + sudo apt-get update + sudo apt-get -y install mesa-common-dev + + # Setup Emsdk + - name: Setup Emscripten + if: ${{ matrix.confs.plat == 'wasm' }} + uses: mymindstorm/setup-emsdk@v14 + with: + version: 4.0.15 + actions-cache-folder: emsdk-cache-${{ matrix.confs.mode }} + + # Setup MSYS2 + - name: Setup MSYS2 + if: ${{ matrix.confs.plat == 'mingw' }} + uses: msys2/setup-msys2@v2 + with: + msystem: ${{ matrix.confs.msystem }} + install: base-devel git unzip p7zip mingw-w64-${{ matrix.confs.arch }}-toolchain mingw-w64-${{ matrix.confs.arch }}-xmake + update: true + + # Setup NDK + - name: Setup Android NDK (${{ matrix.confs.ndk_ver }}) + if: ${{ matrix.confs.plat == 'android' }} + run: | + wget -q https://dl.google.com/android/repository/android-ndk-r${{ matrix.confs.ndk_ver }}-linux.zip + unzip -q -o ./android-ndk-r${{ matrix.confs.ndk_ver }}-linux.zip + echo "ADDITIONAL_CONF=--ndk=`pwd`/android-ndk-r${{ matrix.confs.ndk_ver }} --ndk_sdkver=${{ matrix.confs.ndk_sdkver }}" >> $GITHUB_ENV + + - name: Get current date as package key + id: cache_key + run: echo "key=$(date +'%W')" >> $GITHUB_OUTPUT + shell: bash + + # Force xmake to a specific folder (for cache) + - name: Set xmake global dir + run: echo "XMAKE_GLOBALDIR=${{ runner.workspace }}/xmake-global" >> $GITHUB_ENV + + # Install xmake + - name: Setup xmake + if: ${{ matrix.confs.plat != 'mingw' }} + uses: xmake-io/github-action-setup-xmake@v1 + with: + xmake-version: latest + actions-cache-folder: .xmake-cache-W${{ steps.cache_key.outputs.key }} + + # Update xmake repository (in order to have the file that will be cached) + - name: Update xmake repository + run: xmake repo --update + + # Fetch xmake dephash + - name: Retrieve dependencies hash + id: dep_hash + run: echo "hash=$(xmake l utils.ci.packageskey)" >> $GITHUB_OUTPUT + + # Restore xmake dependencies + - name: Restore cached xmake dependencies + id: restore-depcache + uses: actions/cache/restore@v4 + with: + path: ${{ env.XMAKE_GLOBALDIR }}/.xmake/packages + key: ${{ matrix.confs.plat }}-${{ matrix.confs.arch }}-${{ matrix.confs.mode }}-${{ steps.dep_hash.outputs.hash }}-W${{ steps.cache_key.outputs.key }} + + # Setup platform configs + - name: Setup platform config + run: | + PLATFORM_CONF="" + if [ "${{ matrix.confs.test }}" == "true" ]; then + PLATFORM_CONF="${PLATFORM_CONF} --tests=y" >> $GITHUB_ENV + fi + echo "ADDITIONAL_CONF=${{ env.ADDITIONAL_CONF }} $PLATFORM_CONF" >> $GITHUB_ENV + FILENAME="concerto-reflection_${{ matrix.confs.plat }}_${{ matrix.confs.arch }}_${{ matrix.kind }}" + if [ "${{ startsWith(github.event.ref, 'refs/tags/') }}" == "false" ]; then + FILENAME="${FILENAME}_${{ matrix.confs.mode }}" + fi + if [ "${{ matrix.confs.plat }}" == "windows" ]; then + FILENAME="${FILENAME}.zip" + else + FILENAME="${FILENAME}.tgz" + fi + echo "OUTPUT_FILE=$FILENAME" >> $GITHUB_ENV + + # Setup compilation mode and install project dependencies + - name: Configure xmake and install dependencies + run: xmake config --plat=${{ matrix.confs.plat }} --arch=${{ matrix.confs.arch }} --kind=${{ matrix.kind }} --mode=${{ matrix.confs.mode }} ${{ env.ADDITIONAL_CONF }} --ccache=n --yes + + # Save dependencies + - name: Save cached xmake dependencies + if: ${{ !steps.restore-depcache.outputs.cache-hit }} + uses: actions/cache/save@v4 + with: + path: ${{ env.XMAKE_GLOBALDIR }}/.xmake/packages + key: ${{ steps.restore-depcache.outputs.cache-primary-key }} + + # Build library and tests + - name: Build library + run: xmake + + # Run unit tests + - name: Run unit tests + if: ${{ matrix.confs.test }} + run: xmake run concerto-reflection-tests + + - name: Install + run: xmake install -vo concerto-reflection + + # For some reason macOS-14 doesn't seem to have Python + - uses: actions/setup-python@v6 + if: ${{ matrix.platform.runner == 'macos-14' }} + with: + python-version: "3.11" + + - name: Archive result + uses: ihiroky/archive-action@v1 + with: + root_dir: concerto-reflection + file_path: ${{ env.OUTPUT_FILE }} + verbose: true + + # Nightly tags (for commits to main branch) + - name: Upload binaries to release (Main) + uses: svenstaro/upload-release-action@v2 + if: ${{ (github.ref == 'refs/heads/main') && github.event_name == 'push' && matrix.confs.package }} + with: + repo_token: ${{ secrets.GITHUB_TOKEN }} + file: ${{ env.OUTPUT_FILE }} + asset_name: ${{ env.OUTPUT_FILE }} + tag: "0.0.0-nightly" + overwrite: true + prerelease: true + + # Release tags (for tags) + - name: Upload binaries to release (Tag) + uses: svenstaro/upload-release-action@v2 + if: ${{ startsWith(github.event.ref, 'refs/tags/') && matrix.confs.mode == 'releasedbg' && matrix.confs.package }} + with: + repo_token: ${{ secrets.GITHUB_TOKEN }} + file: ${{ env.OUTPUT_FILE }} + asset_name: ${{ env.OUTPUT_FILE }} + tag: ${{ github.ref }} + overwrite: true \ No newline at end of file diff --git a/.github/workflows/macos.yml b/.github/workflows/macos.yml deleted file mode 100644 index 53f50fb..0000000 --- a/.github/workflows/macos.yml +++ /dev/null @@ -1,71 +0,0 @@ -#from https://github.com/NazaraEngine/NazaraEngine/blob/main/.github/workflows/macos-build.yml -name: macOS build - -on: - pull_request: - push: - paths-ignore: - - '.github/workflows/ubuntu22.yml' - - '.github/workflows/windows.yml' - branches: [ "main" ] - -jobs: - build: - runs-on: ${{ matrix.os }} - strategy: - fail-fast: false - matrix: - os: [macos-14] - arch: [x86_64, arm64] - mode: [debug, release, releasedbg] - kind: [static, shared] - - steps: - - name: Update clang to 18 - run: brew install llvm@18 - - - name: Get current date as package key - id: cache_key - run: echo "key=$(date +'%W')" >> $GITHUB_OUTPUT - - - name: Checkout repository - uses: actions/checkout@v4 - - - name: Set xmake env - run: echo "XMAKE_GLOBALDIR=${{ runner.workspace }}/xmake-global" >> $GITHUB_ENV - - - name: Setup xmake - uses: xmake-io/github-action-setup-xmake@v1 - with: - xmake-version: latest - actions-cache-folder: .xmake-cache-W${{ steps.cache_key.outputs.key }} - - - name: Update xmake repository - run: xmake repo --update - - - name: Retrieve dependencies hash - id: dep_hash - run: echo "hash=$(xmake l utils.ci.packageskey)" >> $GITHUB_OUTPUT - - - name: Restore cached xmake dependencies - id: restore-depcache - uses: actions/cache/restore@v4 - with: - path: ${{ env.XMAKE_GLOBALDIR }}/.xmake/packages - key: macOS-${{ matrix.arch }}-${{ matrix.mode }}-${{ matrix.kind }}-${{ steps.dep_hash.outputs.hash }}-W${{ steps.cache_key.outputs.key }} - - - name: Configure xmake and install dependencies - run: xmake config --arch=${{ matrix.arch }} --mode=${{ matrix.mode }} -k ${{ matrix.kind }} --yes --cc=$(brew --prefix llvm@18)/bin/clang-18 --cxx=$(brew --prefix llvm@18)/bin/clang++ --tests=y - - - name: Save cached xmake dependencies - if: ${{ !steps.restore-depcache.outputs.cache-hit }} - uses: actions/cache/save@v4 - with: - path: ${{ env.XMAKE_GLOBALDIR }}/.xmake/packages - key: ${{ steps.restore-depcache.outputs.cache-primary-key }} - - - name: Build - run: xmake --yes -v - - - name: Run unit tests - run: xmake run concerto-reflection-tests \ No newline at end of file diff --git a/.github/workflows/ubuntu24.yml b/.github/workflows/ubuntu24.yml deleted file mode 100644 index d4093ef..0000000 --- a/.github/workflows/ubuntu24.yml +++ /dev/null @@ -1,74 +0,0 @@ -#from https://github.com/NazaraEngine/NazaraEngine/blob/main/.github/workflows/windows-build.yml -name: Ubuntu build - -on: - push: - paths-ignore: - - '.github/workflows/macos.yml' - - '.github/workflows/windows.yml' - branches: [ "main" ] - pull_request: - - workflow_dispatch: - -jobs: - build: - runs-on: ${{ matrix.os }} - - strategy: - fail-fast: false - matrix: - os: [ubuntu-24.04] - arch: [x86_64, arm64] - mode: [debug, release, releasedbg] - kind: [static, shared] - steps: - - uses: actions/checkout@v4 - - - name: Set gcc/g++ to 13 - run: | - ln -s /usr/bin/g++-13 /usr/local/bin/g++ - ln -s /usr/bin/gcc-13 /usr/local/bin/gcc - - - name: Get current date as package key - id: cache_key - run: echo "key=$(date +'%W')" >> $GITHUB_OUTPUT - - - name: Set xmake env - run: echo "XMAKE_GLOBALDIR=${{ runner.workspace }}/xmake-global" >> $GITHUB_ENV - - - name: Setup xmake - uses: xmake-io/github-action-setup-xmake@v1 - with: - xmake-version: branch@dev - actions-cache-folder: .xmake-cache-W${{ steps.cache_key.outputs.key }} - - - name: Update xmake repo - run: xmake repo --update - - - name: Retrieve dependencies hash - id: dep_hash - run: echo "hash=$(xmake l utils.ci.packageskey)" >> $GITHUB_OUTPUT - - - name: Restore cached xmake dependencies - id: restore-depcache - uses: actions/cache/restore@v4 - with: - path: ${{ env.XMAKE_GLOBALDIR }}/.xmake/packages - key: Linux-${{ matrix.arch }}-${{ matrix.mode }}-${{ matrix.kind }}-${{ steps.dep_hash.outputs.hash }}-W${{ steps.cache_key.outputs.key }} - - - name: Configure xmake and install dependencies - run: xmake config --arch=${{ matrix.arch }} --mode=${{ matrix.mode }} -k ${{ matrix.kind }} --yes --tests=y - - - name: Save cached xmake dependencies - if: ${{ !steps.restore-depcache.outputs.cache-hit }} - uses: actions/cache/save@v4 - with: - path: ${{ env.XMAKE_GLOBALDIR }}/.xmake/packages - key: ${{ steps.restore-depcache.outputs.cache-primary-key }} - - - name: Build - run: xmake --yes -v - - - name: Run unit tests - run: xmake run concerto-reflection-tests \ No newline at end of file diff --git a/.github/workflows/windows.yml b/.github/workflows/windows.yml deleted file mode 100644 index 295f20e..0000000 --- a/.github/workflows/windows.yml +++ /dev/null @@ -1,69 +0,0 @@ -#from https://github.com/NazaraEngine/NazaraEngine/blob/main/.github/workflows/windows-build.yml -name: Windows build - -on: - pull_request: - push: - paths-ignore: - - '.github/workflows/macos.yml' - - '.github/workflows/windows.yml' - branches: [ "main" ] - -jobs: - build: - runs-on: ${{ matrix.os }} - strategy: - fail-fast: false - matrix: - os: [windows-latest] - arch: [x64] - mode: [debug, release, releasedbg] - kind: [static, shared] - - steps: - - name: Get current date as package key - id: cache_key - run: echo "key=$(date +'%W')" >> $GITHUB_OUTPUT - shell: bash - - - name: Checkout repository - uses: actions/checkout@v4 - - - name: Set xmake env - run: echo "XMAKE_GLOBALDIR=${{ runner.workspace }}/xmake-global" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append - - - name: Setup xmake - uses: xmake-io/github-action-setup-xmake@v1 - with: - xmake-version: branch@dev - actions-cache-folder: .xmake-cache-W${{ steps.cache_key.outputs.key }} - - - name: Update xmake repository - run: xmake repo --update - - - name: Retrieve dependencies hash - id: dep_hash - run: echo "hash=$(xmake l utils.ci.packageskey)" | Out-File -FilePath $env:GITHUB_OUTPUT -Encoding utf8 -Append - - - name: Restore cached xmake dependencies - id: restore-depcache - uses: actions/cache/restore@v4 - with: - path: ${{ env.XMAKE_GLOBALDIR }}\.xmake\packages - key: MSVC-${{ matrix.arch }}-${{ matrix.mode }}-${{ matrix.kind }}-${{ steps.dep_hash.outputs.hash }}-W${{ steps.cache_key.outputs.key }} - - - name: Configure xmake and install dependencies - run: xmake config --arch=${{ matrix.arch }} --mode=${{ matrix.mode }} -k ${{ matrix.kind }} --yes --tests=y - - - name: Save cached xmake dependencies - if: ${{ !steps.restore-depcache.outputs.cache-hit }} - uses: actions/cache/save@v4 - with: - path: ${{ env.XMAKE_GLOBALDIR }}/.xmake/packages - key: ${{ steps.restore-depcache.outputs.cache-primary-key }} - - - name: Build - run: xmake --yes -v - - - name: Run unit tests - run: xmake run concerto-reflection-tests \ No newline at end of file