test.yml 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  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 choosenim
  32. id: cache-choosenim
  33. uses: actions/cache@v1
  34. with:
  35. path: ~/.choosenim
  36. key: ${{ runner.os }}-choosenim-${{ matrix.nim_version }}
  37. - name: Cache nimble
  38. id: cache-nimble
  39. uses: actions/cache@v1
  40. with:
  41. path: ~/.nimble
  42. key: ${{ runner.os }}-nimble-${{ hashFiles('*.nimble') }}
  43. - uses: jiro4989/setup-nim-action@v1
  44. with:
  45. nim-version: ${{ matrix.nim_version }}
  46. - name: Fix apt packages
  47. run: |
  48. # see. https://github.com/actions/virtual-environments/issues/675
  49. sudo sed -i 's/azure\.//' /etc/apt/sources.list
  50. sudo apt update -yqq
  51. - name: Install xvfb
  52. run: sudo apt install -y xvfb
  53. - name: Install freeglut
  54. run: sudo apt install -y freeglut3 freeglut3-dev
  55. - name: Install sdl2
  56. run: sudo apt install --fix-missing -y libsdl2-dev libsdl2-image-dev libsdl2-mixer-dev
  57. - name: Build examples
  58. run: |
  59. cd examples
  60. for dir in hello_world calculator novel snake screensaver; do
  61. (
  62. cd "$dir"
  63. nim c main.nim
  64. timeout 2 xvfb-run --auto-servernum --server-num=1 ./main || [ $? -eq ${{ env.TIMEOUT_EXIT_STATUS }} ]
  65. )
  66. done
  67. shell: bash
  68. - name: Build tests
  69. run: |
  70. cd tests
  71. for file in $(ls -v test*.nim); do
  72. echo "test: $file"
  73. nim c $file
  74. timeout 2 xvfb-run --auto-servernum --server-num=1 ./${file%%.nim} || [ $? -eq ${{ env.TIMEOUT_EXIT_STATUS }} ]
  75. done
  76. shell: bash