Skip to content

Commit 906acd3

Browse files
authored
Merge pull request #1682 from EliahKagan/run-ci/impure
Have `pure-rust-build` job find what compiles C code
2 parents 275a0c5 + f45f23e commit 906acd3

File tree

1 file changed

+42
-3
lines changed

1 file changed

+42
-3
lines changed

Diff for: .github/workflows/ci.yml

+42-3
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ jobs:
4040
apt-get update
4141
apt-get install --no-install-recommends -y -- "${prerequisites[@]}"
4242
shell: bash
43-
- name: Verify environment is sufficiently minimal for the test
43+
- name: Verify that we are in an environment with limited dev tools
4444
run: |
4545
set -x
4646
for pattern in cmake g++ libssl-dev make pkgconf pkg-config; do
@@ -55,8 +55,47 @@ jobs:
5555
done
5656
- name: Install Rust via Rustup
5757
run: curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y --profile minimal
58-
- uses: Swatinem/rust-cache@v2
59-
- run: /github/home/.cargo/bin/cargo install --debug --locked --no-default-features --features max-pure --path .
58+
- name: Add Rust tools to path
59+
run: echo "PATH=$HOME/.cargo/bin:$PATH" >> "$GITHUB_ENV"
60+
- name: Generate dependency tree
61+
run: cargo tree --locked --no-default-features --features max-pure > tree.txt
62+
- name: Scan for dependencies that build C or C++ code
63+
run: |
64+
pattern='.*\b(-sys|cc|cmake|pkg-config|vcpkg)\b.*'
65+
! GREP_COLORS='ms=30;48;5;214' grep --color=always -Ex -C 1000000 -e "$pattern" tree.txt
66+
continue-on-error: true
67+
- name: Wrap cc1 (and cc1plus if present) to record calls
68+
run: |
69+
cat >/usr/local/bin/wrapper1 <<'EOF'
70+
#!/bin/sh -e
71+
printf '%s\n' "$0 $*" |
72+
flock /run/lock/wrapper1.fbd136bd-9b1b-448d-84a9-e18be53ae63c.lock \
73+
tee -a -- /var/log/wrapper1.log ~/display >/dev/null # We'll link ~/display later.
74+
exec "$0.orig" "$@"
75+
EOF
76+
77+
cat >/usr/local/bin/wrap1 <<'EOF'
78+
#!/bin/sh -e
79+
dir="$(dirname -- "$1")"
80+
base="$(basename -- "$1")"
81+
cd -- "$dir"
82+
mv -- "$base" "$base.orig"
83+
ln -s -- /usr/local/bin/wrapper1 "$base"
84+
EOF
85+
86+
chmod +x /usr/local/bin/wrap1 /usr/local/bin/wrapper1
87+
mkdir /run/lock/wrapper1.fbd136bd-9b1b-448d-84a9-e18be53ae63c.lock
88+
89+
find /usr/lib/gcc \( -name cc1 -o -name cc1plus \) \
90+
-print -exec /usr/local/bin/wrap1 {} \;
91+
- name: Build max-pure with limited dev tools and log cc1
92+
run: |
93+
ln -s -- "/proc/$$/fd/1" ~/display # Bypass `cc1` redirection.
94+
cargo install --debug --locked --no-default-features --features max-pure --path .
95+
- name: Show logged C and C++ compilations (should be none)
96+
run: |
97+
! cat /var/log/wrapper1.log
98+
continue-on-error: true
6099

61100
test:
62101
runs-on: ubuntu-latest

0 commit comments

Comments
 (0)