我想设置 github 操作
- 调用 nuget 并缓存它
- 构建解决方案
- 运行单元测试
我设法让第二步和第三步正常工作,但现在将第一步结合起来是一个问题。
- name: Cache Nuget
- uses: actions/cache@v1
with:
path: ~/.nuget/packages
key: ${{ runner.os }}-nuget-${{ hashFiles('**/*.csproj') }}
restore-keys: |
${{ runner.os }}-nuget-
我试着把它放在后面- uses: actions/checkout@v2
但它会引发以下错误。
every step must define a `uses` or `run` key
...
steps:
- uses: actions/checkout@v2
- name: Cache Nuget
- uses: actions/cache@v1
with:
path: ~/.nuget/packages
key: ${{ runner.os }}-nuget-${{ hashFiles('**/*.csproj') }}
restore-keys: |
${{ runner.os }}-nuget-
- name: Setup .NET
uses: actions/setup-dotnet@v1
...
我究竟做错了什么?
感谢帮助。
这是完整的配置。
name: Build and Tests
on:
push:
branches: [ main ]
pull_request:
branches: [ main ]
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Cache Nuget
- uses: actions/cache@v1
with:
path: ~/.nuget/packages
key: ${{ runner.os }}-nuget-${{ hashFiles('**/*.csproj') }}
restore-keys: |
${{ runner.os }}-nuget-
- name: Setup .NET
uses: actions/setup-dotnet@v1
with:
dotnet-version: 5.0.x
- name: Restore dependencies
run: dotnet restore
- name: Build
run: dotnet build --configuration Release --no-restore
- name: Run Tests
run: dotnet test --configuration Release --no-build --verbosity minimal /p:CollectCoverage=true /p:CoverletOutput=TestResults/ /p:CoverletOutputFormat=lcov
- name: Publish coverage report to coveralls.io
uses: coverallsapp/github-action@master
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
path-to-lcov: Tests/App.Tests/TestResults/coverage.info
您的格式已关闭。仅在第一行使用破折号,如下所示:
- uses: actions/checkout@v2
- name: Cache Nuget
uses: actions/cache@v1
如果您还在最后一行添加破折号前缀 (-
),那么 GitHub 认为name
是一个单独的步骤,它不知道如何处理它。然而,不使用破折号意味着uses
属于同一步骤name
.
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)