Merge pull request 'drew/add-ci-setup' (#1) from drew/add-ci-setup into master
Reviewed-on: #1pull/3/head
commit
6cab703805
@ -0,0 +1,23 @@
|
|||||||
|
kind: pipeline
|
||||||
|
type: docker
|
||||||
|
name: CI Test Pipeline
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- name: greeting
|
||||||
|
image: alpine
|
||||||
|
commands:
|
||||||
|
- echo "Welcome to drone\n"
|
||||||
|
|
||||||
|
- name: Unit Tests
|
||||||
|
image: python:3.11-bullseye
|
||||||
|
commands:
|
||||||
|
- bash -c './ci_scripts/run_unit_tests.sh'
|
||||||
|
|
||||||
|
trigger:
|
||||||
|
event:
|
||||||
|
- pull_request
|
||||||
|
- push
|
||||||
|
|
||||||
|
# Secrets used to pull private images
|
||||||
|
image_pull_secrets:
|
||||||
|
- dockerconfigjson
|
@ -0,0 +1,10 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
function _setup_env() {
|
||||||
|
# build a virtual env
|
||||||
|
if [ -z "${VIRTUAL_ENV}" ]; then
|
||||||
|
python3 -m venv env
|
||||||
|
# shellcheck source=/dev/null
|
||||||
|
source env/bin/activate
|
||||||
|
fi
|
||||||
|
}
|
@ -1,20 +0,0 @@
|
|||||||
#!/usr/bin/env bash
|
|
||||||
|
|
||||||
# setting -e to exit immediately on a command failure.
|
|
||||||
# setting -o pipefail sets the exit code of a pipeline to that of the rightmost command to exit with a non-zero status, or to zero if all commands of the pipeline exit successfully.
|
|
||||||
set -eo pipefail
|
|
||||||
|
|
||||||
if [ -z "$VIRTUAL_ENV" ]; then
|
|
||||||
echo "warning: you are not in a virtualenv"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
pip install -U pip pip-tools
|
|
||||||
pip-compile requirements.in
|
|
||||||
pip-compile dev-requirements.in
|
|
||||||
pip-sync requirements.txt dev-requirements.txt
|
|
||||||
|
|
||||||
if [ ! -d ".git" ]; then
|
|
||||||
git init
|
|
||||||
pre-commit install
|
|
||||||
fi
|
|
@ -0,0 +1,38 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
# setting -e to exit immediately on a command failure.
|
||||||
|
# set -o pipefail sets the exit code of a pipeline to
|
||||||
|
# that of the rightmost command to exit with a non-zero status,
|
||||||
|
# or to zero if all commands of the pipeline exit successfully.
|
||||||
|
# set -u affects variables. When set, a reference to any variable
|
||||||
|
# you haven't previously defined - with the exceptions of $* and $@ -
|
||||||
|
# is an error, and causes the program to immediately exit
|
||||||
|
set -eo pipefail
|
||||||
|
IFS=$'\n\t'
|
||||||
|
|
||||||
|
# shellcheck source=/dev/null
|
||||||
|
source "$(dirname "$0")/_common.sh"
|
||||||
|
|
||||||
|
function project_bootstrap() {
|
||||||
|
_setup_env
|
||||||
|
pip install -U pip pip-tools=='7.3.0'
|
||||||
|
pip-compile requirements.in
|
||||||
|
pip-compile dev-requirements.in
|
||||||
|
pip-sync requirements.txt dev-requirements.txt
|
||||||
|
}
|
||||||
|
|
||||||
|
function install_precommit_hooks() {
|
||||||
|
if [ ! -d ".git" ]; then
|
||||||
|
git init
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ -z "$VIRTUAL_ENV" ]; then
|
||||||
|
echo "warning: you are not in a virtualenv"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
pre-commit install
|
||||||
|
}
|
||||||
|
|
||||||
|
project_bootstrap
|
||||||
|
install_precommit_hooks
|
@ -0,0 +1,12 @@
|
|||||||
|
#! /usr/bin/env bash
|
||||||
|
set -ex
|
||||||
|
|
||||||
|
# shellcheck source=/dev/null
|
||||||
|
source "$(dirname "$0")/_common.sh"
|
||||||
|
|
||||||
|
if [ "${DRONE}" == "true" ]; then
|
||||||
|
_setup_env
|
||||||
|
pip install -r requirements.txt -r dev-requirements.txt
|
||||||
|
fi
|
||||||
|
|
||||||
|
exec "${VIRTUAL_ENV}/bin/python" -m pytest -vv --cov "$@"
|
Loading…
Reference in New Issue