【问题标题】:Flutter continuous integration (CI) not working on github because the project is inside a folderFlutter 持续集成 (CI) 无法在 github 上运行,因为项目位于文件夹中
【发布时间】:2022-03-12 02:22:04
【问题描述】:

我正在尝试在我的 github 存储库上实现持续集成。 如果项目与 root 处于同一级别,则它可以工作。但我想将项目放在一个文件夹中以使其井井有条。在我的本地设置中,我会执行“cd my_folder”,但我尝试将其添加到 .yml 脚本中,但仍然失败。

显示错误:

Error: No pubspec.yaml file found.
This command should be run from the root of your Flutter project.
Error: Process completed with exit code 1.

基本上它失败了,因为它试图在 pubspec.yaml 不存在的存储库的根目录中执行 pub get,而不是在文件夹内部。

这是代码:

on:
  push:
    branches:
      - development

jobs:

  build:
    runs-on: ubuntu-latest
    steps:
    - uses: actions/checkout@v1
    - uses: actions/setup-java@v1
      with:
        java-version: '12.x'
    - uses: subosito/flutter-action@v1
      with:
          channel: 'beta'
   # Enter into the flutter project.
    - run: cd my_folder # Here I tried to put this command, but is useless
          
   # Get flutter dependencies.
    - run: flutter pub get # <--- Here is the error
    
    # Statically analyze the Dart code for any errors.
    - run: flutter analyze .
    
    # Run widget tests for our flutter project.
    - run: flutter test

【问题讨论】:

    标签: flutter dart continuous-integration yaml continuous-deployment


    【解决方案1】:

    我找到了解决办法,只需要添加一个工作目录

    最终代码

    name: CI
    on:
      push:
        branches:
          - development
    
    jobs:
    
      build:
        runs-on: ubuntu-latest
        steps:
        - uses: actions/checkout@v1
        - uses: actions/setup-java@v1
          with:
            java-version: '12.x'
        - uses: subosito/flutter-action@v1
          with:
              channel: 'beta'
             
        - name: Get flutter dependencies
          run: flutter pub get
          working-directory: my_folder
        
        - name: Statically analyze the Dart code for any errors.
          run: flutter analyze .
          working-directory: my_folder
        
        - name: Run widget tests for our flutter project.
          run: flutter test
          working-directory: my_folder
    

    【讨论】:

      【解决方案2】:

      这个错误告诉你,你的开发分支没有pubspec.yaml,尝试将你的pubspec.yaml推送到开发分支。

      【讨论】:

        猜你喜欢
        • 2019-11-15
        • 2011-12-14
        • 1970-01-01
        • 1970-01-01
        • 2021-03-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2013-07-12
        相关资源
        最近更新 更多