简体   繁体   English

在 Github Actions 中运行 Node.js API

[英]Running a Node.js API in Github Actions

I have a Monorepo which contains a front-end app and a node.js API.我有一个 Monorepo,其中包含一个前端应用程序和一个 node.js API。 I would like to run both the front-end app and the node.js API, in order to run some end-to-end tests.我想同时运行前端应用程序和 node.js API,以便运行一些端到端测试。 However I can not figure out how to run these two applications before running the tests.但是,在运行测试之前,我无法弄清楚如何运行这两个应用程序。 Here is my actions file so far.到目前为止,这是我的操作文件。

name: Test Client

on: [push]

jobs:
  build:
    runs-on: ubuntu-latest

    strategy:
      matrix:
        node-version: [12.x]

    steps:
      - uses: actions/checkout@v1
      - name: Use Node.js ${{ matrix.node-version }}
        uses: actions/setup-node@v1
        with:
          node-version: ${{ matrix.node-version }}
      - name: Initial Setup
        run: |
          npm install yarn -g
      - name: yarn install, build, and test
        working-directory: client-app
        run: |
          yarn install
          yarn build
          yarn test
        env:
          CI: true

I would like to run an API in a different directory, before running the client-app tests.在运行客户端应用程序测试之前,我想在不同的目录中运行 API。 Is this possible without using a third-party service?在不使用第三方服务的情况下这可能吗?

You can ensure the pipeline does not hang on a command by adding "&" to the end of the command: see: https://github.community/t5/GitHub-Actions/How-do-I-run-commands-concurrently/td-p/36057您可以通过在命令末尾添加“&”来确保管道不会挂在命令上:请参阅: https : //github.community/t5/GitHub-Actions/How-do-I-run-commands-concurrently /td-p/36057

For example now I can do:例如现在我可以这样做:

yarn start-api &
yarn start-client &
yarn test

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Github 操作 - node.js CI - Github Actions - node.js CI 在同一作业中使用 Node.JS 和 .NET 的 GitHub 操作 - GitHub actions using Node.JS and .NET in same job GitHub 操作解决了错误的 Node.js 路径 - GitHub Actions resolve wrong Node.js path Node.js 应用程序的 Github 动作缓存不起作用 - Github actions caching for Node.js application is not working 为 Azure Node.js Web 应用推送到 GitHub 时发出警告:“不推荐使用 Node.js 12 操作” - Warning when pushing to GitHub for Azure Node.js Web App: "Node.js 12 actions are deprecated" 如何运行 node.js github 存储库作为 github 操作上另一个存储库中的服务 - how to run a node.js github repository as a service in another repository on github actions 无法在 GitHub 操作中将 Node.js 与 Docker MySQL 数据库连接 - Can't connect Node.js with Docker MySQL database in GitHub actions npm ci 命令在节点 16 上运行时在 GitHub 操作中失败 - npm ci command fails in GitHub actions when running on Node 16 在 GitHub 操作中运行 Postgres 以测试我的 Go API - Running Postgres in GitHub Actions to test my Go API 使用 GitHub 操作将测试结果上传到 Node js 的 Sqhub - Upload test results to Sqhub for Node js with GitHub Actions
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM