Skip to content

Tooling ehancements

Tooling ehancements #9

Workflow file for this run

name: Continuous Integration
# Enable Buildkit and let compose use it to speed up image building
env:
DOCKER_BUILDKIT: 1
COMPOSE_DOCKER_CLI_BUILD: 1
on:
pull_request:
branches:
- master
push:
branches:
- master
jobs:
lint:
runs-on: ubuntu-22.04
steps:
- name: Checkout Code Repository
uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.12"
cache: 'pip'
- name: Install dependencies
run: |
pip install --upgrade pip
pip install -r requirements.txt
- name: Black
run: |
black . --check
- name: isort
run: |
isort . --check-only --profile black
- name: Flake8
run: |
flake8 tests tenlists
test:
runs-on: ubuntu-22.04
needs: [lint]
container:
image: python:3.12-slim-bookworm
env:
TENLISTS_SECRET_KEY_DEV: fake
MAIL_SERVER_DEV: smtp.mailtrap.io
MAIL_PORT_DEV: 2525
TENLISTS_EMAIL_USER_DEV: ''
TENLISTS_EMAIL_PWD_DEV: ''
MAIL_USE_TLS: True
MAIL_USE_SSL: False
TENLISTS_MP3_CLOUD_STORAGE_BASE_URL: https://example.com/path/to/folder
TENLISTS_API_BASE: http://127.0.0.1:8000/ten-lists/api/v1.0/mp3s
steps:
- name: Checkout source code
uses: actions/checkout@v4
- name: System Dependencies
shell: bash
run: |
apt-get update --yes --quiet
apt-get install --yes --quiet --no-install-recommends build-essential curl ffmpeg git
curl -fsSL https://deb.nodesource.com/setup_16.x | bash -
apt-get install -y nodejs
npm ci --cache .npm --prefer-offline
grunt all
- name: Install Python dependencies & testing tools
shell: bash
run: |
pip install --upgrade pip
pip install -r requirements.txt
pip install coveralls
curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./cc-test-reporter
chmod +x ./cc-test-reporter
curl https://deepsource.io/cli | sh
- name: Create .env file to simulate a development setup
shell: bash
run: |
mkdir -p env/
touch env/.dev.env
echo "TENLISTS_SECRET_KEY_DEV='fake'" >> env/.dev.env
echo "MAIL_SERVER_DEV=smtp.mailtrap.io" >> env/.dev.env
echo "MAIL_PORT_DEV=2525" >> env/.dev.env
echo "TENLISTS_EMAIL_USER_DEV=" >> env/.dev.env
echo "TENLISTS_EMAIL_PWD_DEV=" >> env/.dev.env
echo "MAIL_USE_TLS=True" >> env/.dev.env
echo "MAIL_USE_SSL=False" >> env/.dev.env
echo "TENLISTS_MP3_CLOUD_STORAGE_BASE_URL=https://example.com/path/to/folder" >> env/.dev.env
echo "TENLISTS_API_BASE=http://127.0.0.1:8000/ten-lists/api/v1.0/mp3s" >> env/.dev.env
- name: Run tests
run: |
./cc-test-reporter before-build
pytest
coveralls
./cc-test-reporter after-build --coverage-input-type coverage.py
./bin/deepsource report --analyzer test-coverage --key python --value-file ./coverage.xml
- name: Coveralls
uses: coverallsapp/github-action@v2
with:
github-token: ${{ github.token }}
- name: Codacy Coverage Reporter
uses: codacy/codacy-coverage-reporter-action@v1.3.0
with:
project-token: ${{ secrets.CODACY_PROJECT_TOKEN }}
# or
# api-token: ${{ secrets.CODACY_API_TOKEN }}
coverage-reports: coverage.xml