1
0
Fork 0
mirror of synced 2024-06-26 10:00:19 +12:00
ArchiveBox/.github/workflows/test.yml

129 lines
3.4 KiB
YAML
Raw Normal View History

2020-07-04 08:52:28 +12:00
name: Test workflow
on: [push]
2020-07-23 11:30:36 +12:00
env:
MAX_LINE_LENGTH: 110
PIPENV_VENV_IN_PROJECT: 1
CACHE_PATH: .venv
2020-07-04 08:52:28 +12:00
jobs:
2020-07-23 11:30:36 +12:00
lint:
2020-07-04 08:52:28 +12:00
runs-on: ubuntu-latest
2020-07-23 11:30:36 +12:00
steps:
- uses: actions/checkout@v2
- name: Set up Python
uses: actions/setup-python@v1
with:
python-version: 3.8
architecture: x64
2020-07-25 07:37:29 +12:00
2020-07-23 11:30:36 +12:00
- name: Install pipenv
run: |
pip install pipenv
2020-07-25 07:37:29 +12:00
2020-07-23 11:30:36 +12:00
- uses: actions/cache@v2
id: cache-archivebox
with:
path: ${{ env.CACHE_PATH }}
key: ${{ runner.os }}-3.8-pipenv-${{ hashFiles('**/Pipfile') }}
restore-keys: |
${{ runner.os }}-3.8-pipenv-
- name: Install dependencies
run: |
pipenv install --dev
- name: Lint with flake8
run: |
# one pass for show-stopper syntax errors or undefined names
2020-07-24 03:33:01 +12:00
pipenv run flake8 archivebox --count --show-source --statistics
2020-07-23 11:30:36 +12:00
# one pass for small stylistic things
2020-07-24 03:33:01 +12:00
pipenv run flake8 archivebox --count --max-line-length="$MAX_LINE_LENGTH" --statistics
2020-07-23 11:30:36 +12:00
- name: Lint with mypy
run: |
2020-07-25 07:37:29 +12:00
pipenv run mypy archivebox || true
2020-07-23 11:30:36 +12:00
test:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, macos-latest]
python: [3.7, 3.8]
2020-07-04 08:52:28 +12:00
steps:
2020-07-23 11:30:36 +12:00
- uses: actions/checkout@v2
2020-07-04 08:52:28 +12:00
with:
fetch-depth: 1
2020-07-23 11:30:36 +12:00
- name: Set up Python ${{ matrix.python }}
2020-07-04 08:52:28 +12:00
uses: actions/setup-python@v1
with:
2020-07-23 11:30:36 +12:00
python-version: ${{ matrix.python }}
2020-07-04 08:52:28 +12:00
architecture: x64
2020-07-23 11:30:36 +12:00
- name: Install pipenv
run: |
pip install pipenv
2020-07-25 07:37:29 +12:00
2020-07-23 11:30:36 +12:00
- uses: actions/cache@v1
id: cache-archivebox
with:
path: ${{ env.CACHE_PATH }}
key: ${{ runner.os }}-${{ matrix.python }}-pipenv-${{ hashFiles('**/Pipfile') }}
restore-keys: |
${{ runner.os }}-${{ matrix.python }}-pipenv-
2020-07-04 08:52:28 +12:00
- name: Install dependencies
run: |
2020-07-23 11:30:36 +12:00
pipenv install --dev
- name: Test built package with pytest
run: |
pipenv run pytest -s
2020-07-25 07:37:29 +12:00
2020-07-23 11:30:36 +12:00
docker-test:
runs-on: ubuntu-latest
2020-07-04 08:52:28 +12:00
2020-07-23 11:30:36 +12:00
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 1
2020-07-25 07:37:29 +12:00
2020-07-23 11:30:36 +12: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-25 07:37:29 +12:00
2020-07-23 11:30:36 +12: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-25 07:37:29 +12:00
2020-07-23 11:30:36 +12:00
- name: Add link
run: |
docker run -v "$PWD"/data:/data --network host archivebox add http://www.test-nginx-1.local
2020-07-25 07:37:29 +12:00
2020-07-23 11:30:36 +12:00
- name: Add stdin link
run: |
echo "http://www.test-nginx-2.local" | docker run -i -v "$PWD"/data:/data archivebox add
2020-07-25 07:37:29 +12:00
2020-07-23 11:30:36 +12: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-25 07:37:29 +12:00
2020-07-23 11:30:36 +12:00
- name: Start docker-compose stack
run: |
docker-compose up -d
2020-07-25 07:37:29 +12:00
2020-07-23 11:30:36 +12:00
- name: Curl to Django app
2020-07-04 08:52:28 +12:00
run: |
2020-07-23 11:30:36 +12:00
sleep 10
2020-07-23 11:39:02 +12:00
curl -IL http://127.0.0.1:8000/