test.yml 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. name: test
  2. on:
  3. push:
  4. pull_request:
  5. jobs:
  6. skip:
  7. runs-on: ubuntu-latest
  8. steps:
  9. - run: echo "Skip job"
  10. before:
  11. runs-on: ubuntu-latest
  12. if: "! contains(github.event.head_commit.message, '[skip ci]')"
  13. steps:
  14. - run: echo "not contains '[skip ci]'"
  15. build:
  16. runs-on: ${{ matrix.os }}
  17. strategy:
  18. matrix:
  19. os:
  20. - ubuntu-latest
  21. #- windows-latest
  22. #- macOS-latest
  23. nim_version:
  24. - '1.2.0'
  25. - 'stable'
  26. needs: before
  27. env:
  28. TIMEOUT_EXIT_STATUS: 124
  29. steps:
  30. - uses: actions/checkout@v1
  31. - name: Cache nimble
  32. id: cache-nimble
  33. uses: actions/cache@v1
  34. with:
  35. path: ~/.nimble
  36. key: ${{ runner.os }}-nimble-${{ hashFiles('*.nimble') }}
  37. - uses: jiro4989/setup-nim-action@v1
  38. with:
  39. nim-version: ${{ matrix.nim_version }}
  40. - name: Fix apt packages
  41. run: |
  42. # see. https://github.com/actions/virtual-environments/issues/675
  43. sudo sed -i 's/azure\.//' /etc/apt/sources.list
  44. sudo apt update -yqq
  45. - name: Install xvfb
  46. run: sudo apt install -y xvfb
  47. - name: Install freeglut
  48. run: sudo apt install -y freeglut3 freeglut3-dev
  49. - name: Install sdl2
  50. run: sudo apt install --fix-missing -y libsdl2-dev libsdl2-image-dev libsdl2-mixer-dev
  51. - name: Build examples
  52. run: |
  53. cd examples
  54. for dir in hello_world calculator novel snake screensaver; do
  55. (
  56. cd "$dir"
  57. nim c main.nim
  58. timeout 2 xvfb-run --auto-servernum --server-num=1 ./main || [ $? -eq ${{ env.TIMEOUT_EXIT_STATUS }} ]
  59. )
  60. done
  61. shell: bash
  62. - name: Build tests
  63. run: |
  64. cd tests
  65. for file in $(ls -v test*.nim); do
  66. echo "test: $file"
  67. nim c $file
  68. timeout 2 xvfb-run --auto-servernum --server-num=1 ./${file%%.nim} || [ $? -eq ${{ env.TIMEOUT_EXIT_STATUS }} ]
  69. done
  70. shell: bash