Skip to content

Commit

Permalink
Run tests in parallel
Browse files Browse the repository at this point in the history
  • Loading branch information
sschmid committed Nov 10, 2024
1 parent a4cc340 commit 020c949
Show file tree
Hide file tree
Showing 8 changed files with 20 additions and 10 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/macos.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
steps:
- name: "Install dependencies"
run: |
brew install bash fzf kcov shellcheck
brew install bash fzf kcov parallel shellcheck
brew install --cask keepassxc
- name: "Checkout"
Expand All @@ -21,10 +21,10 @@ jobs:
submodules: recursive

- name: "Run tests"
run: test/run
run: test/run -j $(sysctl -n hw.logicalcpu)

- name: "Test coverage"
run: test/coverage
run: test/coverage --jobs $(sysctl -n hw.logicalcpu) test

- name: "Upload coverage report"
uses: actions/upload-artifact@v4
Expand Down
3 changes: 2 additions & 1 deletion docker/alpine/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ WORKDIR /usr/local/opt/pw
COPY DEPENDENCIES.md .
RUN apk add --no-cache \
$(cat DEPENDENCIES.md) \
parallel \
xclip \
xvfb

Expand All @@ -20,4 +21,4 @@ ENTRYPOINT ["docker-entrypoint.sh"]
FROM pw AS test
WORKDIR /usr/local/opt/pw
COPY test test
RUN test/bats/bin/bats test
RUN test/bats/bin/bats --jobs $(nproc) test
3 changes: 2 additions & 1 deletion docker/archlinux/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ WORKDIR /usr/local/opt/pw
COPY DEPENDENCIES.md .
RUN pacman -Syu --noconfirm && pacman -S --noconfirm --needed \
$(cat DEPENDENCIES.md) \
parallel \
xclip \
xorg-server-xvfb \
&& pacman -Scc --noconfirm
Expand All @@ -21,4 +22,4 @@ ENTRYPOINT ["docker-entrypoint.sh"]
FROM pw AS test
WORKDIR /usr/local/opt/pw
COPY test test
RUN test/bats/bin/bats test
RUN test/bats/bin/bats --jobs $(nproc) test
3 changes: 2 additions & 1 deletion docker/debian/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ COPY DEPENDENCIES.md .
RUN apt-get update && apt-get install -y \
$(cat DEPENDENCIES.md) \
file \
parallel \
xclip \
xvfb \
&& rm -rf /var/lib/apt/lists/*
Expand All @@ -21,4 +22,4 @@ ENTRYPOINT ["docker-entrypoint.sh"]
FROM pw AS test
WORKDIR /usr/local/opt/pw
COPY test test
RUN test/bats/bin/bats test
RUN test/bats/bin/bats --jobs $(nproc) test
3 changes: 2 additions & 1 deletion docker/fedora/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ COPY DEPENDENCIES.md .
RUN dnf install -y \
$(cat DEPENDENCIES.md) \
file \
parallel \
procps-ng \
xclip \
xorg-x11-server-Xvfb \
Expand All @@ -23,4 +24,4 @@ ENTRYPOINT ["docker-entrypoint.sh"]
FROM pw AS test
WORKDIR /usr/local/opt/pw
COPY test test
RUN test/bats/bin/bats test
RUN test/bats/bin/bats --jobs $(nproc) test
3 changes: 2 additions & 1 deletion docker/ubuntu/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ COPY DEPENDENCIES.md .
RUN apt-get update && apt-get install -y \
$(cat DEPENDENCIES.md) \
file \
parallel \
xclip \
xvfb \
&& rm -rf /var/lib/apt/lists/*
Expand All @@ -21,4 +22,4 @@ ENTRYPOINT ["docker-entrypoint.sh"]
FROM pw AS test
WORKDIR /usr/local/opt/pw
COPY test test
RUN test/bats/bin/bats test
RUN test/bats/bin/bats --jobs $(nproc) test
2 changes: 2 additions & 0 deletions test/pw-clip.bats
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

if [[ "$OSTYPE" == "darwin"* ]]; then

export BATS_NO_PARALLELIZE_WITHIN_FILE=true

setup() {
load 'pw'
_setup
Expand Down
7 changes: 5 additions & 2 deletions test/run
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ run_tests() {
DOCKER_BUILDKIT=1 docker build --target test -t "sschmid/pw/test/$1" -f "docker/$1/Dockerfile" .
}

while getopts ":ap:" options; do
while getopts ":aj:p:" options; do
case "${options}" in
a)
run_tests alpine
Expand All @@ -17,6 +17,9 @@ while getopts ":ap:" options; do
run_tests fedora
run_tests ubuntu
;;
j)
jobs="${OPTARG}"
;;
p)
run_tests "${OPTARG}"
exit
Expand All @@ -29,5 +32,5 @@ while getopts ":ap:" options; do
done
shift $(( OPTIND - 1 ))

test/bats/bin/bats "${@:-test}"
test/bats/bin/bats --jobs "${jobs:-1}" "${@:-test}"
test/shellcheck

0 comments on commit 020c949

Please sign in to comment.