Browse Source

Switch CI to CircleCI (#90)

* Add CircleCI test config
pull/91/head
Dashie der otter 1 month ago
parent
commit
f48978cf5e
No account linked to committer's email address
10 changed files with 210 additions and 13 deletions
  1. 173
    0
      .circleci/config.yml
  2. 1
    0
      .coveragerc
  3. 1
    1
      .drone.yml
  4. 1
    0
      .gitignore
  5. 1
    1
      README.md
  6. 1
    1
      config.py.sample
  7. 1
    0
      pyproject.toml
  8. 2
    1
      setup.cfg
  9. 1
    1
      tests/config_test.py
  10. 28
    8
      tests/install_audiowaveform.sh

+ 173
- 0
.circleci/config.yml View File

@@ -0,0 +1,173 @@
# Python CircleCI 2.0 configuration file
# Check https://circleci.com/docs/2.0/language-python/ for more details
version: 2

aliases:
- &defaults
docker:
- image: circleci/python:3.6-buster-node
working_directory: ~/projects/reel2bits

- &attach_workspace
attach_workspace:
at: ~/projects/

- &persist_to_workspace
persist_to_workspace:
root: ~/projects/
paths:
- ./reel2bits/
- ./audiowaveform/
- &install_steps
steps:
- checkout
- *attach_workspace
# TODO: npm/node/front v2
- *persist_to_workspace

- &install_system_dependencies
run:
name: Install system dependencies
command: |
sudo apt-get update
sudo apt-get install -y sox libtag1v5 libmagic1 libffi6 ffmpeg postgresql-client-11
sudo apt-get install -y cmake build-essential git wget make libboost-all-dev
sudo apt-get install -y libsox-dev libsox-fmt-all libtag1-dev libmagic-dev libffi-dev libgd-dev libmad0-dev libsndfile1-dev libid3tag0-dev

- &install_audiowaveform
run:
name: Install audiowaveform
command: ./tests/install_audiowaveform.sh

- &install_python_dependencies
steps:
- *attach_workspace
- *install_system_dependencies
- *install_audiowaveform
- run: python -V | tee /tmp/.python-version
- restore_cache:
keys:
- v1-dependencies-{{ checksum "/tmp/.python-version" }}-{{ checksum "requirements.txt" }}
- v1-dependencies-{{ checksum "/tmp/.python-version" }}-
- v1-dependencies-
- run: python3 -m venv venv
- run:
command: |
. venv/bin/activate
pip install --requirement requirements.txt
pip install black
pip install flake8
- save_cache:
key: v1-dependencies-{{ checksum "/tmp/.python-version" }}-{{ checksum "requirements.txt" }}
paths:
- ./venv
- *persist_to_workspace

- &test_steps
steps:
- *attach_workspace
- *install_system_dependencies
- *install_audiowaveform
- run:
name: Linters
command: |
. venv/bin/activate
black --check .
flake8 . --count --show-source --statistics
- run:
name: Tests
command: |
. venv/bin/activate
cp tests/config_test.py config.py
mkdir test-reports
python setup.py test
- run:
name: Full migrations
command: |
psql -U postgres -h localhost -w -c 'CREATE DATABASE reel2bits'
psql -U postgres -h localhost -w -c 'CREATE EXTENSION IF NOT EXISTS "uuid-ossp";' reel2bits
. venv/bin/activate
cp config.py.sample config.py
flask db upgrade
- store_test_results:
path: test-reports
- store_artifacts:
path: test-reports

jobs:
install:
<<: *defaults
<<: *install_steps

install-python3.6:
<<: *defaults
<<: *install_python_dependencies

install-python3.7:
<<: *defaults
docker:
- image: circleci/python:3.7-buster-node
<<: *install_python_dependencies

install-python3.8:
<<: *defaults
docker:
- image: circleci/python:3.8-rc-buster-node
<<: *install_python_dependencies

test-python3.6:
<<: *defaults
docker:
- image: circleci/python:3.6-buster-node
- image: circleci/postgres:11-alpine
environment:
POSTGRES_USER: postgres
POSTGRES_DB: reel2bits_test
<<: *test_steps

test-python3.7:
<<: *defaults
docker:
- image: circleci/python:3.7-buster-node
- image: circleci/postgres:11-alpine
environment:
POSTGRES_USER: postgres
POSTGRES_DB: reel2bits_test
<<: *test_steps

test-python3.8:
<<: *defaults
docker:
- image: circleci/python:3.8-rc-buster-node
- image: circleci/postgres:11-alpine
environment:
POSTGRES_USER: postgres
POSTGRES_DB: reel2bits_test
<<: *test_steps

workflows:
version: 2
build-and-test:
jobs:
- install
- install-python3.6:
requires:
- install
- install-python3.7:
requires:
- install
- install-python3.6
- install-python3.8:
requires:
- install
- install-python3.6
- test-python3.6:
requires:
- install-python3.6
- test-python3.7:
requires:
- install-python3.7
- test-python3.8:
requires:
- install-python3.8

+ 1
- 0
.coveragerc View File

@@ -5,3 +5,4 @@ omit =
config.py
configtest.py
**/*__init__.py
venv/*

+ 1
- 1
.drone.yml View File

@@ -34,7 +34,7 @@ steps:
- python setup.py install
- ./tests/install_audiowaveform.sh
- black --check .
- flake8 .
- flake8 . --count --show-source --statistics
- cp tests/config_test.py config.py
- python setup.py test


+ 1
- 0
.gitignore View File

@@ -14,3 +14,4 @@
.coverage
/.ropeproject
/.mypy_cache
/test-reports

+ 1
- 1
README.md View File

@@ -5,7 +5,7 @@
</h1>

<p align="center">
<a href="https://drone.sigpipe.me/dashie/reel2bits"><img src="https://drone.sigpipe.me/api/badges/dashie/reel2bits/status.svg" alt="Build Status"/></a>
<a href="https://circleci.com/gh/rhaamo/reel2bits"><img src="https://circleci.com/gh/rhaamo/reel2bits.svg?style=svg" alt="Build Status"/></a>
<a href="https://dev.sigpipe.me/dashie/reel2bits/src/branch/master/LICENSE"><img src="https://img.shields.io/badge/license-AGPL3-green.svg"/></a>
<img src="https://img.shields.io/badge/python-%3E%3D3.6-blue.svg"/>
<a href="https://github.com/ambv/black"><img src="https://img.shields.io/badge/code%20style-black-000000.svg" alt="Code Style: black" /></a>

+ 1
- 1
config.py.sample View File

@@ -28,7 +28,7 @@ AP_ENABLED = False
# Activate federation at your own risks

SQLALCHEMY_DATABASE_URI = \
'postgresql+psycopg2://postgres@database/reel2bits'
'postgresql+psycopg2://postgres@localhost/reel2bits'

# Should users confirm theire email address ?
SECURITY_CONFIRMABLE = True

+ 1
- 0
pyproject.toml View File

@@ -7,6 +7,7 @@ exclude = '''
| \.eggs
| \.idea
| \__pycache__
| venv
)/
'''
skip-numeric-underscore-normalization = true

+ 2
- 1
setup.cfg View File

@@ -2,9 +2,10 @@
test=pytest

[tool:pytest]
addopts = --verbose --cov=.
addopts = --verbose --cov=. --cov-report=xml:test-reports/coverage.xml --junitxml=test-reports/junit.xml
python_files = tests/*.py

[flake8]
max-line-length = 120
ignore = E501
exclude = .svn,CVS,.bzr,.hg,.git,__pycache__,.tox,venv,.eggs

+ 1
- 1
tests/config_test.py View File

@@ -5,7 +5,7 @@ TESTING = True
WTF_CSRF_ENABLED = False

SECRET_KEY = "udf298euf02uf2f02f2uf0"
SQLALCHEMY_DATABASE_URI = "postgresql+psycopg2://postgres@database:5432/reel2bits_test"
SQLALCHEMY_DATABASE_URI = "postgresql+psycopg2://postgres@localhost:5432/reel2bits_test"
# SQLALCHEMY_DATABASE_URI = 'sqlite:///ahrl.db'
# SQLALCHEMY_DATABASE_URI = 'mysql://dashie:saucisse@localhost/ahrl'
SQLALCHEMY_ECHO = False

+ 28
- 8
tests/install_audiowaveform.sh View File

@@ -1,7 +1,29 @@
#!/bin/sh
#!/bin/bash

# Quick and dirty AudioWaveform build with cache logic for speedup

if [ -z "$DRONE_RUNNER_PLATFORM" ]; then
# CircleCI
RUNNER="$(uname -s)"
BINPATH=/home/circleci/projects/audiowaveform/${RUNNER}/audiowaveform
CACHEPATH=~/projects
CI="CircleCI"
SUDO="sudo"
else
# Drone
RUNNER=$DRONE_RUNNER_PLATFORM
BINPATH="${PWD}/.cache/audiowaveform/${RUNNER}/audiowaveform"
CACHEPATH=~/.cache
CI="DroneCI"
fi

echo "-- debug start"
echo "-- CI detected: ${CI}"
echo "-- runner: ${RUNNER}"
echo "-- ls cachepath (${CACHEPATH}): $(ls -la ${CACHEPATH})"
echo "-- file: $(file ${BINPATH})"
echo "-- debug end"

# Build function
build() {
echo "-- build audiowaveform; building AudioWaveform..."
@@ -15,17 +37,15 @@ build() {
cd build
cmake ..
make
mkdir -pv /usr/local/bin
cp -fv audiowaveform /usr/local/bin/audiowaveform
${SUDO} mkdir -pv /usr/local/bin
${SUDO} cp -fv audiowaveform /usr/local/bin/audiowaveform
}

BINPATH="${PWD}/.cache/audiowaveform/${DRONE_RUNNER_PLATFORM}/audiowaveform"

# Cache logic : test if we have an executable already built, and working
if [[ -d .cache ]]; then
if [[ -d $CACHEPATH ]]; then
echo "-- build audiowaveform; cache available"
# We have a cache dir, create struct
mkdir -pv ".cache/audiowaveform/${DRONE_RUNNER_PLATFORM}"
mkdir -pv "${CACHEPATH}/audiowaveform/${RUNNER}"

# Check if a binary exists
if [[ -x ${BINPATH} ]]; then
@@ -34,7 +54,7 @@ if [[ -d .cache ]]; then
if ${BINPATH} --help|grep "AudioWaveform v"; then
echo "-- build audiowaveform; and can run; copying it"
# can run
cp -fv ${BINPATH} /usr/local/bin/audiowaveform
${SUDO} cp -fv ${BINPATH} /usr/local/bin/audiowaveform
else
# can't run
build

Loading…
Cancel
Save