From 6cd251973d31e6ac2158e0770ec494e76ed4ec56 Mon Sep 17 00:00:00 2001 From: Ben Alkov Date: Tue, 28 Apr 2020 13:16:04 -0400 Subject: [PATCH] Set up all CI to use GH actions Signed-off-by: Ben Alkov --- .github/workflows/dockerfile_lint.yml | 16 ++++ .github/workflows/test_sh.yaml | 116 ++++++++++++++++++++++++++ .stickler.yml | 5 -- .travis.yml | 50 ----------- requirements_test.txt | 4 + test.sh | 6 +- 6 files changed, 139 insertions(+), 58 deletions(-) create mode 100644 .github/workflows/dockerfile_lint.yml create mode 100644 .github/workflows/test_sh.yaml delete mode 100644 .stickler.yml delete mode 100644 .travis.yml create mode 100644 requirements_test.txt diff --git a/.github/workflows/dockerfile_lint.yml b/.github/workflows/dockerfile_lint.yml new file mode 100644 index 0000000000..99cfbaae71 --- /dev/null +++ b/.github/workflows/dockerfile_lint.yml @@ -0,0 +1,16 @@ +name: Lint Dockerfiles + +on: [pull_request] + +jobs: + dockerfile-lint: + runs-on: ubuntu-latest + + container: + image: hadolint/hadolint:latest-debian + + steps: + - uses: actions/checkout@v1 + + - name: Lint Dockerfiles with hadolint + run: hadolint images/**/Dockerfile tests/files/**/Dockerfile diff --git a/.github/workflows/test_sh.yaml b/.github/workflows/test_sh.yaml new file mode 100644 index 0000000000..0cb2557638 --- /dev/null +++ b/.github/workflows/test_sh.yaml @@ -0,0 +1,116 @@ +name: Run tests using test.sh + +on: [pull_request] + +jobs: + test: + name: Python ${{ matrix.os.python }} tests on ${{ matrix.os.name }}-${{ matrix.os.version }} + runs-on: ubuntu-latest + + strategy: + fail-fast: false + matrix: + os: + # - name: centos + # version: 7 + # python: 2 + # engine: docker + + # - name: fedora + # version: 30 + # python: 3 + # engine: docker + + - name: fedora + version: 31 + python: 3 + engine: docker + + steps: + - uses: actions/checkout@v1 + + - name: Install dependencies + run: | + python -m pip install --upgrade pip + pip install -r requirements_test.txt + + - name: test.sh + env: + OS: ${{ matrix.os.name }} + OS_VERSION: ${{ matrix.os.version }} + PYTHON_VERSION: ${{ matrix.os.python }} + ENGINE: ${{ matrix.os.engine }} + run: ./test.sh + + - name: Coveralls + uses: coverallsapp/github-action@master + with: + github-token: ${{ secrets.GITHUB_TOKEN }} + + pylint: + name: Pylint analyzer for Python ${{ matrix.os.python }} + runs-on: ubuntu-latest + + strategy: + matrix: + os: + # - name: fedora + # version: 29 + # python: 2 + # engine: docker + + - name: fedora + version: 31 + python: 3 + engine: docker + + steps: + - uses: actions/checkout@v1 + + - run: ./test.sh + env: + OS: ${{ matrix.os.name }} + OS_VERSION: ${{ matrix.os.version }} + PYTHON_VERSION: ${{ matrix.os.python }} + ENGINE: ${{ matrix.os.engine }} + ACTION: pylint + + # bandit: + # name: Bandit analyzer for Python ${{ matrix.os.python }} + # runs-on: ubuntu-latest + + # strategy: + # matrix: + # os: + # - name: centos + # version: 7 + # python: 2 + # engine: docker + + # - name: fedora + # version: 31 + # python: 3 + # engine: docker + + # steps: + # - uses: actions/checkout@v1 + + # - run: ./test.sh + # env: + # OS: ${{ matrix.os.name }} + # OS_VERSION: ${{ matrix.os.version }} + # PYTHON_VERSION: ${{ matrix.os.python }} + # ENGINE: ${{ matrix.os.engine }} + # ACTION: bandit + + # markdownlint: + # name: markdownlint analyzer + # runs-on: ubuntu-latest + + # steps: + # - uses: actions/checkout@v1 + + # - run: ./test.sh + # env: + # ENGINE: docker + # ACTION: markdownlint diff --git a/.stickler.yml b/.stickler.yml deleted file mode 100644 index e621d759f4..0000000000 --- a/.stickler.yml +++ /dev/null @@ -1,5 +0,0 @@ -linters: - flake8: - max-line-length: 100 - shellcheck: - shell: bash diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index fe5f1228c7..0000000000 --- a/.travis.yml +++ /dev/null @@ -1,50 +0,0 @@ -language: python -branches: - only: - - master -sudo: "required" -services: - - docker -env: - matrix: - - ACTION=bandit - OS=centos - OS_VERSION=7 - PYTHON_VERSION=2 - ENGINE=docker - - ACTION=bandit - OS=fedora - OS_VERSION=31 - PYTHON_VERSION=3 - ENGINE=docker - - ACTION=pylint - OS=fedora - OS_VERSION=29 - PYTHON_VERSION=2 - ENGINE=docker - - ACTION=pylint - OS=fedora - OS_VERSION=31 - PYTHON_VERSION=3 - ENGINE=docker - - OS=centos - OS_VERSION=7 - PYTHON_VERSION=2 - ENGINE=docker - - OS=fedora - OS_VERSION=30 - PYTHON_VERSION=3 - ENGINE=docker - - OS=fedora - OS_VERSION=31 - PYTHON_VERSION=3 - ENGINE=docker - - ACTION=markdownlint - ENGINE=docker -install: - - pip install coveralls -script: - - ./test.sh -after_success: coveralls -notifications: - email: false diff --git a/requirements_test.txt b/requirements_test.txt new file mode 100644 index 0000000000..d2e42100e4 --- /dev/null +++ b/requirements_test.txt @@ -0,0 +1,4 @@ +pytest +coverage +pytest-cov +coveralls diff --git a/test.sh b/test.sh index c2f81dac1b..b355868d32 100755 --- a/test.sh +++ b/test.sh @@ -13,7 +13,7 @@ CONTAINER_NAME="atomic-reactor-$OS-$OS_VERSION-py$PYTHON_VERSION" if [[ $ACTION == "markdownlint" ]]; then IMAGE="ruby" CONTAINER_NAME="atomic-reactor-$ACTION-$IMAGE" - RUN="$ENGINE exec -ti $CONTAINER_NAME" + RUN="$ENGINE exec -i $CONTAINER_NAME" fi # Use arrays to prevent globbing and word splitting @@ -43,7 +43,7 @@ function setup_osbs() { # PIP_PREFIX: osbs-client provides input templates that must be copied into /usr/share/... ENVS='-e PIP_PREFIX=/usr' - RUN="$ENGINE exec -ti ${ENVS} $CONTAINER_NAME" + RUN="$ENGINE exec -i ${ENVS} $CONTAINER_NAME" PYTHON="python$PYTHON_VERSION" PIP="pip$PYTHON_VERSION" if [[ $OS == "fedora" ]]; then @@ -142,7 +142,7 @@ function setup_osbs() { case ${ACTION} in "test") setup_osbs - TEST_CMD="pytest tests --cov atomic_reactor --cov-report html" + TEST_CMD="pytest --cov=atomic_reactor --cov-report=html --color=yes tests" ;; "pylint") setup_osbs