Feat/ir #1115
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: "Building and testing ArkScript" | |
on: | |
push: | |
branches: [ dev, master ] | |
paths-ignore: | |
- '.github/workflows/benchmarks.yml' | |
- '.github/workflows/docker.yml' | |
- '.github/workflows/label.yml' | |
- '.github/workflows/lizard.yml' | |
- '.github/workflows/release.yml' | |
- '.vscode/*.*' | |
- 'examples/*.ark' | |
- '.github/images/*.*' | |
- '*.md' | |
- 'docs/*.*' | |
- 'Dockerfile' | |
- '.dockerignore' | |
- 'LICENCE' | |
- '.gitignore' | |
pull_request: | |
env: | |
BUILD_TYPE: Debug | |
SQLITE_VERSION: 3390100 # 3.39.1 | |
jobs: | |
check: | |
name: Formatting Check | |
runs-on: ubuntu-24.04 | |
strategy: | |
matrix: | |
path: | |
- 'src' | |
- 'include' | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Run clang-format style check for C/C++/Protobuf programs. | |
uses: jidicula/[email protected] | |
with: | |
clang-format-version: '13' | |
check-path: ${{ matrix.path }} | |
fallback-style: 'Mozilla' # optional | |
check_ark: | |
name: ArkScript formatting check | |
runs-on: ubuntu-24.04 | |
strategy: | |
fail-fast: false | |
matrix: | |
path: | |
- examples | |
- examples/games | |
- examples/games/snake | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Format check | |
uses: ArkScript-lang/action-format@master | |
with: | |
folder: ${{ matrix.path }} | |
repo_visualizer: | |
runs-on: ubuntu-24.04 | |
needs: [ check ] | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
- name: Update diagram | |
uses: githubocto/repo-visualizer@main | |
with: | |
excluded_paths: 'dist,node_modules,submodules' | |
should_push: false | |
output_file: 'diagram.svg' | |
artifact_name: 'diagram' | |
build: | |
runs-on: ${{ matrix.config.os }} | |
name: ${{ matrix.config.name }} | |
needs: [ check ] | |
strategy: | |
fail-fast: false | |
matrix: | |
config: | |
- { | |
os: ubuntu-24.04, name: "Ubuntu Clang 16", | |
compiler: clang, compiler_version: 16, sanitizers: "On", | |
artifact: "ubuntu-clang-16" | |
} | |
- { | |
os: ubuntu-24.04, name: "Ubuntu Clang 16 (valgrind)", | |
compiler: clang, compiler_version: 16, sanitizers: "Off", | |
artifact: "ubuntu-clang-valgrind" | |
} | |
- { | |
os: ubuntu-24.04, name: "Ubuntu GCC 14", | |
compiler: gcc, compiler_version: 14, sanitizers: "On", | |
artifact: "ubuntu-gcc-14" | |
} | |
- { | |
os: windows-latest, name: "Windows VS 2022", | |
compiler: msvc, compiler_version: "", sanitizers: "On", | |
artifact: "windows-msvc-22" | |
} | |
- { | |
os: macos-latest, name: "MacOS Clang 16", | |
artifact: "macos-clang-16", | |
compiler: clang, compiler_version: 16, sanitizers: "On" | |
} | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
submodules: recursive | |
- name: Setup compilers, dependencies, project and build | |
uses: ./.github/workflows/setup-compilers | |
with: | |
os_name: ${{ matrix.config.os }} | |
compiler: ${{ matrix.config.compiler }} | |
compiler_version: ${{ matrix.config.compiler_version }} | |
sanitizers: ${{ matrix.config.sanitizers }} | |
with_deps: true | |
- name: Organize files for upload | |
shell: bash | |
run: | | |
mkdir -p artifact/lib/std | |
# Linux/MacOS | |
if [[ '${{ startsWith(matrix.config.os, 'ubuntu') }}' == 'true' ]] || [[ '${{ startsWith(matrix.config.os, 'macos') }}' == 'true' ]]; then | |
cp build/arkscript artifact || true | |
cp build/libArkReactor.* artifact || true | |
fi | |
# Windows | |
if [[ '${{ startsWith(matrix.config.os, 'windows') }}' == 'true' ]]; then | |
cp build/$BUILD_TYPE/arkscript.exe artifact || true | |
cp build/$BUILD_TYPE/ArkReactor.dll artifact || true | |
fi | |
# Generic | |
cp lib/*.arkm artifact/lib | |
cp lib/std/*.ark artifact/lib/std | |
rm -rf artifact/lib/std/{.git,.github,tests/__arkscript__} | |
- name: Organize temp artifact | |
shell: bash | |
run: | | |
mkdir -p temp/tests/unittests/ | |
cp build/unittests temp/ || true | |
cp build/$BUILD_TYPE/unittests.exe temp/ || true | |
cp -r tests/unittests temp/tests/unittests | |
- name: Upload artifact | |
uses: actions/upload-artifact@v4 | |
with: | |
name: ${{ matrix.config.artifact }} | |
path: artifact | |
- name: Upload temp artifact | |
uses: actions/upload-artifact@v4 | |
with: | |
name: temp-${{ matrix.config.artifact }} | |
path: temp | |
retention-days: 1 | |
coverage: | |
runs-on: ubuntu-24.04 | |
name: Coverage | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
submodules: recursive | |
- name: Install dependencies | |
run: | | |
sudo apt-get install -yq -o Acquire::Retries=3 lcov | |
lcov --version | |
- name: Setup compilers, dependencies, project and build | |
uses: ./.github/workflows/setup-compilers | |
with: | |
os_name: ubuntu-24.04 | |
compiler: clang | |
compiler_version: 16 | |
sanitizers: On | |
coverage: On | |
with_deps: false | |
- name: Run tests | |
run: | | |
export ASAN_OPTIONS=detect_odr_violation=0 | |
./build/unittests | |
- name: Gather coverage | |
run: cmake --build build --target coverage | |
- name: Coveralls | |
uses: coverallsapp/github-action@master | |
with: | |
path-to-lcov: build/coverage.info | |
github-token: ${{ secrets.GITHUB_TOKEN }} | |
tests: | |
runs-on: ${{ matrix.config.os }} | |
name: Tests on ${{ matrix.config.name }} | |
needs: [ build ] | |
strategy: | |
fail-fast: false | |
matrix: | |
config: | |
- { os: ubuntu-24.04, name: "Ubuntu Clang 16", artifact: "ubuntu-clang-16", compiler_version: 16, } | |
- { os: ubuntu-24.04, name: "Ubuntu GCC 14", artifact: "ubuntu-gcc-14", compiler_version: 14, } | |
- { os: windows-latest, name: "Windows VS 2022", artifact: "windows-msvc-22", compiler_version: 22, } | |
- { os: macos-latest, name: "MacOS Clang 16", artifact: "macos-clang-16", compiler_version: 16, } | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
submodules: recursive | |
- name: Setup tests | |
uses: ./.github/workflows/setup-tests | |
with: | |
os_name: ${{ matrix.config.os }} | |
compiler_version: ${{ matrix.config.compiler_version }} | |
- name: Tests | |
shell: bash | |
run: | | |
export ASAN_OPTIONS=detect_odr_violation=0 | |
./unittests | |
- name: Modules tests | |
shell: bash | |
run: | | |
export ASAN_OPTIONS=detect_odr_violation=0 | |
chmod u+x ./lib/modules/.github/run-tests | |
(./lib/modules/.github/run-tests src) | |
fuzzing: | |
runs-on: ubuntu-24.04 | |
name: Fuzz testing | |
continue-on-error: true | |
container: | |
image: aflplusplus/aflplusplus:v4.20c | |
env: | |
BUILD_FOLDER: afl | |
FUZZER_SEED: 0 | |
FUZZ_TIME_SEC: 300 | |
FUZZER_TIMEOUT_EXEC_MS: 500 | |
AFL_NO_STARTUP_CALIBRATION: 1 | |
AFL_CMPLOG_ONLY_NEW: 1 | |
AFL_MAP_SIZE: 223723 | |
volumes: | |
- ${{ github.workspace }}:/src | |
options: --cpus 4 | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
submodules: recursive | |
- name: Build with AFL | |
run: | | |
cd /src | |
cmake -B${BUILD_FOLDER} \ | |
-DCMAKE_C_COMPILER=/AFLplusplus/afl-cc \ | |
-DCMAKE_CXX_COMPILER=/AFLplusplus/afl-c++ \ | |
-DCMAKE_BUILD_TYPE=Release \ | |
-DARK_BUILD_EXE=On \ | |
-DARK_SANITIZERS=On | |
cmake --build ${BUILD_FOLDER} --config Release -j 4 | |
- name: Fuzz | |
run: | | |
afl-fuzz -i tests/fuzzing/corpus-cmin-tmin \ | |
-o output \ | |
-s $FUZZER_SEED \ | |
-t $FUZZER_TIMEOUT_EXEC_MS \ | |
-V $FUZZ_TIME_SEC \ | |
-- ${BUILD_FOLDER}/arkscript @@ -L ./lib | |
- uses: 8BitJonny/[email protected] | |
id: PR | |
with: | |
sha: ${{ github.event.pull_request.head.sha }} | |
# Only return if PR is still open | |
filterOutClosed: true | |
- run: | | |
echo "PR found: ${prFound}" | |
echo "PR ${prNumber:-ERROR} ${prTitle:-NOTITLE}" | |
env: | |
# Direct access to common PR properties | |
prNumber: ${{ steps.PR.outputs.number }} | |
prTitle: ${{ steps.PR.outputs.pr_title }} | |
prFound: ${{ steps.PR.outputs.pr_found }} | |
- name: Summarize for PR | |
id: summary | |
if: steps.PR.outputs.pr_found == 'true' | |
shell: bash | |
run: | | |
echo "FUZZ_SUMMARY<<EOF" >> $GITHUB_ENV | |
afl-whatsup -s -d output >> $GITHUB_ENV | |
afl-showmap -C -i output -o /dev/null -- ./${BUILD_FOLDER}/arkscript @@ -L ./lib | sed -r "s/\x1B\[([0-9]{1,3}(;[0-9]{1,2};?)?)?[mGK]//g" | grep -v Reading | grep -v Scanning >> $GITHUB_ENV | |
echo "EOF" >> $GITHUB_ENV | |
- name: Summarize | |
if: steps.PR.outputs.pr_found == 'false' | |
shell: bash | |
run: | | |
afl-whatsup -s -d output | |
afl-showmap -C -i output -o /dev/null -- ./${BUILD_FOLDER}/arkscript @@ -L ./lib | |
- name: Find Comment | |
uses: peter-evans/find-comment@v3 | |
if: steps.PR.outputs.pr_found == 'true' | |
id: fc | |
with: | |
issue-number: ${{ github.event.pull_request.number }} | |
comment-author: 'github-actions[bot]' | |
body-includes: Fuzzing report | |
- name: Create or update comment | |
uses: peter-evans/create-or-update-comment@v4 | |
if: steps.PR.outputs.pr_found == 'true' | |
with: | |
comment-id: ${{ steps.fc.outputs.comment-id }} | |
issue-number: ${{ github.event.pull_request.number }} | |
body: | | |
## Fuzzing report | |
${{ env.FUZZ_SUMMARY }} | |
edit-mode: replace | |
- name: Sort files for upload | |
continue-on-error: true | |
run: | | |
mkdir crashes | |
cp output/default/crashes/id:* crashes/ | |
tar -czvf crashes.tar.gz crashes | |
- name: Upload crashes | |
continue-on-error: true | |
uses: actions/upload-artifact@v4 | |
with: | |
name: crashes | |
path: crashes.tar.gz | |
valgrind: | |
runs-on: ubuntu-24.04 | |
name: Ubuntu Clang Valgrind | |
needs: [ build ] | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
submodules: recursive | |
- name: Download artifact | |
id: download | |
uses: actions/download-artifact@v4 | |
with: | |
name: "ubuntu-clang-valgrind" | |
path: build | |
- name: Update LLVM compilers | |
shell: bash | |
run: | | |
mv build/lib/*.arkm lib/ | |
chmod u+x build/arkscript | |
sudo apt-get update --fix-missing | |
sudo apt-get install -y clang-16 lld-16 libc++-16-dev libc++abi-16-dev clang-tools-16 | |
- name: Install valgrind 3.20.0 | |
shell: bash | |
run: | | |
wget --no-check-certificate http://ftp.us.debian.org/debian/pool/main/v/valgrind/valgrind_3.20.0-2.1_amd64.deb | |
sudo apt remove needrestart | |
sudo apt install ./valgrind_3.20.0-2.1_amd64.deb | |
- name: Valgrind checks for memory leaks | |
shell: bash | |
run: | | |
valgrind --leak-check=full --show-leak-kinds=all \ | |
--track-origins=yes --track-fds=yes \ | |
--trace-children=yes \ | |
--verbose -s \ | |
--error-exitcode=1 \ | |
build/arkscript tests/unittests/resources/LangSuite/unittests.ark -L ./lib valgrind |