From 6b9d256ccda9c04b1a48195ea10a137910277852 Mon Sep 17 00:00:00 2001 From: Boyd Johnson Date: Sat, 13 Apr 2024 15:26:21 -0500 Subject: [PATCH 1/3] Add Dockerfiles to run tests against different clang versions --- dockerfiles/Dockerfile-bindgen | 10 ++++++++++ dockerfiles/Dockerfile-clang | 16 ++++++++++++++++ dockerfiles/README.md | 31 +++++++++++++++++++++++++++++++ 3 files changed, 57 insertions(+) create mode 100644 dockerfiles/Dockerfile-bindgen create mode 100644 dockerfiles/Dockerfile-clang create mode 100644 dockerfiles/README.md diff --git a/dockerfiles/Dockerfile-bindgen b/dockerfiles/Dockerfile-bindgen new file mode 100644 index 0000000000..09a914b6de --- /dev/null +++ b/dockerfiles/Dockerfile-bindgen @@ -0,0 +1,10 @@ +ARG LLVM_VERSION=13 + +FROM clang:${LLVM_VERSION}-ubuntu + +RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y --default-toolchain nightly + +COPY . /project +WORKDIR /project + +CMD ["/root/.cargo/bin/cargo", "test", "-p", "bindgen-tests", "--features", "__testing_only_extra_assertions"] diff --git a/dockerfiles/Dockerfile-clang b/dockerfiles/Dockerfile-clang new file mode 100644 index 0000000000..c48914f8c6 --- /dev/null +++ b/dockerfiles/Dockerfile-clang @@ -0,0 +1,16 @@ +FROM ubuntu:jammy + +ENV DEBIAN_FRONTEND noninteractive + +ARG LLVM_VERSION=13 + +RUN apt-get update && apt-get install -y \ + wget \ + curl \ + gnupg \ + build-essential \ + && wget -O - https://apt.llvm.org/llvm-snapshot.gpg.key | gpg --dearmor | tee /usr/share/keyrings/llvm-archive-keyring.gpg > /dev/null \ + && echo "deb [signed-by=/usr/share/keyrings/llvm-archive-keyring.gpg] https://apt.llvm.org/jammy/ llvm-toolchain-jammy-${LLVM_VERSION} main" > /etc/apt/sources.list.d/llvm.list \ + && apt-get update && apt-get install -y \ + clang-${LLVM_VERSION} \ + libclang-${LLVM_VERSION}-dev diff --git a/dockerfiles/README.md b/dockerfiles/README.md new file mode 100644 index 0000000000..e020ccc2e7 --- /dev/null +++ b/dockerfiles/README.md @@ -0,0 +1,31 @@ +# Dockerfiles for running cargo test on bindgen-tests + +## Dockerfile-clang + +LLVM_VERSION can be [13, 18] and correspond to the packages at [apt.llvm.org](https://apt.llvm.org/) for Ubuntu 22.04 + +From the `rust-bingen` repo, + +``` +docker build dockerfiles -f dockerfiles/Dockerfile-clang -t clang:14-ubuntu --build-arg LLVM_VERSION=14 +``` + +## Dockerfile-bindgen + +From the `rust-bindgen` repo, + +``` +docker build . -f dockerfiles/Dockerfile-bindgen -t bindgen:clang-14-ubuntu --build-arg LLVM_VERSION=14 +``` + +## Make changes to the repo happen in the docker container + +``` +docker run -v .:/project bindgen:clang-14-ubuntu +``` + +To pass an environment variable to the container + +``` +docker run -v .:/project -e BINDGEN_OVERWRITE_EXPECTED=1 bindgen:clang-14-ubuntu +``` From 460f63b69f843fe445979fc8414f5bcc270f362a Mon Sep 17 00:00:00 2001 From: Boyd Johnson Date: Sat, 13 Apr 2024 15:27:14 -0500 Subject: [PATCH 2/3] Run the Dockerfiles in GH Actions --- .github/workflows/bindgen-tests.yml | 33 +++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 .github/workflows/bindgen-tests.yml diff --git a/.github/workflows/bindgen-tests.yml b/.github/workflows/bindgen-tests.yml new file mode 100644 index 0000000000..f9a71e1c9b --- /dev/null +++ b/.github/workflows/bindgen-tests.yml @@ -0,0 +1,33 @@ +name: bindgen-tests with different versions of clang + +on: + push: + branches: + - "**" + pull_request: + branches: + - main + +jobs: + build-and-test: + runs-on: ubuntu-22.04 + strategy: + fail-fast: false + matrix: + llvm_version: [13, 14, 15, 16, 17, 18] + + steps: + - uses: actions/checkout@v4 + name: Checkout code + + - name: Build Clang Docker Image + run: | + docker build ./dockerfiles/ -f dockerfiles/Dockerfile-clang -t clang:${{ matrix.llvm_version }}-ubuntu --build-arg LLVM_VERSION=${{ matrix.llvm_version }} + + - name: Build Bindgen Docker Image + run: | + docker build . -f dockerfiles/Dockerfile-bindgen -t bindgen:clang-${{ matrix.llvm_version }}-ubuntu --build-arg LLVM_VERSION=${{ matrix.llvm_version }} + + - name: Run Tests in Docker Container + run: | + docker run bindgen:clang-${{ matrix.llvm_version }}-ubuntu From a75d4fc92834b7b2e83b4a814fdef7bf0545b521 Mon Sep 17 00:00:00 2001 From: Christian Poveda Date: Fri, 22 Nov 2024 14:48:06 -0500 Subject: [PATCH 3/3] Only run LLVM 16 and later --- .github/workflows/bindgen-tests.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/bindgen-tests.yml b/.github/workflows/bindgen-tests.yml index f9a71e1c9b..04c3a921be 100644 --- a/.github/workflows/bindgen-tests.yml +++ b/.github/workflows/bindgen-tests.yml @@ -14,7 +14,7 @@ jobs: strategy: fail-fast: false matrix: - llvm_version: [13, 14, 15, 16, 17, 18] + llvm_version: [16, 17, 18] steps: - uses: actions/checkout@v4