Skip to content

Merge pull request #494 from open-contracting/refactor-packages #331

Merge pull request #494 from open-contracting/refactor-packages

Merge pull request #494 from open-contracting/refactor-packages #331

Workflow file for this run

name: CI
on: [push, pull_request]
jobs:
build:
if: github.event_name == 'push' || github.event.pull_request.head.repo.full_name != github.repository
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: '3.11'
cache: pip
cache-dependency-path: '**/requirements*.txt'
- uses: actions/setup-node@v4
with:
node-version: 18
cache: npm
cache-dependency-path: '**/package-lock.json'
- uses: ruby/setup-ruby@v1
with:
ruby-version: 2.6
bundler-cache: true
- working-directory: frontend
run: npm install
- name: Run Vue tests
working-directory: frontend
shell: bash
run: npx vue-cli-service test:unit
- run: pip install -r requirements.txt
# Check requirements.txt contains production requirements.
- run: ./manage.py --help
- run: pip install -r requirements_dev.txt
- name: Run Django tests
env:
PYTHONWARNINGS: error
DATABASE_URL: postgresql://postgres:postgres@localhost:${{ job.services.postgres.ports[5432] }}/postgres
CELERY_BACKEND: db+postgresql://postgres:postgres@localhost:${{ job.services.postgres.ports[5432] }}/postgres
REDIS_URL: redis://localhost:${{ job.services.redis.ports[6379] }}/0
MEDIA_ROOT: /tmp/
FILE_UPLOAD_TEMP_DIR: /tmp/
shell: bash
run: |
./manage.py migrate
./manage.py makemigrations --check --dry-run
./manage.py check --fail-level WARNING
coverage run --source=core,spoonbill_web -m pytest -W error --no-migrations
- uses: coverallsapp/github-action@v2
services:
postgres:
image: postgres:16
env:
POSTGRES_PASSWORD: postgres
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
ports:
- 5432/tcp
redis:
image: bitnami/redis:6.2
env:
ALLOW_EMPTY_PASSWORD: "yes"
options: >-
--health-cmd "redis-cli ping"
--health-interval 10s
--health-timeout 5s
--health-retries 5
ports:
- 6379/tcp
docker:
if: github.event_name == 'push' || github.event.pull_request.head.repo.full_name != github.repository
runs-on: ubuntu-latest
steps:
# Build the images and start the containers.
- uses: actions/checkout@v4
- name: Create .env file
run: |
echo "DJANGO_ENV=production" >> .env
echo "DATABASE_URL=postgresql://postgres:postgres@host.docker.internal:${{ job.services.postgres.ports[5432] }}/postgres" >> .env
echo "CELERY_BACKEND=db+postgresql://postgres:postgres@host.docker.internal:${{ job.services.postgres.ports[5432] }}/postgres" >> .env
echo "REDIS_URL=redis://redis:6379/0" >> .env
echo "CORS_ALLOWED_ORIGINS=http://127.0.0.1:8000,http://127.0.0.1" >> .env
- run: docker compose -f docker-compose.test.yaml pull --ignore-pull-failures
- run: docker compose -f docker-compose.test.yaml build
- run: docker compose -f docker-compose.test.yaml up -d
- run: docker compose -f docker-compose.test.yaml run --rm app python manage.py migrate
- run: docker ps
# If any containers are not up, debug with, for example:
# - run: docker compose -f docker-compose.test.yaml logs app
# Test the images.
- uses: actions/checkout@v4
with:
repository: open-contracting/spoonbill-test
path: test
- uses: actions/setup-python@v5
with:
python-version: '3.11'
- run: pip install -r test/requirements_dev.txt
- name: Copy translation files for tests
run: |
cp core/locale/es/LC_MESSAGES/django.po test/resources/core_es.po
cp spoonbill_web/locale/es/LC_MESSAGES/django.po test/resources/backend_es.po
cp frontend/locale/es/lang.po test/resources/front_es.po
- env:
# See https://github.com/open-contracting/spoonbill-test
SITE_URL: http://127.0.0.1
working-directory: test
continue-on-error: true
run: python -m robot tests
- uses: actions/upload-artifact@v4
if: always()
with:
path: |
test/log.html
test/output.xml
test/report.html
services:
postgres:
image: postgres:16
env:
POSTGRES_PASSWORD: postgres
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
ports:
- 5432/tcp