Skip to content

Commit 3597aa5

Browse files
authored
Merge pull request #55 from Heshdude/test-git-checkout-workflow
Run ShellSpec tests on changed installers on PRs
2 parents f4ac5d0 + e6b9994 commit 3597aa5

File tree

5 files changed

+54
-0
lines changed

5 files changed

+54
-0
lines changed

.github/workflows/dockerimage.yml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
name: Run tests
2+
3+
on:
4+
5+
push:
6+
branches: [ master ]
7+
8+
pull_request:
9+
branches: [ master ]
10+
11+
12+
jobs:
13+
14+
test-on-ubuntu:
15+
16+
runs-on: ubuntu-latest
17+
steps:
18+
- uses: actions/checkout@v2
19+
- uses: technote-space/get-diff-action@v1
20+
- name: Get the list of modified files only
21+
run: docker build -t shellspec . && docker run -v $PWD:/app shellspec bash -c "cd /app && ./test.sh ${{ env.GIT_DIFF }}"

Dockerfile

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
FROM ubuntu
2+
3+
ARG DEBIAN_FRONTEND=noninteractive
4+
RUN apt update && apt install -y curl git expect
5+
RUN git clone https://github.com/shellspec/shellspec.git \
6+
&& mkdir $HOME/bin/ \
7+
&& ln -s /shellspec/shellspec /usr/local/bin/
8+
RUN apt remove git -y
9+
RUN shellspec -v
10+
WORKDIR /app
11+
CMD shellspec

installers/hello/installer.sh

100644100755
File mode changed.
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
Describe "Installer script for"
2+
Describe "hello"
3+
It "should say hello!"
4+
When call installers/hello/installer.sh
5+
The output should eq "Hello!"
6+
End
7+
End
8+
End

test.sh

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
#!/bin/bash
2+
3+
#declare -a X
4+
X=()
5+
6+
for word in "$@"; do
7+
# echo $(dirname "$word")
8+
X+=$(dirname "$word " | cut -d "/" -f "1 2")" "
9+
done
10+
11+
CHANGED=$(echo $X | tr ' ' '\n' | sort | uniq | xargs)
12+
13+
echo "Running tests on $CHANGED"
14+
shellspec $CHANGED -f d

0 commit comments

Comments
 (0)