diff --git a/.github/workflows/codeql.yml b/.github/workflows/codeql.yml index 704eda2e7..bc91042b5 100644 --- a/.github/workflows/codeql.yml +++ b/.github/workflows/codeql.yml @@ -1,8 +1,10 @@ name: CodeQL Workflow on: - pull_request: - branches: [main] + workflow_run: + workflows: [ "Test Unity Package Workflow" ] + types: + - completed jobs: analyze: diff --git a/.github/workflows/duplicate_samples.yml b/.github/workflows/duplicate_samples.yml index 4137dbf03..8a081c52c 100644 --- a/.github/workflows/duplicate_samples.yml +++ b/.github/workflows/duplicate_samples.yml @@ -1,4 +1,4 @@ -name: Duplicate Package Samples Workflow +name: Duplicate Packages Samples Workflow on: pull_request: diff --git a/.github/workflows/publish_dependencies.yml b/.github/workflows/publish_dependencies.yml new file mode 100644 index 000000000..1f81d2678 --- /dev/null +++ b/.github/workflows/publish_dependencies.yml @@ -0,0 +1,64 @@ +name: Publish Solution Dependencies + +on: + workflow_run: + workflows: [ "Duplicate Packages Samples Workflow" ] + types: + - completed + +jobs: + publish: + name: Publish Dependency DLLs️ + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v4 + with: + ref: ${{ github.event.pull_request.head.ref }} + lfs: true + - name: update submodules + # clone submodules + run: | + git submodule update --init + shell: bash + - name: Setup .NET + uses: actions/setup-dotnet@v3 + with: + dotnet-version: 6.0.x + - name: Publish Solution DLLs + run: | + dotnet publish src/ChainSafe.Gaming.Unity/ChainSafe.Gaming.Unity.csproj -c Release /property:Unity=true + - name: Move DLLs to Unity Packages then Commit and Push + run: | + + git config user.email $git_email + git config user.name "${{ github.actor }}" + + export PUBLISH_PATH="${GITHUB_WORKSPACE}/${{ vars.PUBLISH_PATH }}" + + echo -e "DLLs Generated\n$(ls "$PUBLISH_PATH")" + + export PACKAGE_DEPENDENCIES=${{ vars.PACKAGE_DEPENDENCIES }} + + for entry in "${PACKAGE_DEPENDENCIES[@]}" + do + IFS=':' read -ra dirs <<< "$entry" + export PACKAGE_LIB_PATH="${GITHUB_WORKSPACE}/${dirs[0]}" + + rm -rf "$PACKAGE_LIB_PATH" + mkdir -p "$PACKAGE_LIB_PATH" + + IFS=';' read -ra dependencies <<< "${dirs[1]}" + + for dependency in "${dependencies[@]}" + do + cp "$PUBLISH_PATH/$dependency.dll" "$PACKAGE_LIB_PATH" + done + + git add "$PACKAGE_LIB_PATH." -f + done + + git diff-index --cached --quiet HEAD || git commit -m "Published Solution Dependencies to Package Libraries as DLLs" + git push + env: + git_email: "${{ github.actor }}@users.noreply.github.com" \ No newline at end of file diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index cac392c61..2b3e496a1 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -1,8 +1,10 @@ name: NUnit Tests Workflow on: - pull_request: - branches: [main] + workflow_run: + workflows: [ "Publish Solution Dependencies" ] + types: + - completed jobs: check: diff --git a/.github/workflows/unity_tests.yml b/.github/workflows/unity_tests.yml index 3526f463f..fb1b6be61 100644 --- a/.github/workflows/unity_tests.yml +++ b/.github/workflows/unity_tests.yml @@ -1,8 +1,10 @@ name: Test Unity Package Workflow on: - pull_request: - branches: [main] + workflow_run: + workflows: [ "NUnit Tests Workflow" ] + types: + - completed jobs: testAllModes: @@ -12,11 +14,7 @@ jobs: fail-fast: false matrix: projectPath: - - Packages/io.chainsafe.web3-unity - publishPath: - - ${GITHUB_WORKSPACE}/src/ChainSafe.Gaming.Unity/bin/Release/netstandard2.1/publish - packageLibraryPath: - - ${GITHUB_WORKSPACE}/Packages/io.chainsafe.web3-unity/Runtime/Libraries + - src/UnitySampleProject testMode: - PlayMode - EditMode @@ -24,46 +22,23 @@ jobs: - uses: actions/checkout@v4 with: lfs: true - - name: update submodules - # clone submodules - run: | - git submodule update --init - shell: bash - - name: Setup .NET - uses: actions/setup-dotnet@v3 + - uses: actions/cache@v2 with: - dotnet-version: 6.0.x - - name: Restore dependencies - run: dotnet restore /property:Unity=true - - name: Publish - run: | - dotnet publish --no-restore src/ChainSafe.Gaming.Unity/ChainSafe.Gaming.Unity.csproj -c Release /property:Unity=true - echo Generated DLLs - ls ${{ matrix.publishPath }} - - name: Publish to Unity Package - run: | - rm -f ${{ matrix.publishPath }}/UnityEngine.dll - rm -f ${{ matrix.publishPath }}/Microsoft.CSharp.dll - mkdir -p ${{ matrix.packageLibraryPath }} - rm -f ${{ matrix.packageLibraryPath }}/* - cp ${{ matrix.publishPath }}/*.dll ${{ matrix.packageLibraryPath }}/ - echo Copied DLLs - ls ${{ matrix.packageLibraryPath }}/ - cp ${GITHUB_WORKSPACE}/Packages/io.chainsafe.web3-unity/TestPackage~/package.json ${GITHUB_WORKSPACE}/Packages/io.chainsafe.web3-unity/package.json - shell: bash + path: ${{ matrix.projectPath }}/Library + key: Library-${{ matrix.projectPath }} + restore-keys: | + Library- - uses: game-ci/unity-test-runner@v3 id: tests env: UNITY_LICENSE: ${{ secrets.UNITY_LICENSE }} with: projectPath: ${{ matrix.projectPath }} - unityVersion: '2021.3.22f1' testMode: ${{ matrix.testMode }} artifactsPath: ${{ matrix.testMode }}-artifacts githubToken: ${{ secrets.GITHUB_TOKEN }} checkName: ${{ matrix.testMode }} Test Results coverageOptions: 'generateAdditionalMetrics;generateHtmlReport;generateBadgeReport;' - packageMode: true - uses: actions/upload-artifact@v3 if: always() with: