test.yml 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158
  1. name: Run tests
  2. on: [push]
  3. env:
  4. DOCKER_IMAGE: archivebox-ci
  5. PYTHONIOENCODING: utf-8
  6. PYTHONLEGACYWINDOWSSTDIO: utf-8
  7. USE_COLOR: False
  8. jobs:
  9. python_tests:
  10. runs-on: ${{ matrix.os }}
  11. strategy:
  12. matrix:
  13. os: [ubuntu-22.04]
  14. # os: [ubuntu-22.04, macos-latest, windows-latest]
  15. python: [3.11]
  16. steps:
  17. - uses: actions/checkout@v4
  18. with:
  19. submodules: true
  20. fetch-depth: 1
  21. ### Setup Python & JS Languages
  22. - name: Set up Python ${{ matrix.python }}
  23. uses: actions/setup-python@v4
  24. with:
  25. python-version: ${{ matrix.python }}
  26. architecture: x64
  27. - name: Set up Node JS
  28. uses: actions/setup-node@v4
  29. with:
  30. node-version: 20.10.0
  31. - name: Setup PDM
  32. uses: pdm-project/setup-pdm@v3
  33. with:
  34. python-version: '3.11'
  35. cache: true
  36. ### Install Python & JS Dependencies
  37. - name: Get pip cache dir
  38. id: pip-cache
  39. run: |
  40. echo "::set-output name=dir::$(pip cache dir)"
  41. - name: Cache pip
  42. uses: actions/cache@v3
  43. id: cache-pip
  44. with:
  45. path: ${{ steps.pip-cache.outputs.dir }}
  46. key: ${{ runner.os }}-${{ matrix.python }}-venv-${{ hashFiles('setup.py') }}
  47. restore-keys: |
  48. ${{ runner.os }}-${{ matrix.python }}-venv-
  49. - uses: awalsh128/cache-apt-pkgs-action@latest
  50. with:
  51. packages: ripgrep build-essential python3-dev python3-setuptools libssl-dev libldap2-dev libsasl2-dev zlib1g-dev libatomic1 python3-minimal gnupg2 curl wget python3-ldap python3-msgpack python3-mutagen python3-regex python3-pycryptodome procps
  52. version: 1.0
  53. - name: Install pip dependencies
  54. run: |
  55. python -m pip install --upgrade pip setuptools wheel pytest bottle build
  56. python -m pip install -r requirements.txt
  57. python -m pip install -e .[sonic,ldap]
  58. - name: Get npm cache dir
  59. id: npm-cache
  60. run: |
  61. echo "::set-output name=dir::$GITHUB_WORKSPACE/node_modules"
  62. - name: Cache npm
  63. uses: actions/cache@v3
  64. id: cache-npm
  65. with:
  66. path: ${{ steps.npm-cache.outputs.dir }}
  67. key: ${{ runner.os }}-node_modules-${{ hashFiles('package-lock.json') }}
  68. restore-keys: |
  69. ${{ runner.os }}-node_modules
  70. - name: Install npm requirements
  71. run: |
  72. npm install
  73. echo "SINGLEFILE_BINARY=$GITHUB_WORKSPACE/node_modules/.bin/single-file" >> $GITHUB_ENV
  74. echo "READABILITY_BINARY=$GITHUB_WORKSPACE/node_modules/.bin/readability-extractor" >> $GITHUB_ENV
  75. echo "MERCURY_BINARY=$GITHUB_WORKSPACE/node_modules/.bin/mercury-parser" >> $GITHUB_ENV
  76. ### Run the tests
  77. - name: Directory listing for debugging
  78. run: |
  79. pwd
  80. ls
  81. - name: Archivebox version
  82. run: |
  83. archivebox version
  84. - name: Test built package with pytest
  85. # TODO: remove this exception for windows once we get tests passing on that platform
  86. if: ${{ !contains(matrix.os, 'windows') }}
  87. run: |
  88. python -m pytest -s --basetemp=tests/out --ignore=archivebox/vendor --ignore=deb_dist --ignore=pip_dist --ignore=brew_dist
  89. docker_tests:
  90. runs-on: ubuntu-latest
  91. steps:
  92. - uses: actions/checkout@v4
  93. with:
  94. submodules: true
  95. fetch-depth: 1
  96. # TODO: as of 2020-11 this helper layer broke, upgrade and re-enable this once it's usable again
  97. # - uses: satackey/[email protected]
  98. - name: Build image
  99. run: |
  100. docker build . -t "$DOCKER_IMAGE"
  101. - name: Init data dir
  102. run: |
  103. mkdir "${{ github.workspace }}/data"
  104. docker run -v "${{ github.workspace }}/data":/data "$DOCKER_IMAGE" init
  105. - name: Run test server
  106. run: |
  107. sudo bash -c 'echo "127.0.0.1 www.test-nginx-1.local www.test-nginx-2.local" >> /etc/hosts'
  108. docker run --name www-nginx -p 80:80 -d nginx
  109. - name: Add link
  110. run: |
  111. docker run -v "$PWD"/data:/data --network host "$DOCKER_IMAGE" add http://www.test-nginx-1.local
  112. - name: Add stdin link
  113. run: |
  114. echo "http://www.test-nginx-2.local" | docker run -i --network host -v "$PWD"/data:/data "$DOCKER_IMAGE" add
  115. - name: List links
  116. run: |
  117. docker run -v "$PWD"/data:/data "$DOCKER_IMAGE" list | grep -q "www.test-nginx-1.local" || { echo "The site 1 isn't in the list"; exit 1; }
  118. docker run -v "$PWD"/data:/data "$DOCKER_IMAGE" list | grep -q "www.test-nginx-2.local" || { echo "The site 2 isn't in the list"; exit 1; }
  119. - name: Start docker-compose stack
  120. run: |
  121. docker-compose run archivebox init
  122. docker-compose up -d
  123. sleep 5
  124. curl --silent --location 'http://127.0.0.1:8000' | grep 'ArchiveBox'
  125. curl --silent --location 'http://127.0.0.1:8000/static/admin/js/jquery.init.js' | grep 'window.django'
  126. - name: Check added urls show up in index
  127. run: |
  128. docker-compose run archivebox add 'http://example.com/#test_docker' --index-only
  129. curl --silent --location 'http://127.0.0.1:8000' | grep 'http://example.com/#test_docker'
  130. docker-compose down || true