我希望能够在 Google Cloud Build 上使用我的 GitHub 存储库运行 CI。我还有其他比这个测试更基本的存储库,它们按预期工作,也就是说,测试完成并且构建工件已正确上传到 Google Storage。
这个构建有点更具挑战性。一切似乎都工作正常,测试都成功运行,但我似乎没有生成工件,或者至少没有在日志所说的位置生成。
错误是
Step #3: CommandException: No URLs matched: /tmp/lib
。
cloudbuild.yml 文件:
steps:
# Build configuration
- name: 'us-west2-docker.pkg.dev/github-test-builds-419921/ooctest/vulkan-loader-image:latest'
entrypoint: '/bin/bash'
args:
- '-c'
- |
cmake -S. -B build \
-D CMAKE_BUILD_TYPE=Debug \
-D BUILD_TESTS=ON \
-D UPDATE_DEPS=ON \
-D LOADER_ENABLE_ADDRESS_SANITIZER=ON \
-D BUILD_WERROR=ON \
-D CMAKE_CXX_COMPILER=g++ \
-D CMAKE_C_COMPILER=gcc && \
cmake --build build
- name: 'us-west2-docker.pkg.dev/github-test-builds-419921/ooctest/vulkan-loader-image:latest'
entrypoint: '/bin/bash'
args:
- '-c'
- |
ctest --output-on-failure --test-dir build/
- name: 'us-west2-docker.pkg.dev/github-test-builds-419921/ooctest/vulkan-loader-image:latest'
entrypoint: '/bin/bash'
args:
- '-c'
- |
cmake --install build --prefix /tmp
- name: 'gcr.io/cloud-builders/gsutil'
args: ['-m', 'cp', '-r', '/tmp/lib', 'gs://test-ooc/${_ARTIFACT_NAME}/']
# This section is to specify artifacts to be stored
# artifacts:
# objects:
# location: 'gs://test-ooc/${_ARTIFACT_NAME}/'
# paths:
# - '/tmp/lib/**'
# Substitutions
options:
automapSubstitutions: true
substitutions:
_ARTIFACT_NAME: 'Vulkan-Loader-$SHORT_SHA'
用于构建镜像的 DockerFile:
FROM ubuntu:22.04
# Avoid prompts from apt
ARG DEBIAN_FRONTEND=noninteractive
# Update apt and install necessary packages
RUN apt-get update && \
apt-get upgrade -y
RUN apt-get install -y \
software-properties-common \
ca-certificates \
build-essential \
libssl-dev \
pkg-config \
git \
cmake
RUN add-apt-repository ppa:deadsnakes/ppa
RUN add-apt-repository ppa:ubuntu-toolchain-r/test
RUN apt update && \
apt install --yes python3.7 python3.7-venv python3.7-dev && \
apt install --yes clang
RUN python3.7 -m ensurepip
RUN python3.7 -m pip install --upgrade pip
RUN apt install --yes --no-install-recommends libwayland-dev libxrandr-dev && \
sysctl vm.mmap_rnd_bits=28
RUN rm -rf /var/lib/apt/lists/*
Google Cloud Build 的最后一个构建部分和错误:
Step #1: 100% tests passed, 0 tests failed out of 555
Step #1:
Step #1: Total Test time (real) = 55.32 sec
Finished Step #1
Starting Step #2
Step #2: Already have image (with digest): us-west2-docker.pkg.dev/github-test-builds-419921/ooctest/vulkan-loader-image:latest
Step #2: -- Install configuration: "Debug"
Step #2: -- Installing: /tmp/lib/libvulkan.so.1.3.280
Step #2: -- Installing: /tmp/lib/libvulkan.so.1
Step #2: -- Installing: /tmp/lib/libvulkan.so
Step #2: -- Installing: /tmp/lib/cmake/VulkanLoader/VulkanLoaderConfig.cmake
Step #2: -- Installing: /tmp/lib/cmake/VulkanLoader/VulkanLoaderConfig-debug.cmake
Step #2: -- Installing: /tmp/lib/cmake/VulkanLoader/VulkanLoaderConfigVersion.cmake
Step #2: -- Installing: /tmp/lib/pkgconfig/vulkan.pc
Finished Step #2
Starting Step #3
Step #3: Already have image (with digest): gcr.io/cloud-builders/gsutil
Step #3: CommandException: No URLs matched: /tmp/lib
Step #3: CommandException: 1 file/object could not be transferred.
Finished Step #3
ERROR
ERROR: build step 3 "gcr.io/cloud-builders/gsutil" failed: step exited with non-zero status: 1
如果我在 DigitalOcean 上创建 Ubuntu 22.04 映像并手动应用 DockerFile 构建步骤,然后拉取我制作的 Vulkan-Loader 测试存储库,最后手动运行 cloudbuilder.yml 步骤,则文件将在 /tmp/lib 中正确生成。我已经在 cloudbuild.yml 文件中添加了一些日志记录,果然,/tmp/lib 处没有
lib
目录。
我一直在寻找答案,但现在我需要一些帮助。有什么建议可能是错误的,或者如何解决这个问题?
问题似乎可能与每个构建步骤后未找到或清除 /tmp 目录有关。
您可以尝试这个 cloudbuild.yml 文件,其中包含检查 /tmp 目录是否存在的步骤:
steps:
# Build configuration
- name: 'us-west2-docker.pkg.dev/github-test-builds-419921/ooctest/vulkan-loader-image:latest'
entrypoint: '/bin/bash'
args:
- '-c'
- |
cmake -S. -B build \
-D CMAKE_BUILD_TYPE=Debug \
-D BUILD_TESTS=ON \
-D UPDATE_DEPS=ON \
-D LOADER_ENABLE_ADDRESS_SANITIZER=ON \
-D BUILD_WERROR=ON \
-D CMAKE_CXX_COMPILER=g++ \
-D CMAKE_C_COMPILER=gcc && \
cmake --build build
- name: 'us-west2-docker.pkg.dev/github-test-builds-419921/ooctest/vulkan-loader-image:latest'
entrypoint: '/bin/bash'
args:
- '-c'
- |
ctest --output-on-failure --test-dir build/
- name: 'us-west2-docker.pkg.dev/github-test-builds-419921/ooctest/vulkan-loader-image:latest'
entrypoint: '/bin/bash'
args:
- '-c'
- |
cmake --install build --prefix /tmp
- name: 'gcr.io/cloud-builders/gsutil'
args: ['-m', 'ls', '-R', '/tmp']
- name: 'gcr.io/cloud-builders/gsutil'
args: ['-m', 'cp', '-r', '/tmp/lib', 'gs://test-ooc/${_ARTIFACT_NAME}/']
# This section is to specify artifacts to be stored
# artifacts:
# objects:
# location: 'gs://test-ooc/${_ARTIFACT_NAME}/'
# paths:
# - '/tmp/lib/**'
# Substitutions
options:
automapSubstitutions: true
substitutions:
_ARTIFACT_NAME: 'Vulkan-Loader-$SHORT_SHA'
一旦您确认问题与每个构建步骤后清除 /tmp 有关,您就可以修改安装 Vulkan Loader 的构建,将其安装到每个构建步骤后未清除的其他目录。
您可以尝试此构建步骤:
- name: 'us-west2-docker.pkg.dev/github-test-builds-419921/ooctest/vulkan-loader-image:latest'
entrypoint: '/bin/bash'
args:
- '-c'
- |
cmake --install build --prefix /usr/local
然后将文件复制到 Google Cloud Storage 存储桶:
- name: 'gcr.io/cloud-builders/gsutil'
args: ['-m', 'cp', '-r', '/usr/local/lib', 'gs://test-ooc/${_ARTIFACT_NAME}/']