Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tag Linux docker images in GH Actions #17450

Merged
merged 4 commits into from
Dec 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 25 additions & 25 deletions .ci/docker/conan-tests
Original file line number Diff line number Diff line change
Expand Up @@ -9,20 +9,20 @@ ENV PY36=3.6.15 \
PY39=3.9.2 \
PY312=3.12.3 \
PY313=3.13.0 \
CMAKE_3_15_7=/usr/share/cmake-3.15.7/bin/cmake \
CMAKE_3_16_9=/usr/share/cmake-3.16.9/bin/cmake \
CMAKE_3_17_5=/usr/share/cmake-3.17.5/bin/cmake \
CMAKE_3_19_7=/usr/share/cmake-3.19.7/bin/cmake \
CMAKE_3_23_5=/usr/share/cmake-3.23.5/bin/cmake \
CMAKE_3_15=/usr/share/cmake-3.15.7/bin/cmake \
CMAKE_3_16=/usr/share/cmake-3.16.9/bin/cmake \
CMAKE_3_17=/usr/share/cmake-3.17.5/bin/cmake \
CMAKE_3_19=/usr/share/cmake-3.19.7/bin/cmake \
CMAKE_3_23=/usr/share/cmake-3.23.5/bin/cmake \
GCC_9=/usr/bin/gcc-9 \
GXX_9=/usr/bin/g++-9 \
GCC_11=/usr/bin/gcc-11 \
GXX_11=/usr/bin/g++-11 \
CLANG_14=/usr/bin/clang-14 \
CLANGXX_14=/usr/bin/clang++-14 \
BAZEL_6_5_0=6.5.0 \
BAZEL_7_4_1=7.4.1 \
BAZEL_8_0_0=8.0.0
BAZEL_6=6.5.0 \
BAZEL_7=7.4.1 \
BAZEL_8=8.0.0

RUN apt-get update && \
apt-get install -y --no-install-recommends \
Expand Down Expand Up @@ -115,11 +115,11 @@ RUN wget https://github.com/Kitware/CMake/releases/download/v3.15.7/cmake-3.15.7
tar -xvzf cmake-3.19.7-Linux-x86_64.tar.gz && mv cmake-3.19.7-Linux-x86_64 /usr/share/cmake-3.19.7 && \
wget https://github.com/Kitware/CMake/releases/download/v3.23.5/cmake-3.23.5-Linux-x86_64.tar.gz && \
tar -xvzf cmake-3.23.5-Linux-x86_64.tar.gz && mv cmake-3.23.5-linux-x86_64/ /usr/share/cmake-3.23.5 && \
update-alternatives --install /usr/bin/cmake cmake $CMAKE_3_15_7 10 && \
update-alternatives --install /usr/bin/cmake cmake $CMAKE_3_16_9 20 && \
update-alternatives --install /usr/bin/cmake cmake $CMAKE_3_17_5 30 && \
update-alternatives --install /usr/bin/cmake cmake $CMAKE_3_19_7 40 && \
update-alternatives --install /usr/bin/cmake cmake $CMAKE_3_23_5 50
update-alternatives --install /usr/bin/cmake cmake $CMAKE_3_15 10 && \
update-alternatives --install /usr/bin/cmake cmake $CMAKE_3_16 20 && \
update-alternatives --install /usr/bin/cmake cmake $CMAKE_3_17 30 && \
update-alternatives --install /usr/bin/cmake cmake $CMAKE_3_19 40 && \
update-alternatives --install /usr/bin/cmake cmake $CMAKE_3_23 50

RUN update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-9 10 && \
update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-11 30 && \
Expand All @@ -132,18 +132,18 @@ RUN update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-9 10 && \
update-alternatives --set clang /usr/bin/clang-14 && \
update-alternatives --set clang++ /usr/bin/clang++-14

RUN mkdir -p /usr/share/bazel-$BAZEL_6_5_0/bin && \
wget https://github.com/bazelbuild/bazel/releases/download/${BAZEL_6_5_0}/bazel-${BAZEL_6_5_0}-linux-x86_64 && \
chmod +x bazel-${BAZEL_6_5_0}-linux-x86_64 && \
mv bazel-${BAZEL_6_5_0}-linux-x86_64 /usr/share/bazel-$BAZEL_6_5_0/bin/bazel && \
mkdir -p /usr/share/bazel-$BAZEL_7_4_1/bin && \
wget https://github.com/bazelbuild/bazel/releases/download/${BAZEL_7_4_1}/bazel-${BAZEL_7_4_1}-linux-x86_64 && \
chmod +x bazel-${BAZEL_7_4_1}-linux-x86_64 && \
mv bazel-${BAZEL_7_4_1}-linux-x86_64 /usr/share/bazel-$BAZEL_7_4_1/bin/bazel && \
mkdir -p /usr/share/bazel-$BAZEL_8_0_0/bin && \
wget https://github.com/bazelbuild/bazel/releases/download/${BAZEL_8_0_0}/bazel-${BAZEL_8_0_0}-linux-x86_64 && \
chmod +x bazel-${BAZEL_8_0_0}-linux-x86_64 && \
mv bazel-${BAZEL_8_0_0}-linux-x86_64 /usr/share/bazel-$BAZEL_8_0_0/bin/bazel
RUN mkdir -p /usr/share/bazel-$BAZEL_6/bin && \
wget https://github.com/bazelbuild/bazel/releases/download/${BAZEL_6}/bazel-${BAZEL_6}-linux-x86_64 && \
chmod +x bazel-${BAZEL_6}-linux-x86_64 && \
mv bazel-${BAZEL_6}-linux-x86_64 /usr/share/bazel-$BAZEL_6/bin/bazel && \
mkdir -p /usr/share/bazel-$BAZEL_7/bin && \
wget https://github.com/bazelbuild/bazel/releases/download/${BAZEL_7}/bazel-${BAZEL_7}-linux-x86_64 && \
chmod +x bazel-${BAZEL_7}-linux-x86_64 && \
mv bazel-${BAZEL_7}-linux-x86_64 /usr/share/bazel-$BAZEL_7/bin/bazel && \
mkdir -p /usr/share/bazel-$BAZEL_8/bin && \
wget https://github.com/bazelbuild/bazel/releases/download/${BAZEL_8}/bazel-${BAZEL_8}-linux-x86_64 && \
chmod +x bazel-${BAZEL_8}-linux-x86_64 && \
mv bazel-${BAZEL_8}-linux-x86_64 /usr/share/bazel-$BAZEL_8/bin/bazel


USER conan
Expand Down
41 changes: 17 additions & 24 deletions .github/workflows/linux-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ concurrency:
jobs:
build_container:
runs-on: ubuntu-latest
name: Build and Publish Docker Image for testing Conan
outputs:
image_tag: ${{ steps.dockerfile_hash.outputs.tag }}
steps:
- name: Checkout code
uses: actions/checkout@v4
Expand All @@ -34,37 +35,28 @@ jobs:
id: dockerfile_hash
run: |
DOCKERFILE_HASH=$(find ./.ci/docker/conan-tests -type f -exec sha256sum {} \; | sha256sum | cut -d' ' -f1)
echo "hash=$DOCKERFILE_HASH" >> $GITHUB_OUTPUT
echo "tag=$DOCKERFILE_HASH" >> $GITHUB_OUTPUT

- name: Cache Docker image
id: cache_docker_image
uses: actions/cache@v4
with:
path: docker_image_cache
key: ${{ runner.os }}-docker-${{ steps.dockerfile_hash.outputs.hash }}

- name: Load Docker image from cache
if: steps.cache_docker_image.outputs.cache-hit == 'true'
run: docker load -i docker_image_cache/conan-tests.tar

- name: Build Docker image (if not cached)
if: steps.cache_docker_image.outputs.cache-hit != 'true'
- name: Check if image exists
id: check_image
run: |
docker build \
-t ghcr.io/${{ github.repository_owner }}/conan-tests:latest \
-f ./.ci/docker/conan-tests .
mkdir -p docker_image_cache
docker save ghcr.io/${{ github.repository_owner }}/conan-tests:latest -o docker_image_cache/conan-tests.tar
if docker manifest inspect ghcr.io/${{ github.repository_owner }}/conan-tests:${{ steps.dockerfile_hash.outputs.tag }} > /dev/null 2>&1; then
echo "status=exists" >> $GITHUB_OUTPUT
else
echo "status=no-image" >> $GITHUB_OUTPUT
fi

- name: Push Docker image to GHCR
if: steps.cache_docker_image.outputs.cache-hit != 'true'
run: docker push ghcr.io/${{ github.repository_owner }}/conan-tests:latest
- name: Build and push image if not exists
if: steps.check_image.outputs.status == 'no-image'
run: |
docker build -t ghcr.io/${{ github.repository_owner }}/conan-tests:${{ steps.dockerfile_hash.outputs.tag }} -f ./.ci/docker/conan-tests .
docker push ghcr.io/${{ github.repository_owner }}/conan-tests:${{ steps.dockerfile_hash.outputs.tag }}

linux_test_suite:
needs: build_container
runs-on: ubuntu-latest
container:
image: ghcr.io/${{ github.repository_owner }}/conan-tests:latest
image: ghcr.io/${{ github.repository_owner }}/conan-tests:${{ needs.build_container.outputs.image_tag }}
options: --user conan
strategy:
matrix:
Expand Down Expand Up @@ -106,6 +98,7 @@ jobs:
fi

linux_docker_tests:
needs: build_container
runs-on: ubuntu-latest
name: Docker Runner Tests
strategy:
Expand Down
Loading