Skip to content

Commit

Permalink
Merge pull request #28 from maxortner01/documentation
Browse files Browse the repository at this point in the history
Merge pull request #27 from maxortner01/documentation
  • Loading branch information
maxortner01 committed Jun 20, 2024
2 parents c77490f + 4475620 commit 13e3f6f
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 21 deletions.
17 changes: 12 additions & 5 deletions .github/workflows/pages.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ jobs:
submodules: true

- name: "Install deps for docs"
run: brew install doxygen zlib bash cmake pkgconfig dwarfutils openssl
run: brew install doxygen zlib bash cmake pkgconfig dwarfutils openssl

- name: Set reusable strings
# Turn repeated input strings (such as the build output directory) into step outputs. These step outputs can be used throughout the workflow file.
Expand All @@ -35,6 +35,11 @@ jobs:
run: |
echo "build-output-dir=${{ github.workspace }}/build" >> "$GITHUB_OUTPUT"
- name: "Python env"
run: python3 -m venv ${{ steps.strings.outputs.build-output-dir }}/env &&
source ${{ steps.strings.outputs.build-output-dir }}/env/bin/activate &&
python3 -m pip install requests cairosvg

# Runs a single command using the runners shell
- name: Configure docs
run: cmake -B ${{ steps.strings.outputs.build-output-dir }} -DSL_BUILD_LIB=OFF -DSL_BUILD_DOCS=ON -S ${{ github.workspace }}
Expand All @@ -51,12 +56,14 @@ jobs:
run: cmake --build ${{ steps.strings.outputs.build-output-dir }}

- name: Run kcov
run: sudo ${{ steps.strings.outputs.build-output-dir }}/kcov-prefix/src/kcov-build/src/kcov --include-path=../include ${{ steps.strings.outputs.build-output-dir }}/cov_hello_test ${{ steps.strings.outputs.build-output-dir }}/hello_test &&
sudo ${{ steps.strings.outputs.build-output-dir }}/kcov-prefix/src/kcov-build/src/kcov --include-path=../include ${{ steps.strings.outputs.build-output-dir }}/cov_lua_file ${{ steps.strings.outputs.build-output-dir }}/lua_file &&
run: sudo ${{ steps.strings.outputs.build-output-dir }}/kcov-prefix/src/kcov-build/src/kcov --include-path=${{ github.workspace }}/include ${{ steps.strings.outputs.build-output-dir }}/cov_hello_test ${{ steps.strings.outputs.build-output-dir }}/hello_test &&
sudo ${{ steps.strings.outputs.build-output-dir }}/kcov-prefix/src/kcov-build/src/kcov --include-path=${{ github.workspace }}/include ${{ steps.strings.outputs.build-output-dir }}/cov_lua_file ${{ steps.strings.outputs.build-output-dir }}/lua_file &&
sudo ${{ steps.strings.outputs.build-output-dir }}/kcov-prefix/src/kcov-build/src/kcov --merge ${{ steps.strings.outputs.build-output-dir }}/coverage ${{ steps.strings.outputs.build-output-dir }}/cov_* &&
sudo rsync -av ${{ steps.strings.outputs.build-output-dir }}/coverage/. ${{ steps.strings.outputs.build-output-dir }}/docs/html --exclude=index.html &&
sudo cp ${{ steps.strings.outputs.build-output-dir }}/coverage/index.html ${{ steps.strings.outputs.build-output-dir }}/docs/html/coverage.html &&
sudo python3 ${{ github.workspace }}/docs/get_url.py ${{ steps.strings.outputs.build-output-dir }}/docs/html
sudo cp ${{ steps.strings.outputs.build-output-dir }}/coverage/index.html ${{ steps.strings.outputs.build-output-dir }}/docs/html/coverage.html

- name: Run python script
run: sudo bash && source ${{ steps.strings.outputs.build-output-dir }}/env/bin/activate && python3 ${{ github.workspace }}/docs/get_url.py ${{ steps.strings.outputs.build-output-dir }}/docs/html

- name: Create GitHub Pages artifact
uses: actions/[email protected]
Expand Down
9 changes: 0 additions & 9 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -104,13 +104,4 @@ if (SL_BUILD_DOCS)
else (DOXYGEN_FOUND)
message(FATAL_ERROR "Doxygen need to be installed to generate the doxygen documentation")
endif (DOXYGEN_FOUND)
endif()

if (SL_CODE_COVERAGE AND SL_BUILD_DOCS)
add_custom_command(TARGET kcov
DEPENDS t3.txt doc_doxygen
COMMAND rsync -av ${CMAKE_CURRENT_BINARY_DIR}/coverage/. ${CMAKE_CURRENT_BINARY_DIR}/docs/html --exclude=index.html &&
cp ${CMAKE_CURRENT_BINARY_DIR}/coverage/index.html ${CMAKE_CURRENT_BINARY_DIR}/docs/html/coverage.html &&
python3 ${CMAKE_SOURCE_DIR}/docs/get_url.py ${CMAKE_CURRENT_BINARY_DIR}/docs/html # now we need to create the forward to the correct badge
)
endif()
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# Simple Lua (for C++)
![tests](https://github.com/maxortner01/simple-lua/actions/workflows/cmake.yml/badge.svg)
![tests](https://simple-lua.maxortner.com/coverage-badge.html)

![tests](https://simple-lua.maxortner.com/coverage-badge)

This is a basic C++ interface for using a Lua runtime and getting data to and from Lua scripts. For detailed documentation [check out the docs page](https://simple-lua.maxortner.com).
13 changes: 7 additions & 6 deletions docs/get_url.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import sys, json
import sys, json, requests

color_ranges = { 0: "red", 50: "orange", 75: "yellow", 90: "green" }
percent = float(json.loads(open(sys.argv[1] + "/kcov-merged/coverage.json", "r").read())["percent_covered"])
Expand All @@ -7,8 +7,9 @@
max_val = max([c[0] for c in colors])
color = [c[1] for c in colors if c[0] == max_val][0]
url = "https://img.shields.io/badge/code_coverage-{perc}%25-{color}?link=https://simple-lua.maxortner.com/coverage.html".format(perc=int(percent), color=color)
html = """
<head><meta http-equiv="refresh" content="0; url={url}" /></head>
<body>Redirecting...</body>
""".format(url=url)
open(sys.argv[1] + "/coverage-badge.html", "w").write(html)

img_data = requests.get(url).content
#open(sys.argv[1] + "/coverage-badge", 'wb').write(img_data)
#open(sys.argv[1] + "/coverage-badge.svg", 'wb')
from cairosvg import svg2png
svg2png(bytestring=img_data,write_to='coverage-badge.png')

0 comments on commit 13e3f6f

Please sign in to comment.