Update test-dev.yml #7
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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: 127.0.0.1 | |
DB_NAME: pelp | |
DB_USER: pelp | |
DB_PASSWORD: pelp-password | |
DB_PORT: 3306 | |
REDIS_HOST: 127.0.0.1 | |
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 . | |
# Set the version | |
echo '${{ steps.vars.outputs.version }}' > VERSION | |
# Build and publish | |
docker build -t "xbaro/pelp:${{ github.sha }}" -f docker/Dockerfile --build-arg PELP_VERSION=${{ steps.vars.outputs.version }} . | |
docker push xbaro/pelp:${{ github.sha }} | |