我有以下Github操作工作流定义.第一项工作是在本地设置环境,并为少数应用程序运行docker映像.应用程序在本地主机上正确运行(已测试).
第二个作业尝试使用cypress/included
容器运行测试.虽然找不到localhost,但测试是针对localhost运行的.
第二个作业是否可以从第一个作业访问本地主机环境?
name: Test run
on: push
jobs:
env:
runs-on: ubuntu-20.04
steps:
- name: Checkout Env repo
uses: actions/checkout@v2
with:
repository: env-repo
token: ${{ secrets.READ_TOKEN }}
# Install dependencies
- name: Install dependencies
run: sudo apt-get clean && sudo apt-get update && sudo apt-get install gettext-base
# Install docker-compose
- name: Install docker-compose
run: sudo curl -L "https://github.com/docker/compose/releases/download/1.29.2/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
# Change docker-compose permissions
- name: Docker-compose permissions
run: sudo chmod +x /usr/local/bin/docker-compose
# Run Env
- name: Run env on localhost
id: start
run: ./start
continue-on-error: false
cypress:
needs: env
runs-on: ubuntu-20.04
container: cypress/included:8.6.0
strategy:
fail-fast: false
matrix:
containers: [1] # for now, just one
steps:
# Checkout Cypress tests repo
- name: Checkout
uses: actions/checkout@v2
# Setup
- name: Setup npm package
run: npm init -y && npm install --unsafe-perm=true --allow-root
# Run
- name: Run tests vs localhost
uses: cypress-io/github-action@v4
with:
install: false
working-directory: cypress
config-file: ./cypress.json
command: npx currents run --spec '**/integration/**/*.spec.ts'
env:
ACTIONS_RUNNER_DEBUG: true
ACTIONS_STEP_DEBUG: true
测试的输出清楚地表明本地主机不可访问:
From Node.js Internals:
Error: connect ECONNREFUSED 127.0.0.1:18081
at TCPConnectWrap.afterConnect [as oncomplete] (node:net:1161:16)
我试过使用服务,但它不起作用…我不确定这是否可以实现.提前感谢您提供的任何提示