run-tests.yml 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145
  1. name: Tests
  2. on:
  3. push:
  4. paths-ignore:
  5. - "*.md"
  6. branches-ignore:
  7. - master
  8. workflow_call:
  9. # Ensure that multiple runs on the same branch do not overlap.
  10. concurrency:
  11. group: ${{ github.workflow }}-${{ github.ref }}
  12. cancel-in-progress: true
  13. defaults:
  14. run:
  15. shell: bash
  16. jobs:
  17. build-test:
  18. name: Build and test
  19. runs-on: ubuntu-24.04
  20. strategy:
  21. matrix:
  22. nim: ["2.0.x", "2.2.x", "devel"]
  23. steps:
  24. - name: Checkout Code
  25. uses: actions/checkout@v6
  26. - name: Cache Nimble Dependencies
  27. id: cache-nimble
  28. uses: actions/cache@v5
  29. with:
  30. path: ~/.nimble
  31. key: ${{ matrix.nim }}-nimble-v2-${{ hashFiles('*.nimble') }}
  32. restore-keys: |
  33. ${{ matrix.nim }}-nimble-v2-
  34. - name: Setup Nim
  35. uses: jiro4989/setup-nim-action@v2
  36. with:
  37. nim-version: ${{ matrix.nim }}
  38. use-nightlies: true
  39. repo-token: ${{ secrets.GITHUB_TOKEN }}
  40. - name: Build Project
  41. run: nimble build -Y
  42. - name: Upload 2.2.x build artifact
  43. if: matrix.nim == '2.2.x'
  44. uses: actions/upload-artifact@v6
  45. with:
  46. name: nitter-linux-nim-2.2.x-${{ github.sha }}
  47. path: |
  48. ./nitter
  49. if-no-files-found: error
  50. integration-test:
  51. needs: [build-test]
  52. name: Integration test
  53. runs-on: ubuntu-24.04
  54. services:
  55. redis:
  56. image: redis:7
  57. ports:
  58. - 6379:6379
  59. steps:
  60. - name: Install runtime deps
  61. run: |
  62. sudo apt-get install -y --no-install-recommends libsass-dev libpcre3
  63. - name: Checkout code
  64. uses: actions/checkout@v6
  65. - name: Cache pipx (poetry)
  66. uses: actions/cache@v5
  67. with:
  68. path: |
  69. ~/.local/pipx
  70. ~/.local/bin
  71. key: pipx-poetry-${{ runner.os }}
  72. - name: Install poetry
  73. env:
  74. PIPX_HOME: ~/.local/pipx
  75. PIPX_BIN_DIR: ~/.local/bin
  76. run: command -v poetry >/dev/null 2>&1 || pipx install poetry
  77. - name: Setup Python (3.14) with Poetry cache
  78. uses: actions/setup-python@v6
  79. with:
  80. python-version: "3.14"
  81. cache: poetry
  82. cache-dependency-path: tests/poetry.lock
  83. - name: Install Python deps
  84. working-directory: tests
  85. run: poetry sync
  86. - name: Cache Nimble Dependencies
  87. uses: actions/cache@v5
  88. with:
  89. path: ~/.nimble
  90. key: 2.2.x-nimble-v2-${{ hashFiles('*.nimble') }}
  91. restore-keys: |
  92. 2.2.x-nimble-v2-
  93. - name: Setup Nim
  94. uses: jiro4989/setup-nim-action@v2
  95. with:
  96. nim-version: 2.2.x
  97. use-nightlies: true
  98. repo-token: ${{ secrets.GITHUB_TOKEN }}
  99. - name: Download 2.2.x build artifact
  100. uses: actions/download-artifact@v4
  101. with:
  102. name: nitter-linux-nim-2.2.x-${{ github.sha }}
  103. path: .
  104. - name: Make nitter binary executable
  105. run: chmod +x ./nitter
  106. - name: Prepare Nitter Environment
  107. run: |
  108. cp nitter.example.conf nitter.conf
  109. sed -i 's/enableDebug = false/enableDebug = true/g' nitter.conf
  110. sed -i 's/maxRetries = 1/maxRetries = 10/g' nitter.conf
  111. # Run both Nimble tasks concurrently
  112. nim r tools/rendermd.nim &
  113. nim r tools/gencss.nim &
  114. wait
  115. echo '${{ secrets.SESSIONS }}' | head -n1
  116. echo '${{ secrets.SESSIONS }}' > ./sessions.jsonl
  117. - name: Run Tests
  118. run: |
  119. ./nitter &
  120. cd tests
  121. poetry run pytest -n3 --reruns=5 --rs .