Fixed workflow file for Linux (#54) #27
This file contains 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: MacOSX | |
on: | |
push: | |
branches: [ "main" ] | |
paths: | |
- "Core/**" | |
- "Samples/**" | |
- "Scripts/**" | |
pull_request: | |
branches: [ "main" ] | |
paths: | |
- "Core/**" | |
- "Samples/**" | |
- "Scripts/**" | |
workflow_dispatch: | |
jobs: | |
build: | |
runs-on: macos-latest | |
strategy: | |
fail-fast: false | |
matrix: | |
prj: [ BlankApp, HelloTriangle, SpinningCube, ModelLoading ] | |
rhi: [ metal, opengl ] # TODO: Add vulkan | |
steps: | |
- name: Get current date as package key | |
id: cache_key | |
run: echo "key=$(date +'%W')" >> $GITHUB_ENV | |
shell: bash | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
- name: Set xmake env | |
run: echo "XMAKE_GLOBALDIR=${{ github.workspace }}/xmake-global" >> $GITHUB_ENV | |
# Install xmake | |
- name: Setup xmake | |
uses: xmake-io/github-action-setup-xmake@v1 | |
with: | |
xmake-version: latest | |
actions-cache-folder: .xmake-cache-W${{ env.key }} | |
- name: Update xmake repository | |
run: xmake repo --update | |
- name: Restore cached Metal-Cpp | |
id: restore-metal | |
uses: actions/cache/restore@v4 | |
with: | |
path: ${{ github.workspace }}/metal-cpp | |
key: ${{ matrix.rhi }}-${{ matrix.prj }}-W${{ env.key }} | |
- name: Downloading Metal-Cpp | |
if: ${{ !steps.restore-metal.outputs.cache-hit }} | |
run: xmake lua ./Scripts/Macros/macOS.lua | |
- name: Save cached Metal-Cpp | |
if: ${{ !steps.restore-metal.outputs.cache-hit }} | |
uses: actions/cache/save@v4 | |
with: | |
path: ${{ github.workspace }}/metal-cpp | |
key: ${{ steps.restore-metal.outputs.cache-primary-key }} | |
- name: Restore cached xmake dependencies | |
id: restore-depcache | |
uses: actions/cache/restore@v4 | |
with: | |
path: ${{ env.XMAKE_GLOBALDIR }}/.xmake/packages | |
key: ${{ matrix.rhi }}-${{ matrix.prj }}-W${{ env.key }} | |
- name: Check xmake packages directory exists | |
shell: bash | |
run: | | |
if [ -d "${{ env.XMAKE_GLOBALDIR }}/.xmake/packages" ]; then | |
echo "Packages directory exists." | |
ls -la "${{ env.XMAKE_GLOBALDIR }}/.xmake/packages" | |
else | |
echo "Packages directory does not exist." | |
fi | |
- name: Configure xmake and install dependencies | |
run: xmake config --mode=release --ccache=n --rhi=${{ matrix.rhi }} --yes | |
- 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 Visualizer | |
run: xmake build ${{ matrix.prj }} | |
- name: Run tests | |
run: xmake test ${{ matrix.prj }}/* | |