Skip to content

Commit e1e488e

Browse files
committed
Run test within Dockerfile
1 parent 54fa877 commit e1e488e

File tree

11 files changed

+61
-26
lines changed

11 files changed

+61
-26
lines changed

.github/workflows/debian.yml

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,8 @@ jobs:
104104
GCOVR_VERSION=${{ env.GCOVR_VERSION }}
105105
NONROOT_USER=${{ env.NONROOT_USER }}
106106
DEBIAN_VERSION=${{ matrix.os.release }}
107-
context: docker/debian
107+
context: .
108+
file: docker/debian/Dockerfile
108109
outputs: type=image,name=${{ env.CONTAINER_IMAGE }},push-by-digest=true,name-canonical=true,push=true
109110
platforms: ${{ matrix.architecture.platform }}
110111
provenance: mode=max
@@ -113,10 +114,6 @@ jobs:
113114
labels: ${{ steps.meta.outputs.labels }}
114115
target: ${{ matrix.os.compiler_name }}
115116
tags: ${{ env.CONTAINER_IMAGE }}
116-
- name: Test the Docker image
117-
if: ${{ github.ref_type == 'branch' && github.ref_name != github.event.repository.default_branch }}
118-
run: |
119-
docker run --rm -v ${{ github.workspace }}/test:/tmp:ro ${{ env.CONTAINER_IMAGE }} /tmp/run.sh
120117
- name: Export digest
121118
if: ${{ github.ref_type == 'branch' && github.ref_name == github.event.repository.default_branch }}
122119
shell: bash

.github/workflows/rhel.yml

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,8 @@ jobs:
9494
GCOVR_VERSION=${{ env.GCOVR_VERSION }}
9595
NONROOT_USER=${{ env.NONROOT_USER }}
9696
RHEL_VERSION=${{ matrix.os.release }}
97-
context: docker/rhel
97+
context: .
98+
file: docker/rhel/Dockerfile
9899
outputs: type=image,name=${{ env.CONTAINER_IMAGE }},push-by-digest=true,name-canonical=true,push=true
99100
platforms: ${{ matrix.architecture.platform }}
100101
provenance: mode=max
@@ -103,10 +104,6 @@ jobs:
103104
labels: ${{ steps.meta.outputs.labels }}
104105
target: ${{ matrix.os.compiler_name }}
105106
tags: ${{ env.CONTAINER_IMAGE }}
106-
- name: Test the Docker image
107-
if: ${{ github.ref_type == 'branch' && github.ref_name != github.event.repository.default_branch }}
108-
run: |
109-
docker run --rm -v ${{ github.workspace }}/test:/tmp:ro ${{ env.CONTAINER_IMAGE }} /tmp/run.sh
110107
- name: Export digest
111108
if: ${{ github.ref_type == 'branch' && github.ref_name == github.event.repository.default_branch }}
112109
shell: bash

.github/workflows/ubuntu.yml

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,8 @@ jobs:
102102
GCOVR_VERSION=${{ env.GCOVR_VERSION }}
103103
NONROOT_USER=${{ env.NONROOT_USER }}
104104
UBUNTU_VERSION=${{ matrix.os.release }}
105-
context: docker/ubuntu
105+
context: .
106+
file: docker/ubuntu/Dockerfile
106107
outputs: type=image,name=${{ env.CONTAINER_IMAGE }},push-by-digest=true,name-canonical=true,push=true
107108
platforms: ${{ matrix.architecture.platform }}
108109
provenance: mode=max
@@ -111,10 +112,6 @@ jobs:
111112
labels: ${{ steps.meta.outputs.labels }}
112113
target: ${{ matrix.os.compiler_name }}
113114
tags: ${{ env.CONTAINER_IMAGE }}
114-
- name: Test the Docker image
115-
if: ${{ github.ref_type == 'branch' && github.ref_name != github.event.repository.default_branch }}
116-
run: |
117-
docker run --rm -v ${{ github.workspace }}/test:/tmp:ro ${{ env.CONTAINER_IMAGE }} /tmp/run.sh
118115
- name: Export digest
119116
if: ${{ github.ref_type == 'branch' && github.ref_name == github.event.repository.default_branch }}
120117
shell: bash

docker/debian/Dockerfile

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,13 @@ EOF
115115
# Print the Conan profile to verify the configuration.
116116
RUN conan profile show
117117

118+
# Test the image by compiling a simple C++ program.
119+
RUN --mount=type=bind,source=test,target=/test,readonly <<EOF
120+
cp -r /test test
121+
cd test && ./run.sh && cd ..
122+
rm -rf test
123+
EOF
124+
118125
# ===================== CLANG IMAGE =====================
119126
FROM base AS clang
120127

@@ -165,3 +172,10 @@ fi
165172
EOF
166173
# Print the Conan profile to verify the configuration.
167174
RUN conan profile show
175+
176+
# Test the image by compiling a simple C++ program.
177+
RUN --mount=type=bind,source=test,target=/test,readonly <<EOF
178+
cp -r /test test
179+
cd test && ./run.sh && cd ..
180+
rm -rf test
181+
EOF

docker/debian/README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ versions by specifying the `DEBIAN_VERSION` build argument. There are additional
2929
arguments to specify as well, namely `GCC_VERSION` for the GCC flavor and
3030
`CLANG_VERSION` for the Clang flavor.
3131

32-
Run the commands below from the current directory containing the Dockerfile.
32+
Run the commands below from the root directory of the repository.
3333

3434
#### Building the Docker image for GCC.
3535

@@ -45,6 +45,7 @@ GCOVR_VERSION=8.3
4545
CONTAINER_IMAGE=xrplf/ci/debian-${DEBIAN_VERSION}:gcc-${GCC_VERSION}
4646

4747
docker buildx build . \
48+
--file docker/debian/Dockerfile \
4849
--target gcc \
4950
--build-arg BUILDKIT_DOCKERFILE_CHECK=skip=InvalidDefaultArgInFrom \
5051
--build-arg BUILDKIT_INLINE_CACHE=1 \
@@ -70,6 +71,7 @@ GCOVR_VERSION=8.3
7071
CONTAINER_IMAGE=xrplf/ci/debian-${DEBIAN_VERSION}:clang-${CLANG_VERSION}
7172

7273
docker buildx build . \
74+
--file docker/debian/Dockerfile \
7375
--target clang \
7476
--build-arg BUILDKIT_DOCKERFILE_CHECK=skip=InvalidDefaultArgInFrom \
7577
--build-arg BUILDKIT_INLINE_CACHE=1 \

docker/rhel/Dockerfile

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,13 @@ EOF
8686
# Print the Conan profile to verify the configuration.
8787
RUN conan profile show
8888

89+
# Test the image by compiling a simple C++ program.
90+
RUN --mount=type=bind,source=test,target=/test,readonly <<EOF
91+
cp -r /test test
92+
cd test && ./run.sh && cd ..
93+
rm -rf test
94+
EOF
95+
8996
# ===================== CLANG IMAGE =====================
9097
FROM base AS clang
9198

@@ -132,3 +139,10 @@ fi
132139
EOF
133140
# Print the Conan profile to verify the configuration.
134141
RUN conan profile show
142+
143+
# Test the image by compiling a simple C++ program.
144+
RUN --mount=type=bind,source=test,target=/test,readonly <<EOF
145+
cp -r /test test
146+
cd test && ./run.sh && cd ..
147+
rm -rf test
148+
EOF

docker/rhel/README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ versions by specifying the `RHEL_VERSION` build argument. There are additional
4848
arguments to specify as well, namely `GCC_VERSION` for the GCC flavor and
4949
`CLANG_VERSION` for the Clang flavor.
5050

51-
Run the commands below from the current directory containing the Dockerfile.
51+
Run the commands below from the root directory of the repository.
5252

5353
#### Building the Docker image for GCC.
5454

@@ -64,6 +64,7 @@ GCOVR_VERSION=8.3
6464
CONTAINER_IMAGE=xrplf/ci/rhel-${RHEL_VERSION}:gcc-${GCC_VERSION}
6565

6666
docker buildx build . \
67+
--file docker/rhel/Dockerfile \
6768
--target gcc \
6869
--build-arg BUILDKIT_DOCKERFILE_CHECK=skip=InvalidDefaultArgInFrom \
6970
--build-arg BUILDKIT_INLINE_CACHE=1 \
@@ -88,6 +89,7 @@ GCOVR_VERSION=8.3
8889
CONTAINER_IMAGE=xrplf/ci/rhel-${RHEL_VERSION}:clang-${CLANG_VERSION}
8990

9091
docker buildx build . \
92+
--file docker/rhel/Dockerfile \
9193
--target clang \
9294
--build-arg BUILDKIT_DOCKERFILE_CHECK=skip=InvalidDefaultArgInFrom \
9395
--build-arg BUILDKIT_INLINE_CACHE=1 \

docker/ubuntu/Dockerfile

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,13 @@ EOF
109109
# Print the Conan profile to verify the configuration.
110110
RUN conan profile show
111111

112+
# Test the image by compiling a simple C++ program.
113+
RUN --mount=type=bind,source=test,target=/test,readonly <<EOF
114+
cp -r /test test
115+
cd test && ./run.sh && cd ..
116+
rm -rf test
117+
EOF
118+
112119
# ===================== CLANG IMAGE =====================
113120
FROM base AS clang
114121

@@ -154,3 +161,10 @@ fi
154161
EOF
155162
# Print the Conan profile to verify the configuration.
156163
RUN conan profile show
164+
165+
# Test the image by compiling a simple C++ program.
166+
RUN --mount=type=bind,source=test,target=/test,readonly <<EOF
167+
cp -r /test test
168+
cd test && ./run.sh && cd ..
169+
rm -rf test
170+
EOF

docker/ubuntu/README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ future versions by specifying the `UBUNTU_VERSION` build argument. There are
2929
additional arguments to specify as well, namely `GCC_VERSION` for the GCC flavor
3030
and `CLANG_VERSION` for the Clang flavor.
3131

32-
Run the commands below from the current directory containing the Dockerfile.
32+
Run the commands below from the root directory of the repository.
3333

3434
#### Building the Docker image for GCC.
3535

@@ -45,6 +45,7 @@ GCOVR_VERSION=8.3
4545
CONTAINER_IMAGE=xrplf/ci/ubuntu-${UBUNTU_VERSION}:gcc-${GCC_VERSION}
4646

4747
docker buildx build . \
48+
--file docker/ubuntu/Dockerfile \
4849
--target gcc \
4950
--build-arg BUILDKIT_DOCKERFILE_CHECK=skip=InvalidDefaultArgInFrom \
5051
--build-arg BUILDKIT_INLINE_CACHE=1 \
@@ -70,6 +71,7 @@ GCOVR_VERSION=8.3
7071
CONTAINER_IMAGE=xrplf/ci/ubuntu-${UBUNTU_VERSION}:clang-${CLANG_VERSION}
7172

7273
docker buildx build . \
74+
--file docker/ubuntu/Dockerfile \
7375
--target clang \
7476
--build-arg BUILDKIT_DOCKERFILE_CHECK=skip=InvalidDefaultArgInFrom \
7577
--build-arg BUILDKIT_INLINE_CACHE=1 \

test/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
cmake_minimum_required(VERSION 3.15)
2-
project(compressor C)
2+
project(example C)
33

44
find_package(ZLIB REQUIRED)
55

0 commit comments

Comments
 (0)