From fc49735fda968e64ef4d538731440a767d09146c Mon Sep 17 00:00:00 2001 From: Dhruv Makwana Date: Fri, 1 Nov 2024 17:28:49 +0000 Subject: [PATCH] Add CI build and test --- .github/workflows/ci.yml | 62 +++++++++++++++++++ c-tree-carver.opam | 2 +- conf-libclang-12-dev.opam | 6 +- conf-libclang-12-dev.opam.template | 6 +- dune-project | 8 +-- files/configure.sh | 98 ------------------------------ 6 files changed, 73 insertions(+), 109 deletions(-) create mode 100644 .github/workflows/ci.yml delete mode 100644 files/configure.sh diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..430a38b --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,62 @@ +name: CI + +on: + pull_request: + push: + branches: + - main + - cheri-tests + +# cancel in-progress job when a new push is performed +concurrency: + group: ci-${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + +jobs: + build: + strategy: + matrix: + version: [4.14.1] + + + runs-on: ubuntu-22.04 + + steps: + - uses: actions/checkout@v3 + + - name: System dependencies (ubuntu) + run: | + sudo apt-get install opam python3 clang-15 opam libclang-15-dev llvm-15-dev + + - name: Restore cached opam + id: cache-opam-restore + uses: actions/cache/restore@v4 + with: + path: ~/.opam + key: ${{ matrix.version }} + + - name: Setup opam + if: steps.cache-opam-restore.outputs.cache-hit != 'true' + run: | + opam init --yes --no-setup --shell=sh --compiler=${{ matrix.version }} + opam install --with-test --deps-only --yes . + + - name: Save cached opam + if: steps.cache-opam-restore.outputs.cache-hit != 'true' + id: cache-opam-save + uses: actions/cache/save@v4 + with: + path: ~/.opam + key: ${{ steps.cache-opam-restore.outputs.cache-primary-key }} + + - name: Install c-tree-carver + run: | + opam switch ${{ matrix.version }} + eval $(opam env --switch=${{ matrix.version }}) + opam install --yes . + + - name: Run CI tests + run: | + opam switch ${{ matrix.version }} + eval $(opam env --switch=${{ matrix.version }}) + dune runtest && cd cpp && ./test/run_test.py make && ./test/run_test.py for diff --git a/c-tree-carver.opam b/c-tree-carver.opam index b8059f9..c245f5c 100644 --- a/c-tree-carver.opam +++ b/c-tree-carver.opam @@ -14,7 +14,7 @@ depends: [ "conf-c++" "conf-cmake" {dev} "conf-llvm" {= "12.0.1"} - "conf-python3" {with-test} + "conf-python-3" {with-test} "fileutils" {>= "0.6.4"} "shexp" {>= "v0.15.0"} "ocamlformat" {>= "0.25.1" & dev} diff --git a/conf-libclang-12-dev.opam b/conf-libclang-12-dev.opam index 014036f..e431a02 100644 --- a/conf-libclang-12-dev.opam +++ b/conf-libclang-12-dev.opam @@ -18,11 +18,11 @@ depends: [ "conf-bash" {build} ] depexts: [ - ["libclang-12-dev"] {os-family = "debian"} + ["libclang-15-dev"] {os-family = "debian"} ] extra-files: [[ "configure.sh" "sha512=f7f3bedd554da272d3a14d631481bfed0fecce52054cd35fedf41a4493bcc7973fc28abeb305755fb546927785a6f69d1cf2d15b306da35777b471d2bc770864" ]] -synopsis: "Virtual package relying on libclang-12-dev library" -description: "This package can only install if the libclang-12-dev library is installed on the system." +synopsis: "Virtual package relying on libclang-15-dev library" +description: "This package can only install if the libclang-15-dev library is installed on the system." flags: conf diff --git a/conf-libclang-12-dev.opam.template b/conf-libclang-12-dev.opam.template index 88023ed..da5817d 100644 --- a/conf-libclang-12-dev.opam.template +++ b/conf-libclang-12-dev.opam.template @@ -16,11 +16,11 @@ depends: [ "conf-bash" {build} ] depexts: [ - ["libclang-12-dev"] {os-family = "debian"} + ["libclang-15-dev"] {os-family = "debian"} ] extra-files: [[ "configure.sh" "sha512=f7f3bedd554da272d3a14d631481bfed0fecce52054cd35fedf41a4493bcc7973fc28abeb305755fb546927785a6f69d1cf2d15b306da35777b471d2bc770864" ]] -synopsis: "Virtual package relying on libclang-12-dev library" -description: "This package can only install if the libclang-12-dev library is installed on the system." +synopsis: "Virtual package relying on libclang-15-dev library" +description: "This package can only install if the libclang-15-dev library is installed on the system." flags: conf diff --git a/dune-project b/dune-project index a879e20..2eec4a0 100644 --- a/dune-project +++ b/dune-project @@ -20,11 +20,11 @@ (synopsis "Clang-based tool for tree-carving C source trees") (description "") (depends - (ocaml (>= 4.12.0)) + (ocaml (>= 4.14.1)) conf-c++ (conf-cmake :dev) - (conf-llvm (= 12.0.1)) - (conf-python3 :with-test) + (conf-llvm (= 15.0.7)) + (conf-python-3 :with-test) (fileutils (>= 0.6.4)) (shexp (>= v0.15.0)) (ocamlformat (and (>= 0.25.1) :dev)) @@ -35,7 +35,7 @@ (topics c clang tool tree-carving))) (package - (name conf-libclang-12-dev) + (name conf-libclang-15-dev) (allow_empty)) diff --git a/files/configure.sh b/files/configure.sh deleted file mode 100644 index 5273c67..0000000 --- a/files/configure.sh +++ /dev/null @@ -1,98 +0,0 @@ -#!/bin/bash -ex - -# Adapted from https://github.com/ocaml/opam-repository/blob/master/packages/conf-libclang/conf-libclang.12/files/configure.sh - -clean_tempdir () { - rm -f "$tempdir/test_libclang.c" "$tempdir/test_libclang.o" \ - "$tempdir/test_libclang" - rmdir "$tempdir" -} - -shopt -s nullglob -for version in default 12; do - if [ "$version" = default ]; then - llvm_config=llvm-config - llvm_version="$($llvm_config --version)" || continue - if [ $(printf "${llvm_version%%.*}\n13" | sort -n | head -n1) = 13 ]; then - continue - fi - else - if hash brew 2>/dev/null; then - brew_llvm_config="$(brew --cellar)"/llvm*/${version}*/bin/llvm-config - fi - for llvm_config in \ - llvm-config-${version} llvm-config-${version}.0 \ - llvm-config${version}0 llvm-config${version} \ - llvm-config-${version}-32 llvm-config-${version}-64 \ - llvm-config-mp-$version \ - llvm-config-mp-${version}.0 $brew_llvm_config \ - /usr/lib64/llvm/${version}/bin/llvm-config \ - /usr/lib/llvm/${version}/bin/llvm-config; do - llvm_version="$($llvm_config --version)" || continue - break - done - if [ -z "$llvm_version" ]; then - continue - fi - fi - - if [ "$llvm_version" = "12.0.1" ]; then - clangml440_configure_options="--with-llvm-version=12.0.0" # clangml.4.4.0 does not recognize 12.0.1 - else - clangml440_configure_options="" # rely on clangml's ./configure autodetection - fi - - LLVM_CFLAGS="$($llvm_config --cflags)" - LLVM_LDFLAGS="$($llvm_config --ldflags)" - LLVM_LIBDIR="$($llvm_config --libdir)" - - # These filters enable compilation with gcc. - # Filter -Wstring-conversion for OpenSUSE - LLVM_CFLAGS="$(echo $LLVM_CFLAGS | sed 's/-Wstring-conversion //')" - - # Filter -Werror=unguarded-availability-new and -Wcovered-switch-default - # (which appear with LLVM 7) - LLVM_CFLAGS="$(echo $LLVM_CFLAGS | sed 's/-Werror=unguarded-availability-new //')" - LLVM_CFLAGS="$(echo $LLVM_CFLAGS | sed 's/-Wcovered-switch-default //')" - - # Filter "-Wdelete-non-virtual-dtor" (warning only) - LLVM_CFLAGS="$(echo $LLVM_CFLAGS | sed 's/-Wdelete-non-virtual-dtor //')" - - tempdir="$(mktemp -d)" - cat >"$tempdir/test_libclang.c" < -#include - -int -main(int argc, char *argv[]) -{ - CXIndex idx = clang_createIndex(1, 1); - clang_disposeIndex(idx); - return EXIT_SUCCESS; -} -EOF - - CC=cc - if "$CC" -o "$tempdir/test_libclang.o" -c $LLVM_CFLAGS \ - "$tempdir/test_libclang.c" && - "$CC" -o "$tempdir/test_libclang" \ - $LLVM_LDFLAGS "$tempdir/test_libclang.o" \ - "-lclang" "-Wl,-rpath,$LLVM_LIBDIR" && - "$tempdir/test_libclang"; then - true - else - clean_tempdir - continue - fi - - clean_tempdir - - echo "config: \"$llvm_config\"" >> conf-libclang.config - echo "version: \"$llvm_version\"" >> conf-libclang.config - echo "clangml440_configure_options: \"$clangml440_configure_options\"" >> conf-libclang.config - exit 0 -done - -echo "Error: No usable version of LLVM <=12.0.x found." -exit 1 -