|
| 1 | +name: ci-c2rust-postprocess |
| 2 | + |
| 3 | +on: |
| 4 | + schedule: |
| 5 | + - cron: "0 4 * * *" |
| 6 | + |
| 7 | +jobs: |
| 8 | + run-testsuite: |
| 9 | + strategy: |
| 10 | + matrix: |
| 11 | + include: |
| 12 | + - runner: ubuntu-latest |
| 13 | + os: Linux |
| 14 | + arch: x86_64 |
| 15 | + clang-version: 18 |
| 16 | + - runner: ubuntu-22.04 |
| 17 | + os: Linux |
| 18 | + arch: x86_64 |
| 19 | + clang-version: 15 |
| 20 | + fail-fast: false |
| 21 | + name: "postprocess-test-and-cache (${{ matrix.runner }}: ${{ matrix.os }} ${{ matrix.arch}}, Clang ${{ matrix.clang-version }})" |
| 22 | + # The type of runner that the job will run on |
| 23 | + runs-on: ${{ matrix.runner }} |
| 24 | + |
| 25 | + env: |
| 26 | + # TODO: Remove the ident filter when we know the cronjob works |
| 27 | + C2RUST_POSTPROCESS_ARGS: >- |
| 28 | + --ident-filter '^(json_object_set_userdata|json_object_to_file)$' |
| 29 | + --cache-dir ${{ runner.temp }}/llm-cache |
| 30 | +
|
| 31 | + # Steps represent a sequence of tasks that will be executed as part of the job |
| 32 | + steps: |
| 33 | + # Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it |
| 34 | + # Working dir is /home/runner/work/c2rust/c2rust |
| 35 | + - name: Checkout c2rust |
| 36 | + uses: actions/checkout@v4 |
| 37 | + with: |
| 38 | + repository: immunant/c2rust |
| 39 | + # `update = none` is set, which makes this not work, so we need to update them manually. |
| 40 | + # See `.gitmodules` for more info. |
| 41 | + submodules: false |
| 42 | + |
| 43 | + - name: Checkout submodules |
| 44 | + run: | |
| 45 | + git submodule update --init --checkout tests/integration/tests/json-c/repo |
| 46 | +
|
| 47 | + - uses: astral-sh/setup-uv@v6 |
| 48 | + |
| 49 | + - run: uv python install |
| 50 | + |
| 51 | + - uses: Swatinem/rust-cache@v2 |
| 52 | + with: |
| 53 | + cache-workspace-crates: true |
| 54 | + |
| 55 | + - name: Install Rust toolchains |
| 56 | + run: | |
| 57 | + rustup toolchain install nightly-2022-11-03 \ |
| 58 | + --profile minimal --component rustfmt,rustc-dev |
| 59 | + rustup toolchain install nightly-2023-04-15 \ |
| 60 | + --profile minimal --component rustfmt |
| 61 | +
|
| 62 | + - name: Provision Debian Packages |
| 63 | + run: | |
| 64 | + sudo apt-get -qq update |
| 65 | + sudo apt-get -qq install \ |
| 66 | + build-essential \ |
| 67 | + libbrotli-dev \ |
| 68 | + libbz2-dev \ |
| 69 | + libclang-${{ matrix.clang-version }}-dev \ |
| 70 | + libdb-dev \ |
| 71 | + libgcrypt20 \ |
| 72 | + libgdbm-dev \ |
| 73 | + libreadline-dev \ |
| 74 | + libidn2-dev \ |
| 75 | + libldap2-dev \ |
| 76 | + liblzma-dev \ |
| 77 | + libnghttp2-dev \ |
| 78 | + libpcre3-dev \ |
| 79 | + libpsl-dev \ |
| 80 | + librtmp-dev \ |
| 81 | + libtool \ |
| 82 | + libzstd-dev \ |
| 83 | + rcs \ |
| 84 | + tcl-dev \ |
| 85 | + tk-dev \ |
| 86 | + zlib1g-dev |
| 87 | +
|
| 88 | + # Runs a single command using the runners shell |
| 89 | + # Working dir is /home/runner/work/c2rust/c2rust |
| 90 | + - name: Build c2rust |
| 91 | + env: |
| 92 | + LLVM_CONFIG_PATH: /usr/bin/llvm-config-${{ matrix.clang-version }} |
| 93 | + run: cargo build --release |
| 94 | + |
| 95 | + - name: Build tools |
| 96 | + run: | |
| 97 | + (cd tools && cargo build --release --manifest-path split_rust/Cargo.toml) |
| 98 | + (cd tools && cargo build --release --manifest-path merge_rust/Cargo.toml) |
| 99 | +
|
| 100 | + # Use separate restore/save steps so we still save the cache even if the |
| 101 | + # testsuite fails. |
| 102 | + - name: Restore postprocess cache |
| 103 | + uses: actions/cache/restore@v4 |
| 104 | + with: |
| 105 | + path: ${{ runner.temp }}/llm-cache |
| 106 | + # Restore the newest cache matching this runner/compiler prefix. |
| 107 | + key: postprocess-cache-${{ matrix.runner }}-${{ matrix.arch }}-clang-${{ matrix.clang-version }}- |
| 108 | + |
| 109 | + # Entry mtimes drive LRU pruning (see `DirectoryCache.prune`) and must |
| 110 | + # survive the tar round-trip through `actions/cache`; log the oldest |
| 111 | + # entries so this can be verified. |
| 112 | + - name: Show restored cache entry ages |
| 113 | + run: | |
| 114 | + find ${{ runner.temp }}/llm-cache -name metadata.toml -printf '%TF %p\n' 2>/dev/null | sort | head -n 20 |
| 115 | +
|
| 116 | + - name: Run c2rust testsuite |
| 117 | + env: |
| 118 | + GEMINI_API_KEY: ${{ secrets.GEMINI_API_KEY }} |
| 119 | + run: | |
| 120 | + export PATH=$PWD/target/release:$PWD/c2rust-postprocess:$HOME/.local/bin:$PATH |
| 121 | + echo "PATH=$PATH" |
| 122 | + export C2RUST_DIR=$PWD |
| 123 | + # Needs to be run from `tests/integration/` (or further inside) |
| 124 | + # to correctly load the `pyproject.toml`. |
| 125 | + (cd tests/integration && ./test.py json-c) |
| 126 | +
|
| 127 | + # Stale entries are pruned by postprocess itself (--prune-cache-days). |
| 128 | + - name: Save postprocess cache |
| 129 | + if: always() |
| 130 | + uses: actions/cache/save@v4 |
| 131 | + with: |
| 132 | + path: ${{ runner.temp }}/llm-cache |
| 133 | + # Save a fresh snapshot every run: caches are immutable, and entry |
| 134 | + # mtimes (which drive pruning) only persist via a new snapshot even |
| 135 | + # when entry contents are unchanged. Old snapshots stop being |
| 136 | + # restored and age out via GitHub's cache eviction. |
| 137 | + key: postprocess-cache-${{ matrix.runner }}-${{ matrix.arch }}-clang-${{ matrix.clang-version }}-${{ github.run_id }} |
0 commit comments