Skip to content

Update test-dev.yml

Update test-dev.yml #3

Workflow file for this run

# This workflow will install Python dependencies, run tests and lint with a variety of Python versions
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions
name: Testing Dev
on:
push:
branches:
- '*'
- '!master'
jobs:
pylint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up Python version
uses: actions/setup-python@v5
with:
python-version: 3.9
- name: Install dependencies
run: |
python -m pip install --upgrade pip wheel
python -m pip install -r requirements.txt -r requirements_dev.txt
- name: Run PyLint
run: |
pylint --exit-zero --load-plugins=pylint_django --output-format=text --max-line-length=120 src/pelp | tee /tmp/pylint.txt
pytest:
runs-on: ubuntu-latest
needs: pylint
# Service containers to run with `runner-job`
env:
MYSQL_ROOT_PASSWORD: '.pelp-password'
MYSQL_DATABASE: pelp
MYSQL_USER: pelp
MYSQL_PASSWORD: pelp-password
MINIO_ACCESS_KEY: minioadmin
MINIO_SECRET_KEY: minioadmin
DB_ENGINE: mysql
DB_HOST: db
DB_NAME: '$MYSQL_DATABASE'
DB_USER: '$MYSQL_USER'
DB_PASSWORD: '$MYSQL_PASSWORD'
DB_PORT: 3306
REDIS_HOST: redis
REDIS_PORT: 6379
DJANGO_SECRET: my_secret_key
ALLOWED_HOSTS: '*'
DJANGO_SETTINGS_MODULE: 'pelp.settings'
services:
redis:
image: redis
ports:
- 6379:6379
db:
image: mariadb
ports:
- 3306:3306
env:
MYSQL_ROOT_PASSWORD: '.pelp-password'
MYSQL_DATABASE: pelp
MYSQL_USER: pelp
MYSQL_PASSWORD: pelp-password
options: >-
--health-cmd "/usr/local/bin/healthcheck.sh --su=mysql --connect --innodb_initialized"
--health-interval 5s
--health-timeout 2s
--health-retries 3
--name db
minio:
image: bitnami/minio:latest
ports:
- 9000:9000
env:
MINIO_ACCESS_KEY: minioadmin
MINIO_SECRET_KEY: minioadmin
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up Python version
uses: actions/setup-python@v5
with:
python-version: 3.9
- name: Install dependencies
run: |
python -m pip install --upgrade pip wheel
python -m pip install -r requirements.txt -r requirements_dev.txt
- name: Migrate database
run: |
cd src
cp pelp/manage.py .
python manage.py migrate
export PYTHONPATH=$PYTHONPATH:$PWD
cd ..
- name: Test with pytest
run: |
coverage run -m pytest src/tests
coverage report
coverage xml
build_images:
needs: pytest
runs-on: ubuntu-latest
if: github.event_name != 'release' && github.event_name != 'pull_request'
steps:
- uses: actions/checkout@v4
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Store version
id: vars
run: |
echo ::set-output name=version::$(cat VERSION)
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to DockerHub
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and push edge image
run: |
# Build PeLP image
docker build --pull -t "xbaro/pelp:${{ github.sha }}" -f docker/Dockerfile .
python -m pip install pip-tools wheel
# Set the version
echo '${{ steps.vars.outputs.version }}' > VERSION
# Build wheel
python setup.py bdist_wheel
# Build and publish
docker build -t "xbaro/pelp:${{ github.sha }}" -f docker/Dockerfile.edge --build-arg PELP_VERSION=${{ steps.vars.outputs.version }} .
docker push xbaro/pelp:${{ github.sha }}