From 15af82ce069d01f18f107cde1a2426cd51da77bb Mon Sep 17 00:00:00 2001 From: Vishnu Challa Date: Wed, 31 Jul 2024 21:46:44 -0400 Subject: [PATCH] Adding CI test Signed-off-by: Vishnu Challa --- .github/workflows/builders.yaml | 21 +++++++++++++++++ .github/workflows/ci-tests.yaml | 23 +++++++++++++++++++ .../{build-push.yaml => image-push.yaml} | 0 .github/workflows/{pylint.yml => pylint.yaml} | 7 ++---- .github/workflows/tests.yaml | 23 +++++++++++++++++++ test.bats | 8 +++++++ 6 files changed, 77 insertions(+), 5 deletions(-) create mode 100644 .github/workflows/builders.yaml create mode 100644 .github/workflows/ci-tests.yaml rename .github/workflows/{build-push.yaml => image-push.yaml} (100%) rename .github/workflows/{pylint.yml => pylint.yaml} (86%) create mode 100644 .github/workflows/tests.yaml create mode 100644 test.bats diff --git a/.github/workflows/builders.yaml b/.github/workflows/builders.yaml new file mode 100644 index 0000000..c6f02a6 --- /dev/null +++ b/.github/workflows/builders.yaml @@ -0,0 +1,21 @@ +name: Builders +on: + workflow_call: +jobs: + build: + runs-on: ubuntu-latest + strategy: + matrix: + python-version: ["3.11"] + steps: + - uses: actions/checkout@v3 + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v3 + with: + python-version: ${{ matrix.python-version }} + - name: build and install + run: | + python -m pip install --upgrade pip + pip install pylint + pip install -r requirements.txt + pip install . \ No newline at end of file diff --git a/.github/workflows/ci-tests.yaml b/.github/workflows/ci-tests.yaml new file mode 100644 index 0000000..47b0d16 --- /dev/null +++ b/.github/workflows/ci-tests.yaml @@ -0,0 +1,23 @@ +name: CI tests +on: + push: + branches: + - master + - main + pull_request: + branches: + - master + - main + +jobs: + lint: + uses: ./.github/workflows/pylint.yaml + + build: + uses: ./.github/workflows/builders.yaml + + tests: + needs: build + uses: ./.github/workflows/tests.yaml + secrets: inherit + diff --git a/.github/workflows/build-push.yaml b/.github/workflows/image-push.yaml similarity index 100% rename from .github/workflows/build-push.yaml rename to .github/workflows/image-push.yaml diff --git a/.github/workflows/pylint.yml b/.github/workflows/pylint.yaml similarity index 86% rename from .github/workflows/pylint.yml rename to .github/workflows/pylint.yaml index 25699ee..ea4a4ea 100644 --- a/.github/workflows/pylint.yml +++ b/.github/workflows/pylint.yaml @@ -1,7 +1,6 @@ name: Pylint - -on: [push,pull_request] - +on: + workflow_call: jobs: build: runs-on: ubuntu-latest @@ -18,8 +17,6 @@ jobs: run: | python -m pip install --upgrade pip pip install pylint - pip install -r requirements.txt - pip install . - name: Analysing the code with pylint run: | pylint -d C0103 -d R0912 $(git ls-files '*/*.py' '*.py') \ No newline at end of file diff --git a/.github/workflows/tests.yaml b/.github/workflows/tests.yaml new file mode 100644 index 0000000..077fbe8 --- /dev/null +++ b/.github/workflows/tests.yaml @@ -0,0 +1,23 @@ +name: Execute tests +on: + workflow_call: +jobs: + tests: + runs-on: ubuntu-latest + steps: + + - name: Install bats + uses: bats-core/bats-action@1.5.4 + with: + bats-version: 1.10.0 + support-install: false + assert-install: false + detik-install: false + file-install: false + + - name: Execute Tests + run: | + bats -F pretty -T --print-output-on-failure ./test.bats + env: + ES_SERVER: ${{ secrets.ES_SERVER }} + ES_INDEX: ${{ secrets.ES_INDEX }} \ No newline at end of file diff --git a/test.bats b/test.bats new file mode 100644 index 0000000..2fc2582 --- /dev/null +++ b/test.bats @@ -0,0 +1,8 @@ +#!/usr/bin/env bats +# vi: ft=bash +# shellcheck disable=SC2086,SC2030,SC2031,SC2164 + + +@test "orion test" { + run_cmd orion --help +} \ No newline at end of file