Browse Source

chore: created GitHub actions to run tests

pull/8373/head
Rohit T P 6 months ago
parent
commit
0315016d95
  1. 55
      .github/workflows/bats-test.yml
  2. 8
      docker-compose/setup-script/tests/configure/monitor.bats
  3. 8
      docker-compose/setup-script/tests/configure/restart.bats
  4. 8
      docker-compose/setup-script/tests/configure/scale.bats
  5. 8
      docker-compose/setup-script/tests/configure/start.bats
  6. 8
      docker-compose/setup-script/tests/configure/stop.bats
  7. 8
      docker-compose/setup-script/tests/configure/upgrade.bats
  8. 12
      docker-compose/setup-script/tests/install/default.bats
  9. 8
      docker-compose/setup-script/tests/install/ip.bats
  10. 8
      docker-compose/setup-script/tests/install/redis.bats
  11. 8
      docker-compose/setup-script/tests/install/scale.bats
  12. 8
      docker-compose/setup-script/tests/install/ssl.bats
  13. 8
      docker-compose/setup-script/tests/install/watchtower.bats

55
.github/workflows/bats-test.yml

@ -0,0 +1,55 @@
name: Run BATS Tests
on:
push:
paths:
- 'docker-compose/setup-script/noco.sh'
workflow_dispatch:
jobs:
prepare:
runs-on: ubuntu-latest
outputs:
matrix: ${{ steps.set-matrix.outputs.matrix }}
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Install jq
run: |
sudo apt-get update
sudo apt-get install -y jq
- name: Prepare matrix for test files
id: set-matrix
run: |
BATS_FILES=$(find docker-compose/setup-script/tests -name '*.bats')
MATRIX_JSON=$(echo $BATS_FILES | jq -Rsc 'split("\n") | map(select(. != ""))')
echo "matrix=$MATRIX_JSON" >> $GITHUB_ENV
test:
needs: prepare
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
test: ${{fromJson(env.matrix)}}
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Install BATS
run: |
sudo apt-get update
sudo apt-get install -y bats expect
- name: Get working directory
run: |
WORKING_DIR="$(pwd)/docker-compose/setup-script/tests"
echo "WORKING_DIR=$WORKING_DIR" >> $GITHUB_ENV
- name: Run BATS test
run: bats ${{ matrix.test }}
env:
WORKING_DIR: ${{ env.WORKING_DIR }}
SKIP_TARE_DOWN: true

8
docker-compose/setup-script/tests/configure/monitor.bats

@ -11,8 +11,12 @@ setup() {
}
teardown() {
cd "${WORKING_DIR}/configure" || exit 1
./setup.sh
if [ -n "$SKIP_TEARDOWN" ]; then
return
fi
cd "${WORKING_DIR}/install" || exit 1
./setup.sh
}
@test "Properly runs monitor script" {

8
docker-compose/setup-script/tests/configure/restart.bats

@ -11,8 +11,12 @@ setup() {
}
teardown() {
cd "${WORKING_DIR}/configure" || exit 1
./setup.sh
if [ -n "$SKIP_TEARDOWN" ]; then
return
fi
cd "${WORKING_DIR}/install" || exit 1
./setup.sh
}
@test "Check all containers are restarted" {

8
docker-compose/setup-script/tests/configure/scale.bats

@ -11,8 +11,12 @@ setup() {
}
teardown() {
cd "${WORKING_DIR}/configure" || exit 1
./setup.sh
if [ -n "$SKIP_TEARDOWN" ]; then
return
fi
cd "${WORKING_DIR}/install" || exit 1
./setup.sh
}
@test "Check NocoDB is scaled to 3 instances" {

8
docker-compose/setup-script/tests/configure/start.bats

@ -11,8 +11,12 @@ setup() {
}
teardown() {
cd "${WORKING_DIR}/configure" || exit 1
./setup.sh
if [ -n "$SKIP_TEARDOWN" ]; then
return
fi
cd "${WORKING_DIR}/install" || exit 1
./setup.sh
}
@test "Check all containers are up" {

8
docker-compose/setup-script/tests/configure/stop.bats

@ -11,8 +11,12 @@ setup() {
}
teardown() {
cd "${WORKING_DIR}/configure" || exit 1
./setup.sh
if [ -n "$SKIP_TEARDOWN" ]; then
return
fi
cd "${WORKING_DIR}/install" || exit 1
./setup.sh
}
@test "Check all containers are down" {

8
docker-compose/setup-script/tests/configure/upgrade.bats

@ -11,8 +11,12 @@ setup() {
}
teardown() {
cd "${WORKING_DIR}/configure" || exit 1
./setup.sh
if [ -n "$SKIP_TEARDOWN" ]; then
return
fi
cd "${WORKING_DIR}/install" || exit 1
./setup.sh
}
@test "Check all containers are upgraded" {

12
docker-compose/setup-script/tests/install/default.bats

@ -6,13 +6,17 @@ export NOCO_HOME
setup() {
cd "${WORKING_DIR}/install" || exit 1
./setup.sh
cd "${WORKING_DIR}/install" || exit 1
./setup.sh
}
teardown() {
cd "${WORKING_DIR}/install" || exit 1
./setup.sh
if [ -n "$SKIP_TEARDOWN" ]; then
return
fi
cd "${WORKING_DIR}/install" || exit 1
./setup.sh
}
@test "Check installation with all default options" {

8
docker-compose/setup-script/tests/install/ip.bats

@ -11,8 +11,12 @@ setup() {
}
teardown() {
cd "${WORKING_DIR}/install" || exit 1
./setup.sh
if [ -n "$SKIP_TEARDOWN" ]; then
return
fi
cd "${WORKING_DIR}/install" || exit 1
./setup.sh
}
@test "Check installation with custom ip" {

8
docker-compose/setup-script/tests/install/redis.bats

@ -11,8 +11,12 @@ setup() {
}
teardown() {
cd "${WORKING_DIR}/install" || exit 1
./setup.sh
if [ -n "$SKIP_TEARDOWN" ]; then
return
fi
cd "${WORKING_DIR}/install" || exit 1
./setup.sh
}
@test "Check Redis is enabled when specified" {

8
docker-compose/setup-script/tests/install/scale.bats

@ -11,8 +11,12 @@ setup() {
}
teardown() {
cd "${WORKING_DIR}/install" || exit 1
./setup.sh
if [ -n "$SKIP_TEARDOWN" ]; then
return
fi
cd "${WORKING_DIR}/install" || exit 1
./setup.sh
}
@test "Check if two instances of NoCoDB can be run" {

8
docker-compose/setup-script/tests/install/ssl.bats

@ -10,8 +10,12 @@ setup() {
}
teardown() {
cd "${WORKING_DIR}/install" || exit 1
./setup.sh
if [ -n "$SKIP_TEARDOWN" ]; then
return
fi
cd "${WORKING_DIR}/install" || exit 1
./setup.sh
}
@test "Should create SSL certificates" {

8
docker-compose/setup-script/tests/install/watchtower.bats

@ -9,8 +9,12 @@ setup() {
}
teardown() {
cd "${WORKING_DIR}/install" || exit 1
./setup.sh
if [ -n "$SKIP_TEARDOWN" ]; then
return
fi
cd "${WORKING_DIR}/install" || exit 1
./setup.sh
}
@test "Check WatchTower is enabled when specified" {

Loading…
Cancel
Save