run-tests.yml 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152
  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: |
  31. ~/.nimble/pkgcache
  32. ~/.nimble/packages_official.json
  33. key: ${{ matrix.nim }}-nimble-v6-${{ hashFiles('*.nimble') }}
  34. restore-keys: |
  35. ${{ matrix.nim }}-nimble-v6-
  36. - name: Setup Nim
  37. uses: jiro4989/setup-nim-action@v2
  38. with:
  39. nim-version: ${{ matrix.nim }}
  40. use-nightlies: true
  41. repo-token: ${{ secrets.GITHUB_TOKEN }}
  42. - name: Build Project
  43. run: nimble build -Y
  44. - name: Upload 2.2.x build artifact
  45. if: matrix.nim == '2.2.x'
  46. uses: actions/upload-artifact@v6
  47. with:
  48. name: nitter-linux-nim-2.2.x-${{ github.sha }}
  49. path: |
  50. ./nitter
  51. if-no-files-found: error
  52. integration-test:
  53. needs: [build-test]
  54. name: Integration test
  55. runs-on: ubuntu-24.04
  56. timeout-minutes: 30
  57. services:
  58. redis:
  59. image: redis:7
  60. ports:
  61. - 6379:6379
  62. steps:
  63. - name: Install runtime deps
  64. run: |
  65. sudo apt-get install -y --no-install-recommends libsass-dev libpcre3
  66. - name: Checkout code
  67. uses: actions/checkout@v6
  68. - name: Cache pipx (poetry)
  69. uses: actions/cache@v5
  70. with:
  71. path: |
  72. ~/.local/pipx
  73. ~/.local/bin
  74. key: pipx-poetry-${{ runner.os }}
  75. - name: Install poetry
  76. env:
  77. PIPX_HOME: ~/.local/pipx
  78. PIPX_BIN_DIR: ~/.local/bin
  79. run: command -v poetry >/dev/null 2>&1 || pipx install poetry
  80. - name: Setup Python (3.14) with Poetry cache
  81. uses: actions/setup-python@v6
  82. with:
  83. python-version: "3.14"
  84. cache: poetry
  85. cache-dependency-path: tests/poetry.lock
  86. - name: Install Python deps
  87. working-directory: tests
  88. run: poetry sync
  89. - name: Cache Nimble Dependencies
  90. uses: actions/cache@v5
  91. with:
  92. path: |
  93. ~/.nimble/pkgcache
  94. ~/.nimble/packages_official.json
  95. key: 2.2.x-nimble-v6-${{ hashFiles('*.nimble') }}
  96. restore-keys: |
  97. 2.2.x-nimble-v6-
  98. - name: Setup Nim
  99. uses: jiro4989/setup-nim-action@v2
  100. with:
  101. nim-version: 2.2.x
  102. use-nightlies: true
  103. repo-token: ${{ secrets.GITHUB_TOKEN }}
  104. - name: Install Nimble dependencies
  105. run: nimble install -y --depsOnly
  106. - name: Download 2.2.x build artifact
  107. uses: actions/download-artifact@v4
  108. with:
  109. name: nitter-linux-nim-2.2.x-${{ github.sha }}
  110. path: .
  111. - name: Make nitter binary executable
  112. run: chmod +x ./nitter
  113. - name: Prepare Nitter Environment
  114. run: |
  115. cp nitter.example.conf nitter.conf
  116. sed -i 's/enableDebug = false/enableDebug = true/g' nitter.conf
  117. sed -i 's/maxRetries = 1/maxRetries = 10/g' nitter.conf
  118. sed -i 's/hostname = "nitter.net"/hostname = "localhost:8080"/g' nitter.conf
  119. nim r tools/rendermd.nim
  120. nim r tools/gencss.nim
  121. echo '${{ secrets.SESSIONS }}' | head -n1
  122. echo '${{ secrets.SESSIONS }}' > ./sessions.jsonl
  123. - name: Run Tests
  124. run: |
  125. ./nitter &
  126. cd tests
  127. poetry run pytest -n3 --rs .