Skip to content

Commit e28d437

Browse files
committed
Add libcppyml, Separate e2e flow from .cpp compile test flow.
1 parent f12d33d commit e28d437

File tree

3 files changed

+129
-63
lines changed

3 files changed

+129
-63
lines changed

.github/workflows/libcpp-header-integration.yml

Lines changed: 0 additions & 57 deletions
This file was deleted.

.github/workflows/libcpp.yml

Lines changed: 120 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,120 @@
1+
name: libcpp integration
2+
3+
on:
4+
workflow_dispatch:
5+
push:
6+
7+
concurrency:
8+
group: ${{ github.workflow }}-${{ github.ref }}
9+
cancel-in-progress: true
10+
11+
jobs:
12+
docker:
13+
runs-on: ubuntu-latest
14+
env:
15+
OUTPUT_LOCAL_DIR: libcpp-output
16+
STATUS_FILE: libcpp_status
17+
WASM_FILE_NAME: hello.wasm
18+
19+
steps:
20+
- name: Set up Docker Buildx
21+
uses: docker/setup-buildx-action@4d04d5d9486b7bd6fa91e7baf45bbb4f8b9deedd
22+
23+
- name: Build libcpp integration (attempt 1)
24+
id: build_libcpp_try1
25+
continue-on-error: true
26+
uses: docker/build-push-action@d08e5c354a6adb9ed34480a06d141179aa583294
27+
with:
28+
platforms: linux/amd64
29+
cache-from: type=gha
30+
cache-to: type=gha,mode=max
31+
file: Docker/Dockerfile.e2e
32+
target: libcpp-artifacts
33+
tags: libcpp-integration:latest
34+
outputs: type=local,dest=${{ env.OUTPUT_LOCAL_DIR }}
35+
36+
- name: Backoff (after try 1)
37+
if: ${{ always() && steps.build_libcpp_try1.outcome == 'failure' }}
38+
run: sleep 15
39+
40+
- name: Build libcpp integration (attempt 2)
41+
id: build_libcpp_try2
42+
if: ${{ always() && steps.build_libcpp_try1.outcome == 'failure' }}
43+
continue-on-error: true
44+
uses: docker/build-push-action@d08e5c354a6adb9ed34480a06d141179aa583294
45+
with:
46+
platforms: linux/amd64
47+
cache-from: type=gha
48+
cache-to: type=gha,mode=max
49+
file: Docker/Dockerfile.e2e
50+
target: libcpp-artifacts
51+
tags: libcpp-integration:latest
52+
outputs: type=local,dest=${{ env.OUTPUT_LOCAL_DIR }}
53+
54+
- name: Backoff (after try 2)
55+
if: ${{ always() && steps.build_libcpp_try2.outcome == 'failure' }}
56+
run: sleep 30
57+
58+
- name: Build libcpp integration (attempt 3)
59+
id: build_libcpp_try3
60+
if: ${{ always() && steps.build_libcpp_try2.outcome == 'failure' }}
61+
continue-on-error: true
62+
uses: docker/build-push-action@d08e5c354a6adb9ed34480a06d141179aa583294
63+
with:
64+
platforms: linux/amd64
65+
cache-from: type=gha
66+
cache-to: type=gha,mode=max
67+
file: Docker/Dockerfile.e2e
68+
target: libcpp-artifacts
69+
tags: libcpp-integration:latest
70+
outputs: type=local,dest=${{ env.OUTPUT_LOCAL_DIR }}
71+
72+
- name: Fail if all build attempts failed
73+
if: ${{ always() && steps.build_libcpp_try1.outcome == 'failure' && steps.build_libcpp_try2.outcome == 'failure' && steps.build_libcpp_try3.outcome == 'failure' }}
74+
run: |
75+
echo "All libcpp build attempts failed"
76+
exit 1
77+
78+
- name: Read libcpp status
79+
id: libcpp
80+
if: ${{ always() }}
81+
shell: bash
82+
run: |
83+
STATUS_PATH="${{ env.OUTPUT_LOCAL_DIR }}/${{ env.STATUS_FILE }}"
84+
echo "Checking status file at: $STATUS_PATH"
85+
echo "----- File contents (if any) -----"
86+
if [[ -f "$STATUS_PATH" ]]; then
87+
cat "$STATUS_PATH"
88+
cat "$STATUS_PATH" >> "$GITHUB_OUTPUT"
89+
cat "$STATUS_PATH" >> "$GITHUB_ENV"
90+
else
91+
echo "(none)"
92+
echo "LIBCPP_STATUS=fail" >> "$GITHUB_OUTPUT"
93+
echo "LIBCPP_STATUS=fail" >> "$GITHUB_ENV"
94+
echo "::warning file=$STATUS_PATH::Status file missing, defaulting to fail"
95+
fi
96+
echo "----------------------------------"
97+
98+
- name: Upload wasm artifact
99+
if: ${{ always() }}
100+
uses: actions/upload-artifact@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f
101+
with:
102+
name: libcpp-wasm
103+
path: ${{ env.OUTPUT_LOCAL_DIR }}/${{ env.WASM_FILE_NAME }}
104+
if-no-files-found: error
105+
retention-days: 7
106+
107+
- name: Upload libcpp status artifact
108+
if: ${{ always() }}
109+
uses: actions/upload-artifact@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f
110+
with:
111+
name: libcpp-status
112+
path: ${{ env.OUTPUT_LOCAL_DIR }}/${{ env.STATUS_FILE }}
113+
if-no-files-found: error
114+
retention-days: 7
115+
116+
- name: Fail if libcpp integration failed
117+
if: ${{ always() && steps.libcpp.outputs.LIBCPP_STATUS == 'fail' }}
118+
run: |
119+
echo "libcpp integration failed"
120+
exit 1

Docker/Dockerfile.e2e

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,9 @@
2828
# docker run --platform=linux/amd64 -v $(PWD):/lind -w /lind -it dev /bin/bash
2929
#
3030
# Usage D (libcpp integration export):
31-
# docker build --platform=linux/amd64 -f Docker/Dockerfile.e2e --target libcpp-artifacts --output type=local,dest=libcpp-output .
31+
# docker build --platform=linux/amd64 -f Docker/Dockerfile.e2e \
32+
# --target libcpp-artifacts \
33+
# --output type=local,dest=libcpp-output .
3234

3335
# Install build dependencies
3436
# NOTE: We install dependencies for multiple stages at once, to save RUN time
@@ -95,7 +97,8 @@ ENV MATH_TEST_DIR="math_tests"
9597

9698
# --- Install libtinfo5 ---
9799
RUN wget http://security.ubuntu.com/ubuntu/pool/universe/n/ncurses/libtinfo5_6.3-2ubuntu0.1_amd64.deb && \
98-
apt install ./libtinfo5_6.3-2ubuntu0.1_amd64.deb
100+
apt install -y ./libtinfo5_6.3-2ubuntu0.1_amd64.deb && \
101+
rm -f ./libtinfo5_6.3-2ubuntu0.1_amd64.deb
99102

100103
# Install rust
101104
# --profile minimal tells rustup to install only the essentials for the toolchain
@@ -104,7 +107,7 @@ RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | \
104107
ENV PATH="/root/.cargo/bin:${PATH}"
105108

106109
# Build lind-boot
107-
FROM base as build-lind-boot
110+
FROM base AS build-lind-boot
108111
# NOTE: Using 'make' risks cache invalidation on unrelated Makefile changes
109112
COPY --parents src/lind-boot src/wasmtime src/rawposix src/cage src/threei src/typemap src/fdtables src/sysdefs Makefile rust-toolchain.toml .
110113
RUN rm -f src/wasmtime/crates/cage \
@@ -171,7 +174,7 @@ COPY --from=test /reports /reports
171174
COPY --from=test /e2e_comment.md /e2e_comment.md
172175
COPY --from=test /e2e_status /e2e_status
173176

174-
# Run libcpp header integration smoke test and export wasm + status
177+
# Run libcpp integration smoke test and export wasm + status
175178
FROM base AS libcpp-test
176179
ENV LIND_WASM_ROOT=/
177180
COPY --parents scripts tools trial artifacts Makefile .
@@ -195,12 +198,12 @@ RUN --mount=from=build-lind-boot,source=src/lind-boot/target,destination=src/lin
195198
cp -r /artifacts/lib/wasm32-wasi/. /build/sysroot/lib/wasm32-wasi/; \
196199
rm -f /trial/*.wasm; \
197200
/scripts/lind_compile_cpp /trial/hello.cpp; \
198-
wasm_file="$$(find /trial -maxdepth 1 -type f -name "*.wasm" | head -n 1)"; \
201+
wasm_file="$$(find /trial -maxdepth 1 -type f -name '\''*.wasm'\'' | head -n 1)"; \
199202
test -n "$$wasm_file"; \
200203
mkdir -p /libcpp-out; \
201204
cp "$$wasm_file" /libcpp-out/hello.wasm; \
202205
printf "%s\n" "LIBCPP_STATUS=pass" > /libcpp-out/libcpp_status \
203206
'
204207

205208
FROM scratch AS libcpp-artifacts
206-
COPY --from=libcpp-test /libcpp-out/ /
209+
COPY --from=libcpp-test /libcpp-out/ /

0 commit comments

Comments
 (0)