pull-request-test.yml 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. ################################################################################
  2. ### Pull Request Test
  3. ### Executes tests to ensure that the pull request being submitted is valid.
  4. ### - Runs on pull requests to develop, main, and preview branches
  5. ### - Automatically detects preview branches and tests with appropriate MonoGame version
  6. ### - Only runs if the pull request was opened or synchronized
  7. ################################################################################
  8. name: Pull Request Test
  9. on:
  10. pull_request:
  11. branches:
  12. - develop
  13. - main
  14. - 'v*-preview.*'
  15. types:
  16. - opened
  17. - synchronize
  18. jobs:
  19. test:
  20. runs-on: ubuntu-latest
  21. steps:
  22. - name: Clone Repository
  23. uses: actions/checkout@v4
  24. - name: Setup DotNet
  25. uses: actions/setup-dotnet@v4
  26. with:
  27. dotnet-version: 8.0.x
  28. - name: Setup xvfb
  29. run: |
  30. sudo apt-get update
  31. sudo apt-get install -y xvfb
  32. - name: Detect Build Type
  33. id: detect
  34. run: |
  35. TARGET_BRANCH="${{ github.base_ref }}"
  36. echo "Target branch: $TARGET_BRANCH"
  37. # Check if target branch is a preview branch using simple wildcard matching
  38. if [[ "$TARGET_BRANCH" == v*-preview.* ]]; then
  39. echo "is_preview=true" >> $GITHUB_OUTPUT
  40. echo "Detected preview branch - will use preview MonoGame version"
  41. else
  42. echo "is_preview=false" >> $GITHUB_OUTPUT
  43. echo "Detected stable branch - will use stable MonoGame version"
  44. fi
  45. - name: Test MonoGame.Extended (Stable)
  46. if: steps.detect.outputs.is_preview == 'false'
  47. run: |
  48. xvfb-run -a -s "-screen 0 1024x768x24" dotnet test MonoGame.Extended.sln --nologo --verbosity minimal --configuration Release
  49. - name: Test MonoGame.Extended (Preview)
  50. if: steps.detect.outputs.is_preview == 'true'
  51. run: |
  52. xvfb-run -a -s "-screen 0 1024x768x24" dotnet test MonoGame.Extended.sln --nologo --verbosity minimal --configuration Release -p:IsPreviewBuild=true