Skip to content

Commit

Permalink
feat: Incorporate GitHub Actions CI
Browse files Browse the repository at this point in the history
  • Loading branch information
zfields committed Jul 14, 2021
1 parent 1164324 commit f36f80f
Show file tree
Hide file tree
Showing 6 changed files with 55 additions and 31 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,18 @@
# Build development environment
# $ docker build . --tag nes-rob-test

# Launch development environment
# $ docker run --rm --volume $(pwd)/..:/nes-rob/ nes-rob-test
# Launch development environment (mount source root as /nes-rob/)
# $ docker run --rm --volume $(pwd)/../../../:/nes-rob/ --workdir /nes-rob/ nes-rob-test

# Base Image
FROM alpine

# Yarn Install Requirements
# Testing Dependencies
RUN ["ash", "-c", "\
apk add --no-cache \
gcovr \
g++ \
valgrind \
"]

WORKDIR /nes-rob/test/
CMD ["./run_all_tests.sh"]
ENTRYPOINT ["./test/run_all_tests.sh"]
6 changes: 6 additions & 0 deletions .github/actions/run-tests-in-container/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
name: 'Containerized Test'
author: 'Zachary J. Fields'
description: 'Perform unit-test in containerized environment'
runs:
using: 'docker'
image: 'Dockerfile'
20 changes: 20 additions & 0 deletions .github/workflows/nes-rob-ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
name: NES R.O.B. CI

on:
push:
branches: [ main ]
pull_request:
branches: [ main ]

jobs:
validate_code: # job id
runs-on: ubuntu-latest
steps:
- name: Checkout Code
id: checkout
uses: actions/checkout@v2
with:
submodules: true
- name: Run Tests In Container
id: containerized_tests
uses: ./.github/actions/run-tests-in-container
4 changes: 1 addition & 3 deletions docs/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ FROM alpine
COPY .gitconfig /root/
COPY .netrc /root/

# Yarn Install Requirements
# Install Dependencies
RUN ["ash", "-c", "\
apk add --no-cache \
doxygen \
Expand All @@ -25,7 +25,5 @@ RUN ["ash", "-c", "\
ttf-freefont \
"]

WORKDIR /nes-rob/

# Remove and Rebuild Documentation
CMD ["/nes-rob/docs/.publish-gh-pages.sh"]
9 changes: 5 additions & 4 deletions docs/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -101,19 +101,20 @@ Running Tests
-------------
The tests are designed to be executed using Docker, and the environment required
by the tests is defined in `test/Dockerfile`. The following directions are
provided to aid in executing the tests in a container.
by the tests is defined in `.github/actions/run-tests-in-container/Dockerfile`.
The following directions are provided to aid in executing the tests in
a container.
1. From the `nes-rob` folder, build the container with the following command:
```none
docker build test --tag nes-rob-test
docker build .github/actions/run-tests-in-container/ --tag nes-rob-test
```

2. Execute the tests inside the container using the following command:

```none
docker run --rm --volume $(pwd):/nes-rob/ nes-rob-test
docker run --rm --volume $(pwd):/nes-rob/ --workdir /nes-rob/ nes-rob-test
```

3. Similar test results should print to your terminal for review.
Expand Down
38 changes: 19 additions & 19 deletions test/run_all_tests.sh
Original file line number Diff line number Diff line change
@@ -1,25 +1,25 @@
#!/bin/sh

g++ -fprofile-arcs -ftest-coverage -Wall -Wpedantic -O0 -g \
NesRob.test.cpp \
signal_generator.test.cpp \
../src/signal_generator.cpp \
../src/signal_generator_error.cpp \
led_ntsc_driver.test.cpp \
../src/led_ntsc_driver.cpp \
w_wave_driver.test.cpp \
../src/w_wave_driver.cpp \
../src/pulse_driver_error.cpp \
../src/hal_error.cpp \
-I. \
-I ../src/ \
-I Catch2/single_include/ \
-I FakeIt/single_header/catch/ \
-DRUN_ALL_TESTS \
-o nes_rob_tests \
&& valgrind ./nes_rob_tests \
g++ -fprofile-arcs -ftest-coverage -Wall -Wpedantic -std=c++11 -O0 -g \
test/NesRob.test.cpp \
test/signal_generator.test.cpp \
src/signal_generator.cpp \
src/signal_generator_error.cpp \
test/led_ntsc_driver.test.cpp \
src/led_ntsc_driver.cpp \
test/w_wave_driver.test.cpp \
src/w_wave_driver.cpp \
src/pulse_driver_error.cpp \
src/hal_error.cpp \
-I src/ \
-I test/ \
-I test/Catch2/single_include/ \
-I test/FakeIt/single_header/catch/ \
-DRUN_ALL_TESTS \
-o nes_rob_tests \
&& valgrind --leak-check=full --error-exitcode=66 ./nes_rob_tests \
&& gcovr --print-summary --sort-percentage --exclude-throw-branches --delete \
--object-directory . \
--root ../src \
--root src \
--exclude .*_error.* \
&& rm nes_rob_tests *.gcno

0 comments on commit f36f80f

Please sign in to comment.