diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..e57ba9e --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,95 @@ +name: CI + +on: + push: + branches: + - master + pull_request: + branches: + - master + workflow_dispatch: + +jobs: + test: + name: Run Tests + runs-on: ubuntu-latest + permissions: + contents: read + checks: write + steps: + - name: Checkout repository + uses: actions/checkout@v4 + with: + lfs: true + + - name: Cache Library + uses: actions/cache@v4 + with: + path: Library + key: Library-${{ hashFiles('Assets/**', 'Packages/**', 'ProjectSettings/**') }} + restore-keys: | + Library- + + - name: Run EditMode tests + uses: game-ci/unity-test-runner@v4 + env: + UNITY_LICENSE: ${{ secrets.UNITY_LICENSE }} + with: + testMode: editmode + githubToken: ${{ secrets.GITHUB_TOKEN }} + + - name: Run PlayMode tests + uses: game-ci/unity-test-runner@v4 + env: + UNITY_LICENSE: ${{ secrets.UNITY_LICENSE }} + with: + testMode: playmode + githubToken: ${{ secrets.GITHUB_TOKEN }} + + - name: Upload test results + uses: actions/upload-artifact@v4 + if: always() + with: + name: Test results + path: artifacts + + build: + name: Build for ${{ matrix.targetPlatform }} + runs-on: ubuntu-latest + needs: test + permissions: + contents: read + strategy: + fail-fast: false + matrix: + targetPlatform: + - StandaloneWindows64 + - StandaloneLinux64 + - StandaloneOSX + steps: + - name: Checkout repository + uses: actions/checkout@v4 + with: + lfs: true + + - name: Cache Library + uses: actions/cache@v4 + with: + path: Library + key: Library-${{ matrix.targetPlatform }}-${{ hashFiles('Assets/**', 'Packages/**', 'ProjectSettings/**') }} + restore-keys: | + Library-${{ matrix.targetPlatform }}- + Library- + + - name: Build project + uses: game-ci/unity-builder@v4 + env: + UNITY_LICENSE: ${{ secrets.UNITY_LICENSE }} + with: + targetPlatform: ${{ matrix.targetPlatform }} + + - name: Upload build artifact + uses: actions/upload-artifact@v4 + with: + name: Build-${{ matrix.targetPlatform }} + path: build/${{ matrix.targetPlatform }}