2020-12-06 09:26:44 -05:00
|
|
|
name: Run tests
|
2020-07-03 16:52:28 -04:00
|
|
|
on: [push]
|
|
|
|
|
2020-12-06 09:26:44 -05:00
|
|
|
env:
|
|
|
|
DOCKER_IMAGE: archivebox-ci
|
2020-12-11 12:45:46 -05:00
|
|
|
PYTHONIOENCODING: utf-8
|
|
|
|
PYTHONLEGACYWINDOWSSTDIO: utf-8
|
|
|
|
USE_COLOR: False
|
2020-12-06 09:26:44 -05:00
|
|
|
|
2020-07-03 16:52:28 -04:00
|
|
|
jobs:
|
2020-12-06 09:26:44 -05:00
|
|
|
python_tests:
|
2020-07-22 19:30:36 -04:00
|
|
|
runs-on: ${{ matrix.os }}
|
|
|
|
|
|
|
|
strategy:
|
|
|
|
matrix:
|
2020-12-11 13:38:51 -05:00
|
|
|
os: [ubuntu-20.04, macos-latest, windows-latest]
|
2020-12-11 11:44:53 -05:00
|
|
|
python: [3.7]
|
2020-07-03 16:52:28 -04:00
|
|
|
|
|
|
|
steps:
|
2020-07-22 19:30:36 -04:00
|
|
|
- uses: actions/checkout@v2
|
2020-07-03 16:52:28 -04:00
|
|
|
with:
|
2020-11-28 05:48:45 -05:00
|
|
|
submodules: true
|
2020-07-03 16:52:28 -04:00
|
|
|
fetch-depth: 1
|
|
|
|
|
2020-08-13 22:23:27 -04:00
|
|
|
### Setup Python & JS Languages
|
2020-07-22 19:30:36 -04:00
|
|
|
- name: Set up Python ${{ matrix.python }}
|
2020-07-03 16:52:28 -04:00
|
|
|
uses: actions/setup-python@v1
|
|
|
|
with:
|
2020-07-22 19:30:36 -04:00
|
|
|
python-version: ${{ matrix.python }}
|
2020-07-03 16:52:28 -04:00
|
|
|
architecture: x64
|
2020-07-22 19:30:36 -04:00
|
|
|
|
2020-08-13 22:23:27 -04:00
|
|
|
- name: Set up Node JS 14.7.0
|
|
|
|
uses: actions/setup-node@v1
|
|
|
|
with:
|
|
|
|
node-version: 14.7.0
|
|
|
|
|
|
|
|
### Install Python & JS Dependencies
|
2020-08-05 14:30:20 -04:00
|
|
|
- name: Get pip cache dir
|
|
|
|
id: pip-cache
|
|
|
|
run: |
|
|
|
|
echo "::set-output name=dir::$(pip cache dir)"
|
|
|
|
|
2020-07-31 12:06:20 -04:00
|
|
|
- name: Cache pip
|
2020-07-28 00:13:10 -04:00
|
|
|
uses: actions/cache@v2
|
2020-07-31 12:06:20 -04:00
|
|
|
id: cache-pip
|
2020-07-22 19:30:36 -04:00
|
|
|
with:
|
2020-08-05 14:30:20 -04:00
|
|
|
path: ${{ steps.pip-cache.outputs.dir }}
|
2020-07-28 00:13:10 -04:00
|
|
|
key: ${{ runner.os }}-${{ matrix.python }}-venv-${{ hashFiles('setup.py') }}
|
2020-07-22 19:30:36 -04:00
|
|
|
restore-keys: |
|
2020-07-28 00:13:10 -04:00
|
|
|
${{ runner.os }}-${{ matrix.python }}-venv-
|
2020-07-22 19:30:36 -04:00
|
|
|
|
2020-08-14 00:35:43 -04:00
|
|
|
- name: Install pip dependencies
|
2020-08-13 22:23:27 -04:00
|
|
|
run: |
|
2020-11-28 04:29:06 -05:00
|
|
|
python -m pip install --upgrade pip setuptools wheel pytest bottle
|
|
|
|
./bin/build_pip.sh
|
|
|
|
python -m pip install .
|
2020-08-13 22:23:27 -04:00
|
|
|
|
|
|
|
- name: Get npm cache dir
|
|
|
|
id: npm-cache
|
|
|
|
run: |
|
|
|
|
echo "::set-output name=dir::$GITHUB_WORKSPACE/node_modules"
|
|
|
|
|
|
|
|
- name: Cache npm
|
|
|
|
uses: actions/cache@v2
|
|
|
|
id: cache-npm
|
2020-08-04 10:01:17 -04:00
|
|
|
with:
|
2020-08-13 22:23:27 -04:00
|
|
|
path: ${{ steps.npm-cache.outputs.dir }}
|
|
|
|
key: ${{ runner.os }}-node_modules-${{ hashFiles('package-lock.json') }}
|
|
|
|
restore-keys: |
|
|
|
|
${{ runner.os }}-node_modules
|
|
|
|
|
|
|
|
- name: Install npm requirements
|
|
|
|
run: |
|
|
|
|
npm install
|
2020-10-23 07:54:37 -04:00
|
|
|
echo "SINGLEFILE_BINARY=$GITHUB_WORKSPACE/node_modules/.bin/single-file" >> $GITHUB_ENV
|
|
|
|
echo "READABILITY_BINARY=$GITHUB_WORKSPACE/node_modules/.bin/readability-extractor" >> $GITHUB_ENV
|
|
|
|
echo "MERCURY_BINARY=$GITHUB_WORKSPACE/node_modules/.bin/mercury-parser" >> $GITHUB_ENV
|
2020-08-04 10:01:17 -04:00
|
|
|
|
2020-08-13 22:23:27 -04:00
|
|
|
### Run the tests
|
|
|
|
- name: Directory listing for debugging
|
2020-07-28 07:31:39 -04:00
|
|
|
run: |
|
2020-08-13 22:23:27 -04:00
|
|
|
pwd
|
2020-12-11 12:10:39 -05:00
|
|
|
ls
|
2020-12-11 12:33:18 -05:00
|
|
|
|
|
|
|
- name: Archivebox version
|
|
|
|
run: |
|
2020-08-14 00:39:02 -04:00
|
|
|
archivebox version
|
2020-07-22 19:30:36 -04:00
|
|
|
|
|
|
|
- name: Test built package with pytest
|
|
|
|
run: |
|
2020-07-28 07:27:42 -04:00
|
|
|
python -m pytest -s
|
2020-12-06 09:26:44 -05:00
|
|
|
|
|
|
|
docker_tests:
|
|
|
|
runs-on: ubuntu-latest
|
|
|
|
|
|
|
|
steps:
|
|
|
|
- uses: actions/checkout@v2
|
|
|
|
with:
|
|
|
|
submodules: true
|
|
|
|
fetch-depth: 1
|
|
|
|
|
|
|
|
# TODO: as of 2020-11 this helper layer broke, upgrade and re-enable this once it's usable again
|
|
|
|
# - uses: satackey/action-docker-layer-caching@v0.0.8
|
|
|
|
|
|
|
|
- name: Build image
|
|
|
|
run: |
|
|
|
|
docker build . -t "$DOCKER_IMAGE"
|
|
|
|
|
|
|
|
- name: Init data dir
|
|
|
|
run: |
|
2020-12-11 13:38:51 -05:00
|
|
|
mkdir "${{ github.workspace }}/data"
|
|
|
|
docker run -v "${{ github.workspace }}/data":/data "$DOCKER_IMAGE" init
|
2020-12-06 09:26:44 -05:00
|
|
|
|
|
|
|
- name: Run test server
|
|
|
|
run: |
|
|
|
|
sudo bash -c 'echo "127.0.0.1 www.test-nginx-1.local www.test-nginx-2.local" >> /etc/hosts'
|
|
|
|
docker run --name www-nginx -p 80:80 -d nginx
|
|
|
|
|
|
|
|
- name: Add link
|
|
|
|
run: |
|
|
|
|
docker run -v "$PWD"/data:/data --network host "$DOCKER_IMAGE" add http://www.test-nginx-1.local
|
|
|
|
|
|
|
|
- name: Add stdin link
|
|
|
|
run: |
|
|
|
|
echo "http://www.test-nginx-2.local" | docker run -i --network host -v "$PWD"/data:/data "$DOCKER_IMAGE" add
|
|
|
|
|
|
|
|
- name: List links
|
|
|
|
run: |
|
|
|
|
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; }
|
|
|
|
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; }
|
|
|
|
|
|
|
|
- name: Start docker-compose stack
|
|
|
|
run: |
|
|
|
|
docker-compose run archivebox init
|
|
|
|
docker-compose up -d
|
|
|
|
sleep 5
|
|
|
|
curl --silent --location 'http://127.0.0.1:8000' | grep 'ArchiveBox'
|
|
|
|
curl --silent --location 'http://127.0.0.1:8000/static/admin/js/jquery.init.js' | grep 'window.django'
|
|
|
|
|
|
|
|
- name: Check added urls show up in index
|
|
|
|
run: |
|
|
|
|
docker-compose run archivebox add 'http://example.com/#test_docker' --index-only
|
|
|
|
curl --silent --location 'http://127.0.0.1:8000' | grep 'http://example.com/#test_docker'
|
|
|
|
docker-compose down || true
|