当我的项目作业在Gitlab管道中运行时,在测试作业结束时,即使所有单元测试都很好,作业也会失败。
我不明白为什么以下是我的项目的架构:
.gitlab-ci.yml
cache:
paths:
- node_modules
- dist
default:
image: node:lts
stages:
- build
- test
build:
stage: build
before_script:
- bash ci/build/build_tools_install.sh
script:
- bash ci/build/build_app.sh
tests:
stage: test
variables:
CI: "true"
before_script:
- bash ci/tests/tests_tools_install.sh
script:
- bash ci/tests/tests_run.sh
字符串
测试工具安装.sh
#!/bin/bash
# Display debug in console
set -xe
# Library to control Chrome, it contains Chrome
npm install puppeteer@18.0.0
# Add system libraries needed to start Chrome in Headless mode
apt update -yqq
apt install -yqq gconf-service libasound2 libatk1.0-0 libatk-bridge2.0-0 libc6 libcairo2 libcups2 libdbus-1-3 libexpat1 libfontconfig1 libgcc1 libgconf-2-4 libgdk-pixbuf2.0-0 libglib2.0-0 libgtk-3-0 libnspr4 libpango-1.0-0 libpangocairo-1.0-0 libstdc++6 libx11-6 libx11-xcb1 libxcb1 libxcomposite1 libxcursor1 libxdamage1 libxext6 libxfixes3 libxi6 libxrandr2 libxrender1 libxss1 libxtst6 ca-certificates fonts-liberation libappindicator1 libnss3 lsb-release xdg-utils wget
型
测试运行.sh
#!/bin/bash=
# Display debug in console
set -xe
# Set the CHROME_BIN variable to point to the Chrome binary
export CHROME_BIN=`find $CI_PROJECT_DIR/node_modules/puppeteer -name "chrome"`
# Start Angular tests using locally installed Angular CLI
node_modules/.bin/ng test --code-coverage=false --watch=false
型
Gitlab测试作业控制台结果
04 07 2023 17:17:38.656:INFO [launcher]: Launching browsers ChromeHeadlessNoSandbox with concurrency unlimited
04 07 2023 17:17:38.659:INFO [launcher]: Starting browser ChromeHeadless
04 07 2023 17:17:38.907:INFO [Chrome Headless 106.0.5249.0 (Linux x86_64)]: Connected on socket uFBxUufDl-2onOYIAAAB with id 77018412
Chrome Headless 106.0.5249.0 (Linux x86_64): Executed 0 of 5 SUCCESS (0 secs / 0 secs)
Chrome Headless 106.0.5249.0 (Linux x86_64): Executed 0 of 5 (skipped 5) SUCCESS (0.023 secs / 0 secs)
TOTAL: 0 SUCCESS
TOTAL: 0 SUCCESS
TOTAL: 0 SUCCESS
=============================== Coverage summary ===============================
Statements : Unknown% ( 0/0 )
Branches : Unknown% ( 0/0 )
Functions : Unknown% ( 0/0 )
Lines : Unknown% ( 0/0 )
================================================================================
✔ Browser application bundle generation complete.
✔ Browser application bundle generation complete.
Cleaning up project directory and file based variables
00:01
ERROR: Job failed: exit code 1
型
1条答案
按热度按时间xmd2e60i1#
答案是,由于我有0个测试要运行,即使它返回“成功”,作业也会失败。
谢谢你@Vlad DX为我指明了这个方向,这对我来说一开始没有意义。
字符串