From 18e1d9283f86ef3f5395963c65d4c153740b968d Mon Sep 17 00:00:00 2001 From: Olivier Nicole Date: Tue, 16 Jan 2024 12:12:40 +0100 Subject: [PATCH] Add TSan CI job conditioned to PR label --- .github/workflows/tsan.yml | 93 ++++++++++++++++++++++++++++++++++++++ tools/ci/actions/runner.sh | 10 +++- 2 files changed, 101 insertions(+), 2 deletions(-) create mode 100644 .github/workflows/tsan.yml diff --git a/.github/workflows/tsan.yml b/.github/workflows/tsan.yml new file mode 100644 index 0000000000..62dd9c7a7d --- /dev/null +++ b/.github/workflows/tsan.yml @@ -0,0 +1,93 @@ +# Build the compiler and run the testsuite with ThreadSanitizer, if PR is +# labelled with run-thread-sanitizer +name: Run testsuite with ThreadSanitizer +on: + pull_request: + types: [opened, synchronize, reopened, labeled, unlabeled] + +# Restrict the GITHUB_TOKEN +permissions: {} + +# https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#concurrency +# Concurrent workflows are grouped by the PR or branch that triggered them +# (github.ref) and the name of the workflow (github.workflow). The +# 'cancel-in-progress' option then make sure that only one workflow is running +# at a time. This doesn't prevent new jobs from running, rather it cancels +# already running jobs before scheduling new jobs. +concurrency: + group: ${{ github.workflow }}-${{ github.ref }}-${{ github.event_name == 'pull_request' || github.sha }} + cancel-in-progress: true + +jobs: +# This job will do the initial build of the compiler (on linux). +# We then upload the compiler tree as a build artifact to enable re-use in +# subsequent jobs. + build: + if: contains(github.event.pull_request.labels.*.name, 'run-thread-sanitizer') + runs-on: 'ubuntu-latest' + outputs: + manual_changed: ${{ steps.manual.outputs.manual_changed }} + steps: + - name: Checkout + uses: actions/checkout@v3 + with: + persist-credentials: false + - name: Install libunwind + run: sudo apt install -y libunwind-dev + - name: Configure tree + run: | + MAKE_ARG=-j CONFIG_ARG='--enable-cmm-invariants --enable-dependency-generation --enable-native-toplevel --enable-tsan --enable-ocamltest CFLAGS=-DTSAN_INSTRUMENT_ALL' OCAMLRUNPARAM=b,v=0 bash -xe tools/ci/actions/runner.sh configure + - name: Build + run: | + MAKE_ARG=-j bash -xe tools/ci/actions/runner.sh build + - name: Prepare Artifact + run: tar --zstd -cf /tmp/sources.tar.zstd . + - name: Upload Artifact + uses: actions/upload-artifact@v3 + with: + name: compiler + path: /tmp/sources.tar.zstd + retention-days: 1 + +# Testsuite run jobs: +# normal: Run the full testsuite +# debug: Run the full testsuite with the debug runtime and minor heap +# verification. + normal: + if: contains(github.event.pull_request.labels.*.name, 'run-thread-sanitizer') + name: ${{ matrix.name }} + needs: build + runs-on: ubuntu-latest + strategy: + matrix: + include: + - id: normal + name: normal + dependencies: libunwind-dev + - id: debug + name: extra (debug) + dependencies: libunwind-dev + steps: + - name: Download Artifact + uses: actions/download-artifact@v3 + with: + name: compiler + - name: Unpack Artifact + run: | + tar --zstd -xf sources.tar.zstd + rm -f sources.tar.zstd + - name: Packages + if: matrix.dependencies != '' + run: | + sudo apt-get update -y && sudo apt-get install -y ${{ matrix.dependencies }} + - name: Run the testsuite + if: matrix.id == 'normal' + run: | + TSAN_OPTIONS=history_size=6 MAKE_ARG=-j OCAMLRUNPARAM=b,v=0 bash -xe tools/ci/actions/runner.sh test_sequential + - name: Run the testsuite (debug runtime) + if: matrix.id == 'debug' + env: + OCAMLRUNPARAM: v=0,V=1 + USE_RUNTIME: d + run: | + bash -cxe "TSAN_OPTIONS=history_size=6 SHOW_TIMINGS=1 tools/ci/actions/runner.sh test_sequential" diff --git a/tools/ci/actions/runner.sh b/tools/ci/actions/runner.sh index 060b0c7563..55a0d31f4a 100755 --- a/tools/ci/actions/runner.sh +++ b/tools/ci/actions/runner.sh @@ -70,8 +70,13 @@ Build () { } Test () { - echo Running the testsuite - $MAKE -C testsuite parallel + if [ "$1" = "sequential" ]; then + echo Running the testsuite sequentially + $MAKE -C testsuite all + else + echo Running the testsuite + $MAKE -C testsuite parallel + fi cd .. } @@ -169,6 +174,7 @@ case $1 in configure) Configure;; build) Build;; test) Test;; +test_sequential) Test sequential;; test_prefix) TestPrefix $2;; api-docs) API_Docs;; install) Install;;