From 46f34d68f2a5986704d36c09443562037ba7acbb 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 | 18 +++++++++++++ .github/workflows/ci-tests.yaml | 23 +++++++++++++++++ .../{build-push.yaml => image-push.yaml} | 0 .github/workflows/{pylint.yml => pylint.yaml} | 8 +++--- .github/workflows/tests.yaml | 25 +++++++++++++++++++ test.bats | 13 ++++++++++ 6 files changed, 82 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} (91%) 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..778801e --- /dev/null +++ b/.github/workflows/builders.yaml @@ -0,0 +1,18 @@ +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: | + 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 91% rename from .github/workflows/pylint.yml rename to .github/workflows/pylint.yaml index 25699ee..d9a664e 100644 --- a/.github/workflows/pylint.yml +++ b/.github/workflows/pylint.yaml @@ -1,9 +1,8 @@ name: Pylint - -on: [push,pull_request] - +on: + workflow_call: jobs: - build: + lint: runs-on: ubuntu-latest strategy: matrix: @@ -19,7 +18,6 @@ jobs: 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..47b306c --- /dev/null +++ b/.github/workflows/tests.yaml @@ -0,0 +1,25 @@ +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 + uses: actions/checkout@v3 + run: | + bats -F pretty -T --print-output-on-failure test.bats + env: + TERM: linux + 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..6c908b7 --- /dev/null +++ b/test.bats @@ -0,0 +1,13 @@ +#!/usr/bin/env bats +# vi: ft=bash +# shellcheck disable=SC2086,SC2030,SC2031,SC2164 + + +run_cmd(){ + echo "$@" + ${@} +} + +@test "orion test" { + run_cmd orion --help +} \ No newline at end of file