Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Setup CI action to automate testing #103

Open
wants to merge 7 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
93 changes: 63 additions & 30 deletions .github/workflows/linux_thirdparty.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,39 @@ name: build-test-thirdparty
on: [push, pull_request]

jobs:
host-x86-build:
runs-on: ubuntu-latest
strategy:
matrix:
compiler: [gcc, clang]
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Install prerequisite
uses: awalsh128/cache-apt-pkgs-action@latest
with:
packages: file build-essential clang
version: 1.0
- name: Build stage 1 artifact
env:
CC: ${{ matrix.compiler }}
run: |
make clean
make slimcc
shell: bash
- name: Test stage 1
run: |
make test || exit 1
shell: bash
- name: Build stage 2 artifact
run: |
make stage2/slimcc
shell: bash
- name: Test stage 2
run: |
make test-stage2 || exit 1
shell: bash

docker:
runs-on: ubuntu-latest
steps:
Expand All @@ -29,39 +62,39 @@ jobs:

thirdparty-tests:
runs-on: ubuntu-latest
needs: docker
needs: [docker, host-x86-build]
strategy:
matrix:
include:
- thirdparty: test_cello
- thirdparty: test_curl
- thirdparty: test_doom
- thirdparty: test_git
- thirdparty: test_libpng
- thirdparty: test_libuev
- thirdparty: test_lua
- thirdparty: test_metalang99
- thirdparty: test_oniguruma_jq
- thirdparty: test_openssh
- thirdparty: test_openssl
- thirdparty: test_perl
- thirdparty: test_php
- thirdparty: test_postgres
- thirdparty: test_python
- thirdparty: test_qbe_hare
- thirdparty: test_sqlite
- thirdparty: test_tinycc
- thirdparty: test_toxcore
- thirdparty: test_toybox
- thirdparty: test_vim
- thirdparty: test_zlib
- thirdparty: test_zstd
- thirdparty: build_gcc
- thirdparty: build_musl
- thirdparty: build_nano
- thirdparty: build_sdl
thirdparty:
- test_cello
- test_curl
- test_doom
- test_git
- test_libpng
- test_libuev
- test_lua
- test_metalang99
- test_oniguruma_jq
- test_openssh
- test_openssl
- test_perl
- test_php
- test_postgres
- test_python
- test_qbe_hare
- test_sqlite
- test_tinycc
- test_toxcore
- test_toybox
- test_vim
- test_zlib
- test_zstd
- build_gcc
- build_musl
- build_nano
- build_sdl
steps:
- name: Download artifact
- name: Download debian asan artifact
uses: actions/download-artifact@v4
with:
name: debian_asan
Expand Down
23 changes: 23 additions & 0 deletions .github/workflows/weekly_csmith.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
name: weekly-csmith

on: [workflow_dispatch]
# schedule:
# - cron: '05 05 * * 2'

jobs:
run_csmith:
runs-on: ubuntu-latest
steps:
- name: Check out repository code
uses: actions/checkout@v4
- name: Get deps
run: |
sudo apt-get update
sudo apt-get install -y --no-install-recommends clang csmith libcsmith-dev
- name: Build
run: clang -Wno-switch *.c -O3 -flto=auto -march=native -fsanitize=address -o slimcc_asan
- name: Run csmith
run: |
export ASAN_OPTIONS=detect_leaks=0
mkdir csmith_run && cd "$_"
bash ../scripts/run_csmith.bash $PWD/../slimcc_asan
59 changes: 59 additions & 0 deletions scripts/run_csmith.bash
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
REFCC=clang

TSTCC=$1

EPOCH=$(date +"%s")

MAX_JOBS=4

csmith -v

for ((seed = EPOCH; seed <= $((EPOCH + 605000)); seed++)); do
if (( $(jobs -r -p | wc -l) >= MAX_JOBS )); then
wait -n
fi
(
if (( (seed % 5000) == 0 )); then
echo "heartbeat:"$seed
fi

mkdir -p $seed

csmith --no-packed-struct --seed $seed > $seed/main.c

cd $seed

$REFCC main.c -I /usr/include/csmith -lm -o ref.exe 2>/dev/null

timeout 1 ./ref.exe > ref.txt
if (( $? != 0 )); then
cd ../ && rm -r $seed
exit
fi

$TSTCC main.c -I /usr/include/csmith -lm -o tst.exe
if (( $? != 0 )); then
echo "tst cc failed at:"$seed
touch ../has_error
cd ../ && rm -r $seed
exit
fi

timeout 10 ./tst.exe > tst.txt

cmp -s ref.txt tst.txt
if (( $? != 0 )); then
echo "differ at:"$seed
touch ../has_error
fi

cd ../ && rm -r $seed
) &
done

wait

if test -f ./has_error; then
rm ./has_error
exit 1
fi