Skip to content

Commit 8325da5

Browse files
committed
Add .yml to dockerfile workflow.
Modify to be consistent with existing workflow pattern
1 parent 99c27cb commit 8325da5

2 files changed

Lines changed: 67 additions & 58 deletions

File tree

Lines changed: 43 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -1,72 +1,57 @@
1-
name: libcpp header integration
1+
name: libcpp integration
22

33
on:
44
workflow_dispatch:
55
push:
66

77
jobs:
8-
libcpp-integration-test:
8+
docker:
99
runs-on: ubuntu-latest
10-
timeout-minutes: 60
11-
1210
env:
13-
PROJECT_ROOT: ${{ github.workspace }}
11+
OUTPUT_LOCAL_DIR: libcpp-output
12+
STATUS_FILE: libcpp_status
13+
WASM_FILE_NAME: hello.wasm
1414

1515
steps:
16-
- name: Check out repository
17-
uses: actions/checkout@v4
18-
19-
- name: Show workspace info
20-
run: |
21-
echo "GITHUB_WORKSPACE=$GITHUB_WORKSPACE"
22-
pwd
23-
ls -la
24-
test -f Makefile
25-
26-
- name: Build sysroot
27-
working-directory: ${{ env.PROJECT_ROOT }}
28-
run: |
29-
make lind-boot
30-
make sysroot
31-
32-
- name: Integrate libcpp headers and libraries into sysroot
33-
working-directory: ${{ env.PROJECT_ROOT }}
34-
run: |
35-
set -euxo pipefail
36-
37-
mkdir -p build/sysroot/include/wasm32-wasi
38-
mkdir -p build/sysroot/lib/wasm32-wasi
39-
40-
cp -r artifacts/include/wasm32-wasi/. build/sysroot/include/wasm32-wasi/
41-
cp -r artifacts/lib/wasm32-wasi/. build/sysroot/lib/wasm32-wasi/
42-
43-
echo "Integrated include tree:"
44-
find build/sysroot/include/wasm32-wasi -maxdepth 2 | head -100
45-
46-
echo "Integrated lib tree:"
47-
find build/sysroot/lib/wasm32-wasi -maxdepth 2 | head -100
48-
49-
- name: Ensure compiler script is executable
50-
run: chmod +x scripts/lind_compile_cpp
51-
52-
- name: Compile C++ test to wasm
16+
- name: Set up Docker Buildx
17+
uses: docker/setup-buildx-action@4d04d5d9486b7bd6fa91e7baf45bbb4f8b9deedd
18+
19+
- name: Build libcpp integration image
20+
id: build_libcpp
21+
uses: docker/build-push-action@d08e5c354a6adb9ed34480a06d141179aa583294
22+
with:
23+
platforms: linux/amd64
24+
cache-from: type=gha
25+
cache-to: type=gha,mode=max
26+
file: Docker/Dockerfile.libcpp
27+
tags: libcpp-integration:latest
28+
outputs: type=local,dest=${{ env.OUTPUT_LOCAL_DIR }}
29+
30+
- name: Read libcpp status
31+
id: libcpp
5332
run: |
54-
set -euxo pipefail
55-
rm -f trial/*.wasm
56-
scripts/lind_compile_cpp trial/hello.cpp
33+
STATUS_PATH="${{ env.OUTPUT_LOCAL_DIR }}/${{ env.STATUS_FILE }}"
34+
echo "Checking status file at: $STATUS_PATH"
35+
if [[ -f "$STATUS_PATH" ]]; then
36+
cat "$STATUS_PATH"
37+
cat "$STATUS_PATH" >> "$GITHUB_OUTPUT"
38+
cat "$STATUS_PATH" >> "$GITHUB_ENV"
39+
else
40+
echo "LIBCPP_STATUS=fail" >> "$GITHUB_OUTPUT"
41+
echo "LIBCPP_STATUS=fail" >> "$GITHUB_ENV"
42+
echo "::warning file=$STATUS_PATH::Status file missing, defaulting to fail"
43+
fi
5744
58-
echo "Contents of trial/:"
59-
ls -la trial
45+
- name: Upload wasm artifact
46+
uses: actions/upload-artifact@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f
47+
with:
48+
name: libcpp-wasm
49+
path: ${{ env.OUTPUT_LOCAL_DIR }}/${{ env.WASM_FILE_NAME }}
50+
if-no-files-found: error
51+
retention-days: 7
6052

61-
- name: Verify wasm output exists
53+
- name: Fail if integration failed
54+
if: steps.libcpp.outputs.LIBCPP_STATUS == 'fail'
6255
run: |
63-
set -euxo pipefail
64-
65-
wasm_file="$(find trial -maxdepth 1 -type f -name '*.wasm' | head -n 1)"
66-
67-
if [ -z "$wasm_file" ]; then
68-
echo "Expected a .wasm output in trial/, but none was found."
69-
exit 1
70-
fi
71-
72-
echo "Found wasm output: $wasm_file"
56+
echo "libcpp integration test failed."
57+
exit 1

‎Docker/Dockerfile.libcpp‎

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# Reuse the same base/build logic style as Dockerfile.e2e
2+
3+
FROM base AS build-libcpp
4+
5+
COPY . .
6+
7+
RUN make sysroot
8+
9+
RUN mkdir -p build/sysroot/include/wasm32-wasi \
10+
&& mkdir -p build/sysroot/lib/wasm32-wasi \
11+
&& cp -r artifacts/include/wasm32-wasi/. build/sysroot/include/wasm32-wasi/ \
12+
&& cp -r artifacts/lib/wasm32-wasi/. build/sysroot/lib/wasm32-wasi/
13+
14+
RUN chmod +x scripts/lind_compile_cpp \
15+
&& rm -f trial/*.wasm \
16+
&& scripts/lind_compile_cpp trial/hello.cpp \
17+
&& test -n "$(find trial -maxdepth 1 -type f -name '*.wasm' | head -n 1)"
18+
19+
RUN mkdir -p /out \
20+
&& cp "$(find trial -maxdepth 1 -type f -name '*.wasm' | head -n 1)" /out/hello.wasm \
21+
&& printf '%s\n' 'LIBCPP_STATUS=pass' > /out/libcpp_status
22+
23+
FROM scratch
24+
COPY --from=build-libcpp /out/ /

0 commit comments

Comments
 (0)