Skip to content

transpile: Refactor, document and correct uses of used() flag #6433

transpile: Refactor, document and correct uses of used() flag

transpile: Refactor, document and correct uses of used() flag #6433

name: c2rust-testsuite
# Controls when the action will run. Triggers the workflow on push or pull request
# events but only for the master branch
on:
push:
branches: [ master, feature/ci-dev ]
pull_request:
# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
# This workflow contains a single job called "build"
run-testsuite:
strategy:
# ci-c2rust-postprocess.yml generates postprocess caches for this matrix.
# Keep both matrices in sync so this workflow can restore those caches.
matrix:
include:
- runner: ubuntu-latest
os: Linux
arch: x86_64
clang-version: 18
- runner: ubuntu-22.04
os: Linux
arch: x86_64
clang-version: 15
fail-fast: false
name: "run-testsuite (${{ matrix.runner }}: ${{ matrix.os }} ${{ matrix.arch}}, Clang ${{ matrix.clang-version }})"
# The type of runner that the job will run on
runs-on: ${{ matrix.runner }}
# Steps represent a sequence of tasks that will be executed as part of the job
steps:
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
# Working dir is /home/runner/work/c2rust/c2rust
- name: Checkout c2rust
uses: actions/checkout@v2
with:
repository: immunant/c2rust
# `update = none` is set, which makes this not work, so we need to update them manually.
# See `.gitmodules` for more info.
submodules: false
- name: Checkout submodules
run: |
git submodule update --init --checkout tests/integration/tests/curl/repo
git submodule update --init --checkout tests/integration/tests/json-c/repo
git submodule update --init --checkout tests/integration/tests/libgit2/repo
git submodule update --init --checkout tests/integration/tests/lua/repo
git submodule update --init --checkout tests/integration/tests/nginx/repo
git submodule update --init --checkout tests/integration/tests/zstd/repo
git submodule update --init --checkout tests/integration/tests/libxml2/repo
git submodule update --init --checkout tests/integration/tests/python2/repo
git submodule update --init --checkout tests/integration/tests/libmcs/repo
- uses: astral-sh/setup-uv@v6
- run: uv python install
- uses: Swatinem/rust-cache@v2
with:
cache-workspace-crates: true
- name: Install Rust toolchains
run: |
rustup toolchain install nightly-2023-04-15 \
--profile minimal --component rustfmt,rustc-dev
- name: Provision Debian Packages
run: |
sudo apt-get -qq update
sudo apt-get -qq install \
bear \
build-essential \
cmake \
libbrotli-dev \
libbz2-dev \
libclang-${{ matrix.clang-version }}-dev \
libdb-dev \
libgcrypt20 \
libgdbm-dev \
libreadline-dev \
libidn2-dev \
libldap2-dev \
liblzma-dev \
libnghttp2-dev \
libpcre3-dev \
libpsl-dev \
librtmp-dev \
libtool \
libzstd-dev \
pkg-config \
rcs \
tcl-dev \
tk-dev \
zlib1g-dev
# Runs a single command using the runners shell
# Working dir is /home/runner/work/c2rust/c2rust
- name: Build c2rust
run: |
export LLVM_CONFIG_PATH=/usr/bin/llvm-config-${{ matrix.clang-version }}
cargo build --release
- name: Build tools
run: |
# `cd tools` to pick up `tools/rust-toolchain.toml` (stable, for `edition = "2024"`)
(cd tools && cargo build --release --manifest-path split_rust/Cargo.toml)
(cd tools && cargo build --release --manifest-path merge_rust/Cargo.toml)
- name: Restore postprocess cache
uses: actions/cache/restore@v4
with:
path: ${{ runner.temp }}/llm-cache
# Restore the newest available cache entry that matches this prefix.
key: postprocess-cache-${{ matrix.runner }}-${{ matrix.arch }}-clang-${{ matrix.clang-version }}-
- name: Run c2rust testsuite
env:
# Uses cache-only responses; skips uncached work and exercises cached
# postprocess output usage.
C2RUST_POSTPROCESS_EXTRA_ARGS: --on-error warn --cache-dir ${{ runner.temp }}/llm-cache
run: |
export PATH=$PWD/target/release:$PWD/c2rust-postprocess:$HOME/.local/bin:$PATH
echo "PATH=$PATH"
export C2RUST_DIR=$PWD
./tests/integration/test.py --refactor-jobs 1 curl json-c libgit2 lua nginx zstd libxml2 python2 libmcs
- uses: actions/upload-artifact@v4
with:
name: testsuite-${{ matrix.runner }}-artifacts
path: |
${{ github.workspace }}/tests/integration/**/*.log
${{ github.workspace }}/tests/integration/**/compile_commands.json
${{ github.workspace }}/tests/integration/tests/refactor-diffs/**
if: always()