This is an automated email from the ASF dual-hosted git repository. tvb pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/buildstream-plugins.git
commit d54c1efc677cb4911b14f3c934b443b11d61a8ec Author: Tristan van Berkom <[email protected]> AuthorDate: Fri Mar 25 14:35:50 2022 +0900 .github: Adding run-ci.sh and the ci.docker-compose.yml This doesn't add CI workflows but adds the underlying mechanics needed to run the tox test suite under the various docker containers. --- .github/common.env | 5 +++ .github/compose/ci.docker-compose.yml | 58 ++++++++++++++++++++++++ .github/run-ci.sh | 83 +++++++++++++++++++++++++++++++++++ 3 files changed, 146 insertions(+) diff --git a/.github/common.env b/.github/common.env new file mode 100644 index 0000000..02eea32 --- /dev/null +++ b/.github/common.env @@ -0,0 +1,5 @@ +# Shared common variables + +CI_IMAGE_VERSION=master-488745436 +CI_TOXENV_ALL=py37,py38,py39,py310 +CI_TOXENV_MASTER=py37-bst-master,py38-bst-master,py39-bst-master,py310-bst-master diff --git a/.github/compose/ci.docker-compose.yml b/.github/compose/ci.docker-compose.yml new file mode 100644 index 0000000..1251079 --- /dev/null +++ b/.github/compose/ci.docker-compose.yml @@ -0,0 +1,58 @@ +version: '3.4' + +x-tests-template: &tests-template + image: registry.gitlab.com/buildstream/buildstream-docker-images/testsuite-fedora:35-${CI_IMAGE_VERSION:-latest} + command: tox -vvvvv -- --color=yes --integration + environment: + TOXENV: ${CI_TOXENV_ALL} + + # Enable privileges to run the sandbox + # + privileged: true + devices: + - /dev/fuse:/dev/fuse + + # Mount the local directory and set the working directory + # to run the tests from. + # + volumes: + - ../..:/home/testuser/buildstream + working_dir: /home/testuser/buildstream + + +services: + + fedora-34: + <<: *tests-template + image: registry.gitlab.com/buildstream/buildstream-docker-images/testsuite-fedora:34-${CI_IMAGE_VERSION:-latest} + + fedora-35: + <<: *tests-template + image: registry.gitlab.com/buildstream/buildstream-docker-images/testsuite-fedora:35-${CI_IMAGE_VERSION:-latest} + + debian-10: + <<: *tests-template + image: registry.gitlab.com/buildstream/buildstream-docker-images/testsuite-debian:10-${CI_IMAGE_VERSION:-latest} + + # Ensure that tests also pass in the absence of a sandboxing tool + fedora-missing-deps: + <<: *tests-template + image: registry.gitlab.com/buildstream/buildstream-docker-images/testsuite-fedora:minimal-${CI_IMAGE_VERSION:-latest} + + # Test against the master version of BuildStream + bst-master: + <<: *tests-template + environment: + TOXENV: ${CI_TOXENV_MASTER} + + docs: + <<: *tests-template + command: tox -e docs + + lint: + <<: *tests-template + command: tox -e lint,format-check + + mypy: + <<: *tests-template + command: tox -e mypy diff --git a/.github/run-ci.sh b/.github/run-ci.sh new file mode 100755 index 0000000..d4f60e3 --- /dev/null +++ b/.github/run-ci.sh @@ -0,0 +1,83 @@ +#!/bin/bash + +topdir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" + +function usage () { + echo "Usage: " + echo " run-ci.sh [OPTIONS] [TEST NAME [TEST NAME...]]" + echo + echo "Runs the CI tests locally using docker" + echo + echo "The test names are based on the names of tests in the CI yaml files" + echo + echo "If no test names are specified, all tests will be run" + echo + echo "Options:" + echo + echo " -h --help Display this help message and exit" + echo " " + exit 1; +} + +arg_service=false + +while : ; do + case "$1" in + -h|--help) + usage; + shift ;; + -s|--service) + arg_service=true + shift ;; + *) + break ;; + esac +done + +test_names="${@}" + + +# We need to give ownership to the docker image user `testuser`, +# chances are high that this will be the same UID as the primary +# user on this host +# +user_uid="$(id -u)" +user_gid="$(id -g)" +if [ "${user_uid}" -ne "1000" ] || [ "${user_gid}" -ne "1000" ]; then + sudo chown -R 1000:1000 "${topdir}/.." +fi + + +# runTest() +# +# $1 = test name +# +function runTest() { + test_name=$1 + + # Run docker-compose from it's directory, because it will use + # relative paths + cd "${topdir}/compose" + docker-compose \ + --env-file ${topdir}/common.env \ + --file ${topdir}/compose/ci.docker-compose.yml \ + run "${test_name}" + return $? +} + + +if [ -z "${test_names}" ]; then + for test_name in "mypy debian-10 fedora-34 fedora-35 fedora-missing-deps"; do + if ! runTest "${test_name}"; then + echo "Tests failed" + exit 1 + fi + done +else + for test_name in "${test_names}"; do + if ! runTest "${test_name}"; then + echo "Tests failed" + exit 1 + fi + done +fi
