Skip to content

Workflow file for this run

name: CI
on:
- push
- pull_request
jobs:
Python-Test:
runs-on: ubuntu-latest
services:
redis:
image: redis:latest
ports:
- 6379:6379
postgres:
image: postgres:14
env:
POSTGRES_DB: varfish_web
POSTGRES_USER: varfish_web
POSTGRES_PASSWORD: varfish_web
DATABASE_URL: postgres://varfish_web:varfish_web@postgres/varfish_web
CELERY_BROKER_URL: redis://redis:6379/0
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 10
ports:
- 5432:5432
# We launch a minio instance for testing. Note that we use the bitnami
# image because of the issue lined out in this SO discussion:
#
# - https://stackoverflow.com/questions/64031598
minio:
image: bitnami/minio:latest
env:
MINIO_ROOT_USER: minioadmin
MINIO_ROOT_PASSWORD: minio-root-password
options: >-
--name=minio
--health-cmd "curl http://localhost:9000/minio/health/live"
--health-interval 10s
--health-timeout 5s
--health-retries 10
ports:
- 9000:9000
env:
CELERY_BROKER_URL: redis://0.0.0.0:6379/0
DATABASE_URL: 'postgres://varfish_web:[email protected]/varfish_web'
POSTGRES_HOST: 0.0.0.0
POSTGRES_PORT: 5432
VARFISH_CASE_IMPORT_INTERNAL_STORAGE: |
{
"bucket": "varfish-server-test",
"host": "minio",
"port": 9000,
"access_key": "varfish-server-test",
"secret_key": "varfish-server-test"
}
steps:
- name: Perform minio client setup
run: |
set -x
# create host alias for minio
echo "127.0.0.1 minio" | sudo tee -a /etc/hosts
# install minio client and configure default alias
wget -O /usr/local/bin/mc https://dl.min.io/client/mc/release/linux-amd64/mc
chmod +x /usr/local/bin/mc
mc alias set minio/ http://minio:9000 minioadmin minio-root-password
# setup bucket and access key for tests
mc mb minio/varfish-server-test
mc admin user add minio varfish-server-test varfish-server-test
# write policy file for bucket access, add it to server, and associate with
# access key created above
cat >/tmp/policy.json <<"EOF"
{
"Version": "2012-10-17",
"Statement": [
{
"Action": [
"s3:DeleteObject",
"s3:GetBucketLocation",
"s3:GetObject",
"s3:ListBucket",
"s3:PutObject"
],
"Effect": "Allow",
"Resource": [
"arn:aws:s3:::varfish-server-test/*",
"arn:aws:s3:::varfish-server-test"
],
"Sid": "BucketAccessForUser"
}
]
}
EOF
mc admin policy create minio varfish-server-test-policy /tmp/policy.json
mc admin policy attach minio varfish-server-test-policy --user varfish-server-test
- name: Install system dependencies
run: |
sudo apt-get update
sudo apt-get install -y build-essential zlib1g-dev libtiff5-dev libjpeg8-dev \
libfreetype6-dev liblcms2-dev libwebp-dev libpq-dev graphviz-dev \
libldap2-dev libsasl2-dev
- name: Checkout repository
uses: actions/checkout@v4
with:
submodules: 'recursive'
lfs: true
- name: Install Python
uses: actions/setup-python@v5
with:
# We need to fix the patch version here otherwise, snapshot tests
# with randomness will / may fail.
python-version: "3.10.13"
- name: Install pip and Pipenv
run: |
pip install -U pip pipenv
- name: Install project dependencies with pipenv
run: |
pipenv install --verbose --categories=packages,dev-packages,ldap-packages
- name: Download icons
run: pipenv run python manage.py geticons
- name: Run collectstatic
run: pipenv run python manage.py collectstatic --noinput
- name: Build Vue app as that can be tested via selenium.
run: |
npm ci --prefix varfish/vueapp
npm run build --prefix varfish/vueapp
nohup npm run serve --prefix varfish/vueapp &
- name: Setup environment with worker
uses: mamba-org/setup-micromamba@v1
with:
environment-file: environment.yaml
init-shell: bash
cache-environment: true
post-cleanup: 'all'
- name: Run tests
run: |
pipenv run coverage run --rcfile=.coveragerc manage.py test -v 2 --settings=config.settings.test
pipenv run coverage xml
pipenv run coverage report
# Important: use shell that was initialized by micromamba.
shell: bash -el {0}
- name: Upload Python coverage reports to Codecov
uses: codecov/codecov-action@v4
with:
flags: python
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
Python-Lint:
runs-on: ubuntu-20.04
steps:
- name: Install Python
uses: actions/setup-python@v5
with:
python-version: "3.10"
- name: Checkout repository
uses: actions/checkout@v4
with:
submodules: 'recursive'
lfs: true
- name: Install Python
uses: actions/setup-python@v5
with:
python-version: "3.10"
- name: Install pip and Pipenv
run: |
pip install pip pipenv
- name: Install project dependencies with pipenv
run: |
pipenv install --categories=packages,dev-packages
- name: Check import order with isort
run: |
rm -rf src
pipenv run isort --force-sort-within-sections --profile=black --check .
- name: Check style with black
run: |
pipenv run black --check --line-length 100 .
- name: Run linting
run: |
pipenv run flake8
- name: Check for OpenAPI schema changes.
run: |
pipenv run python manage.py spectacular \
| sed -e 's/^ version:.*/ version: VERSION/g' \
> /tmp/varfish_api_schema.yaml
diff \
varfish/tests/drf_spectacular/varfish_api_schema.yaml \
/tmp/varfish_api_schema.yaml
shell: bash -euo pipefail {0}
Node-Lint:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
submodules: 'recursive'
lfs: true
- name: Install javascript dependencies
run: |
npm ci --prefix varfish/vueapp
- name: Run linting
run: |
make vue_lint
Node-Test:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
submodules: 'recursive'
lfs: true
- name: Install javascript dependencies
run: |
npm ci --prefix varfish/vueapp
- name: Run Vue app tests
run: |
make vue_test-coverage
- name: Upload nodejs coverage reports to Codecov
uses: codecov/codecov-action@v4
with:
flags: nodejs
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}