Build (Linux) #44
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Build (Linux) | |
on: | |
workflow_dispatch: | |
inputs: | |
build-type: | |
description: Build in Release or Debug? | |
required: true | |
default: Debug | |
type: choice | |
options: | |
- Debug | |
- Release | |
- Release optimized | |
run-tests: | |
description: Run the tests? | |
required: false | |
default: false | |
type: boolean | |
rust-cache: | |
description: Use existing rust cache? | |
required: false | |
default: false | |
type: boolean | |
workflow_call: | |
inputs: | |
build-type: | |
required: true | |
default: Debug | |
type: string | |
run-tests: | |
required: false | |
default: false | |
type: boolean | |
rust-cache: | |
required: false | |
default: true | |
type: boolean | |
# Required for <compare> and <=> support | |
env: | |
CC: gcc-11 | |
CXX: g++-11 | |
jobs: | |
# | |
# Build shards for linux | |
# | |
Linux: | |
name: Build (${{ github.event.inputs.build-type || inputs.build-type }}) | |
runs-on: ubuntu-22.04 | |
outputs: | |
build-type: ${{ steps.setup.outputs.build-type }} | |
run-tests: ${{ steps.setup.outputs.run-tests }} | |
rust-cache: ${{ steps.setup.outputs.rust-cache }} | |
artifact-name: shards-linux ${{ steps.setup.outputs.build-type }} | |
steps: | |
- name: Setup | |
id: setup | |
run: | | |
if [ "${{ github.event.inputs.build-type || inputs.build-type }}" == "Release optimized" ] | |
then | |
echo "build-type=Release" >> $GITHUB_OUTPUT | |
echo "optimized=true" >> $GITHUB_OUTPUT | |
else | |
echo "build-type=${{ github.event.inputs.build-type || inputs.build-type }}" >> $GITHUB_OUTPUT | |
echo "optimized=false" >> $GITHUB_OUTPUT | |
fi | |
echo "run-tests=${{ github.event.inputs.run-tests || inputs.run-tests }}" >> $GITHUB_OUTPUT | |
echo "rust-cache=${{ github.event.inputs.rust-cache || inputs.rust-cache }}" >> $GITHUB_OUTPUT | |
- name: Checkout shards | |
uses: actions/checkout@v3 | |
with: | |
repository: fragcolor-xyz/shards | |
fetch-depth: 2 | |
submodules: recursive | |
- name: Set up dependencies | |
run: | | |
sudo apt-get -y update | |
sudo apt-get -y install build-essential git cmake wget clang ninja-build xorg-dev libdbus-1-dev libssl-dev lcov mesa-utils libgtk-3-dev | |
./bootstrap | |
RUSTUP_TOOLCHAIN=`cat rust.version` | |
echo "RUSTUP_TOOLCHAIN=$RUSTUP_TOOLCHAIN" >> $GITHUB_ENV | |
rustup toolchain install $RUSTUP_TOOLCHAIN | |
- uses: Swatinem/rust-cache@v2 | |
if: ${{ steps.setup.outputs.rust-cache == 'true'}} | |
with: | |
key: ${{ steps.setup.outputs.build-type }} | |
- name: Build | |
run: | | |
mkdir -p build | |
cd build | |
if [ "${{ steps.setup.outputs.build-type }}" == "Debug" ]; then | |
cmake -G Ninja -DCMAKE_BUILD_TYPE=Debug -DCODE_COVERAGE=1 -DUSE_UBSAN=ON -DTRACY_ENABLE=ON -DTRACY_TIMER_FALLBACK=ON .. | |
else | |
cmake -G Ninja -DGNU_STATIC_BUILD=ON -DSKIP_HEAVY_INLINE=${{ steps.setup.outputs.optimized == 'false' }} -DCMAKE_BUILD_TYPE=Release .. | |
fi | |
ninja shards | |
- name: Test | |
env: | |
RUST_BACKTRACE: full | |
run: | | |
cd build | |
chmod +x shards | |
./shards new ../shards/tests/hello.shs | |
./shards new ../shards/tests/general.shs | |
./shards new ../shards/tests/table-compose.shs | |
./shards ../shards/tests/variables.edn | |
./shards new ../shards/tests/subwires.shs | |
./shards new ../shards/tests/linalg.shs | |
./shards ../shards/tests/loader.clj | |
./shards new ../shards/tests/network.shs | |
./shards new ../shards/tests/struct.shs | |
./shards new ../shards/tests/flows.shs | |
./shards new ../shards/tests/kdtree.shs | |
./shards new ../shards/tests/channels.shs | |
./shards new ../shards/tests/genetic.shs | |
./shards new ../shards/tests/imaging.shs | |
./shards new ../shards/tests/http.shs | |
./shards ../shards/tests/ws.edn | |
./shards new ../shards/tests/bigint.shs | |
./shards new ../shards/tests/brotli.shs | |
./shards new ../shards/tests/snappy.shs | |
./shards new ../shards/tests/expect.shs | |
./shards new ../shards/tests/failures.shs | |
./shards ../shards/tests/wasm.clj | |
./shards ../shards/tests/rust.clj | |
./shards new ../shards/tests/crypto.shs | |
./shards ../shards/tests/wire-macro.edn | |
./shards new ../shards/tests/const-vars.shs | |
./shards new ../shards/tests/branch.shs | |
./shards ../shards/tests/time.edn | |
./shards new ../shards/tests/eth.shs | |
./shards ../shards/tests/take.edn | |
./shards new ../shards/tests/casting-numbers.shs | |
./shards new ../shards/tests/pure.shs | |
# ./shards new ../shards/tests/shell.shs | |
./shards ../shards/tests/infos.clj | |
./shards ../shards/tests/many.edn | |
./shards new ../shards/tests/events.shs | |
./shards ../shards/tests/tablecase.edn | |
./shards ../shards/tests/types.edn | |
./shards new ../shards/tests/complex-deserialize.shs | |
./shards new ../shards/tests/db.shs | |
./shards new ../shards/tests/suspend-resume.shs | |
./shards new ../shards/tests/help.shs | |
- name: Test (Debug) | |
# Test that only works in Debug build go there | |
if: ${{ steps.setup.outputs.build-type == 'Debug' }} | |
env: | |
RUST_BACKTRACE: full | |
run: | | |
cd build | |
./shards ../shards/tests/export-strings.edn | |
./shards new ../shards/tests/audio.shs test-device:true | |
- name: Test doc samples (non-UI) | |
env: | |
RUST_BACKTRACE: full | |
run: | | |
cd docs/samples | |
for i in $(find shards -name '*.edn' \( ! -path '*UI*' ! -path '*GFX*' ! -path '*Dialog*' \)); | |
do | |
echo "Running sample $i"; | |
../../build/shards run-sample.edn --file "$i"; | |
done | |
- name: Test runtime | |
env: | |
RUST_BACKTRACE: full | |
run: | | |
cd build | |
ninja test-runtime | |
./test-runtime | |
# Minimize disk usage to prevent the next steps getting stuck due to no disk space | |
- name: Minimize disk usage | |
env: | |
RUST_BACKTRACE: full | |
shell: bash | |
run: | | |
rm -rf build/target | |
rm -rf build/lib | |
rm -rf build/deps | |
rm -rf build/_deps | |
rm -rf build/.cache | |
- name: Collect coverage (Debug) | |
if: ${{ steps.setup.outputs.build-type == 'Debug' }} | |
run: | | |
mkdir coverage | |
# capture | |
lcov \ | |
--capture \ | |
--directory build/src \ | |
--directory build/modules \ | |
--output-file coverage/coverage.info | |
# remove external dependencies | |
lcov \ | |
--remove coverage/coverage.info "*/c++/*" "*/boost/*" "*/usr/*" "*/deps/*" "*/shards/mal/*" \ | |
--output-file coverage/coverage.linux.info | |
# convert absolute path to relative path | |
sed -i s/${PWD////\\/}/./g coverage/coverage.linux.info | |
- name: Upload artifact | |
uses: actions/upload-artifact@v3 | |
with: | |
name: shards-linux ${{ steps.setup.outputs.build-type }} | |
path: build/shards | |
if-no-files-found: error | |
retention-days: 1 | |
- name: Upload coverage (Debug) | |
if: ${{ steps.setup.outputs.build-type == 'Debug' }} | |
uses: actions/upload-artifact@v3 | |
with: | |
name: shards-linux-coverage | |
path: coverage/coverage.linux.info | |
if-no-files-found: error | |
retention-days: 1 |