Skip to content

Commit 84ac4f2

Browse files
committed
Add Bats Unit Tests
1 parent 2344d36 commit 84ac4f2

File tree

5 files changed

+896
-0
lines changed

5 files changed

+896
-0
lines changed

.github/workflows/shell-tests.yml

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
name: Shell Script Tests
2+
3+
on:
4+
pull_request:
5+
branches: [main]
6+
paths:
7+
- "**.sh"
8+
- "tests/**"
9+
- ".github/workflows/shell-tests.yml"
10+
11+
jobs:
12+
shellcheck:
13+
name: ShellCheck
14+
runs-on: ubuntu-latest
15+
steps:
16+
- name: Checkout repository
17+
uses: actions/checkout@v3
18+
19+
- name: Run ShellCheck
20+
uses: ludeeus/action-shellcheck@master
21+
with:
22+
severity: error
23+
check_together: "yes"
24+
formats: sh
25+
26+
shell-unit-tests:
27+
name: Bats Unit Tests
28+
runs-on: ubuntu-latest
29+
steps:
30+
- name: Checkout repository
31+
uses: actions/checkout@v3
32+
33+
- name: Setup Bats
34+
uses: mig4/setup-bats@v1
35+
with:
36+
bats-version: 1.8.2
37+
38+
- name: Install Bats libraries
39+
run: |
40+
git clone https://github.com/bats-core/bats-support.git /tmp/bats-support
41+
git clone https://github.com/bats-core/bats-assert.git /tmp/bats-assert
42+
git clone https://github.com/bats-core/bats-file.git /tmp/bats-file
43+
44+
- name: Prepare test environment
45+
run: |
46+
# Create directories needed for tests with proper permissions
47+
sudo mkdir -p /var/run/secrets/kubernetes.io/serviceaccount
48+
sudo chmod -R 777 /var/run/secrets
49+
50+
- name: Run tests
51+
env:
52+
BATS_LIB_PATH: /tmp
53+
run: |
54+
chmod +x tests/run-tests.sh
55+
sudo -E tests/run-tests.sh

0 commit comments

Comments
 (0)