2020-07-03 20:52:28 +00:00
|
|
|
name: Test workflow
|
|
|
|
on: [push]
|
|
|
|
|
2020-07-22 23:30:36 +00:00
|
|
|
env:
|
|
|
|
MAX_LINE_LENGTH: 110
|
2020-07-28 04:14:34 +00:00
|
|
|
|
2020-07-03 20:52:28 +00:00
|
|
|
jobs:
|
2020-07-22 23:30:36 +00:00
|
|
|
lint:
|
2020-07-03 20:52:28 +00:00
|
|
|
runs-on: ubuntu-latest
|
2020-07-22 23:30:36 +00:00
|
|
|
steps:
|
|
|
|
- uses: actions/checkout@v2
|
|
|
|
|
|
|
|
- name: Set up Python
|
|
|
|
uses: actions/setup-python@v1
|
|
|
|
with:
|
|
|
|
python-version: 3.8
|
|
|
|
architecture: x64
|
2020-07-24 19:37:29 +00:00
|
|
|
|
2020-07-28 04:14:34 +00:00
|
|
|
- name: Install flake8
|
2020-07-22 23:30:36 +00:00
|
|
|
run: |
|
2020-07-28 04:13:10 +00:00
|
|
|
pip install flake8
|
2020-07-28 04:14:34 +00:00
|
|
|
|
|
|
|
- name: Lint with flake8
|
|
|
|
run: |
|
2020-07-22 23:30:36 +00:00
|
|
|
# one pass for show-stopper syntax errors or undefined names
|
2020-07-28 04:13:10 +00:00
|
|
|
flake8 archivebox --count --show-source --statistics
|
2020-07-22 23:30:36 +00:00
|
|
|
# one pass for small stylistic things
|
2020-07-28 04:13:10 +00:00
|
|
|
flake8 archivebox --count --max-line-length="$MAX_LINE_LENGTH" --statistics
|
2020-07-22 23:30:36 +00:00
|
|
|
|
2020-07-28 04:13:10 +00:00
|
|
|
# - name: Lint with mypy
|
|
|
|
# run: |
|
|
|
|
# pip install mypy
|
|
|
|
# mypy archivebox || true
|
2020-07-22 23:30:36 +00:00
|
|
|
|
|
|
|
test:
|
|
|
|
runs-on: ${{ matrix.os }}
|
|
|
|
|
|
|
|
strategy:
|
|
|
|
matrix:
|
|
|
|
os: [ubuntu-latest, macos-latest]
|
|
|
|
python: [3.7, 3.8]
|
2020-07-03 20:52:28 +00:00
|
|
|
|
|
|
|
steps:
|
2020-07-22 23:30:36 +00:00
|
|
|
- uses: actions/checkout@v2
|
2020-07-03 20:52:28 +00:00
|
|
|
with:
|
|
|
|
fetch-depth: 1
|
|
|
|
|
2020-07-22 23:30:36 +00:00
|
|
|
- name: Set up Python ${{ matrix.python }}
|
2020-07-03 20:52:28 +00:00
|
|
|
uses: actions/setup-python@v1
|
|
|
|
with:
|
2020-07-22 23:30:36 +00:00
|
|
|
python-version: ${{ matrix.python }}
|
2020-07-03 20:52:28 +00:00
|
|
|
architecture: x64
|
2020-07-22 23:30:36 +00:00
|
|
|
|
2020-07-28 04:13:10 +00:00
|
|
|
- name: Cache virtualenv
|
|
|
|
uses: actions/cache@v2
|
2020-07-28 11:33:48 +00:00
|
|
|
id: cache-venv
|
2020-07-22 23:30:36 +00:00
|
|
|
with:
|
2020-07-28 04:13:10 +00:00
|
|
|
path: .venv
|
|
|
|
key: ${{ runner.os }}-${{ matrix.python }}-venv-${{ hashFiles('setup.py') }}
|
2020-07-22 23:30:36 +00:00
|
|
|
restore-keys: |
|
2020-07-28 04:13:10 +00:00
|
|
|
${{ runner.os }}-${{ matrix.python }}-venv-
|
2020-07-22 23:30:36 +00:00
|
|
|
|
2020-07-28 11:31:11 +00:00
|
|
|
- name: Create virtualenv
|
2020-07-28 11:32:23 +00:00
|
|
|
if: steps.cache-venv.outputs.cache-hit != 'true'
|
2020-07-03 20:52:28 +00:00
|
|
|
run: |
|
2020-07-28 04:14:34 +00:00
|
|
|
python3 -m venv .venv
|
2020-07-28 11:36:40 +00:00
|
|
|
source .venv/bin/activate
|
|
|
|
python3 -m pip install --upgrade pip setuptools
|
2020-07-28 11:31:11 +00:00
|
|
|
|
|
|
|
- name: Install dependencies
|
2020-07-28 11:31:39 +00:00
|
|
|
run: |
|
2020-07-28 11:27:42 +00:00
|
|
|
source .venv/bin/activate
|
|
|
|
python -m pip install .
|
|
|
|
python -m pip install pytest bottle
|
2020-07-22 23:30:36 +00:00
|
|
|
|
|
|
|
- name: Test built package with pytest
|
|
|
|
run: |
|
2020-07-28 11:30:00 +00:00
|
|
|
source .venv/bin/activate
|
2020-07-28 11:27:42 +00:00
|
|
|
python -m pytest -s
|
2020-07-24 19:37:29 +00:00
|
|
|
|
2020-07-22 23:30:36 +00:00
|
|
|
docker-test:
|
|
|
|
runs-on: ubuntu-latest
|
2020-07-03 20:52:28 +00:00
|
|
|
|
2020-07-22 23:30:36 +00:00
|
|
|
steps:
|
|
|
|
- uses: actions/checkout@v2
|
|
|
|
with:
|
|
|
|
fetch-depth: 1
|
2020-07-24 19:37:29 +00:00
|
|
|
|
2020-07-28 04:13:10 +00:00
|
|
|
- uses: satackey/action-docker-layer-caching@v0.0.4
|
|
|
|
|
2020-07-22 23:30:36 +00:00
|
|
|
- name: Build image
|
|
|
|
run: |
|
|
|
|
docker build . -t archivebox
|
|
|
|
|
|
|
|
- name: Init data dir
|
|
|
|
run: |
|
|
|
|
mkdir data
|
|
|
|
docker run -v "$PWD"/data:/data archivebox init
|
2020-07-24 19:37:29 +00:00
|
|
|
|
2020-07-22 23:30:36 +00: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
|
2020-07-24 19:37:29 +00:00
|
|
|
|
2020-07-22 23:30:36 +00:00
|
|
|
- name: Add link
|
|
|
|
run: |
|
|
|
|
docker run -v "$PWD"/data:/data --network host archivebox add http://www.test-nginx-1.local
|
2020-07-24 19:37:29 +00:00
|
|
|
|
2020-07-22 23:30:36 +00:00
|
|
|
- name: Add stdin link
|
|
|
|
run: |
|
|
|
|
echo "http://www.test-nginx-2.local" | docker run -i -v "$PWD"/data:/data archivebox add
|
2020-07-24 19:37:29 +00:00
|
|
|
|
2020-07-22 23:30:36 +00:00
|
|
|
- name: List links
|
|
|
|
run: |
|
|
|
|
docker run -v "$PWD"/data:/data archivebox 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 archivebox list | grep -q "www.test-nginx-2.local" || { echo "The site 2 isn't in the list"; exit 1; }
|
2020-07-24 19:37:29 +00:00
|
|
|
|
2020-07-28 11:49:04 +00:00
|
|
|
|
2020-07-22 23:30:36 +00:00
|
|
|
- name: Start docker-compose stack
|
|
|
|
run: |
|
2020-07-28 11:49:04 +00:00
|
|
|
docker-compose run archivebox init
|
2020-07-22 23:30:36 +00:00
|
|
|
docker-compose up -d
|
2020-07-28 11:49:04 +00:00
|
|
|
sleep 4
|
|
|
|
curl --silent --location 'http://127.0.0.1:8000/static/admin/js/jquery.init.js' | grep 'django.jQuery'
|
2020-07-24 19:37:29 +00:00
|
|
|
|
2020-07-28 11:49:04 +00:00
|
|
|
- name: Check added urls show up in index
|
|
|
|
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'
|
|
|
|
|
|
|
|
- name: Curl index with PUBLIC_INDEX=False
|
2020-07-03 20:52:28 +00:00
|
|
|
run: |
|
2020-07-28 11:49:04 +00:00
|
|
|
docker-compose run archivebox config --set PUBLIC_INDEX=False
|
|
|
|
docker-compose restart
|
|
|
|
sleep 4
|
2020-07-28 11:18:10 +00:00
|
|
|
curl --silent --location 'http://127.0.0.1:8000' | grep 'ArchiveBox Admin'
|
2020-07-28 11:49:04 +00:00
|
|
|
|
|
|
|
- name: Curl index with PUBLIC_INDEX=True
|
|
|
|
run: |
|
2020-07-28 11:18:10 +00:00
|
|
|
docker-compose run archivebox config --set PUBLIC_INDEX=True
|
2020-07-28 11:49:04 +00:00
|
|
|
docker-compose restart
|
|
|
|
sleep 4
|
2020-07-28 11:18:10 +00:00
|
|
|
curl --silent --location 'http://127.0.0.1:8000' | grep 'Add Links'
|