. NET Основные встроенные ресурсы + Gitlab: ОШИБКА: нет файлов для загрузки - PullRequest
0 голосов
/ 18 января 2020

Я работаю над следующим решением. NET Core:

.NET Core Solution

и использую приведенное ниже определение CI Gitlab:

.gitlab-ci.yml:

image: docker:stable
services:
  - docker:dind

stages:
  - test
  - build
  - deploy-db
  - deploy

variables:
  DOCKER_REGISTRY: "our.registry.eu"
  IMAGE_NAME: "${DOCKER_REGISTRY}/membercreditor"

  # secrets are on GitLab environment variables (settings > ci/cd)

  RANCHER_ENV: 1a10
  RANCHER_STACK: api
  RANCHER_SVC: membercreditor

  RANCHER_DEV_KEY: a dev key
  RANCHER_DEV_URL: http://our.dev.rancher.io:8080
  RANCHER_PREPROD_KEY: a preprod key
  RANCHER_PREPROD_URL: http://our.preprod.rancher.io:8080
  RANCHER_PROD_KEY: a prod key
  RANCHER_PROD_URL: http://our.prod.rancher.io:8080

.test:
  stage: test
  image: mcr.microsoft.com/dotnet/core/sdk:3.1-alpine
  script:
    - dotnet test ./Rm.MemberCreditor.Api.Tests/ -l:junit /p:CollectCoverage=true /p:Include="[Rm.*]*" /p:CoverletOutput=./TestResults/
    - dotnet test ./Rm.MemberCreditor.Domain.Tests/ -l:junit /p:CollectCoverage=true /p:Include="[Rm.*]*" /p:CoverletOutput=./TestResults/ /p:MergeWith=../Rm.MemberCreditor.Api.Tests/TestResults/coverage.json
    - dotnet test ./Rm.MemberCreditor.IntegrationTests/ -l:junit /p:CollectCoverage=true /p:Include="[Rm.*]*" /p:CoverletOutput=./TestResults/ /p:MergeWith=../Rm.MemberCreditor.Domain.Tests/TestResults/coverage.json
  coverage: '/Total[ |]+(\d+[,.]\d+)%/'
  artifacts:
    reports:
      junit: ./*.Tests/TestResults/*.xml

.build:
  stage: build
  tags:
    - dind
  script:
    - docker build -t $IMAGE_NAME:$APP_VERSION -f Dockerfile .
    - docker login $DOCKER_REGISTRY -u svc_finance_revmgt -p $SVC_FINANCE_REVMGT_TOKEN
    - docker push $IMAGE_NAME:$APP_VERSION

.deploy-db:
  stage: deploy-db
  image: mcr.microsoft.com/dotnet/core/sdk:3.1-alpine
  script:
    - export CONNECTIONSTRINGS__MEMBERCREDITOR=$CONNECTIONSTRINGS__MEMBERCREDITOR
    - export SECRETS__CS_MEMBERCREDITOR=$SECRETS__CS_MEMBERCREDITOR
    - dotnet tool restore
    - dotnet ef database update -p ./Rm.MemberCreditor.Data.Migrations -s ./Rm.MemberCreditor.Api -v

.deploy:
  stage: deploy
  image: cdrx/rancher-gitlab-deploy
  script:
    - upgrade --rancher-key $RANCHER_KEY
      --rancher-secret $RANCHER_SECRET
      --rancher-url $RANCHER_URL
      --environment $RANCHER_ENV
      --stack $RANCHER_STACK
      --service $RANCHER_SVC
      --new-image $IMAGE_NAME:$APP_VERSION

###########################
### Merge Requests
###########################

test-merge-request:
  extends: .test
  only:
    refs:
      - merge_requests

###########################
### Integration
###########################

test-integration:
  extends: .test
  environment:
    name: integration
  only:
    - develop

build-integration:
  extends: .build
  environment:
    name: integration
  dependencies:
    - test-integration
  before_script:
    - APP_VERSION=latest-integration
  only:
    - develop

deploy-db-integration:
  extends: .deploy-db
  environment:
    name: integration
  dependencies:
    - build-integration
  before_script:
    - export ASPNETCORE_ENVIRONMENT=Integration
  only:
    - develop

deploy-integration:
  extends: .deploy
  environment:
    name: integration
  dependencies:
    - deploy-db-integration
  before_script:
    - APP_VERSION=latest-integration
    - RANCHER_KEY=$RANCHER_DEV_KEY
    - RANCHER_SECRET=$RANCHER_DEV_SECRET
    - RANCHER_URL=$RANCHER_DEV_URL
  only:
    - develop

###########################
### UAT
###########################

test-uat:
  extends: .test
  environment:
    name: uat
  only:
    - master

build-uat:
  extends: .build
  environment:
    name: uat
  dependencies:
    - test-uat
  before_script:
    - APP_VERSION=latest-uat
  only:
    - master

deploy-db-uat:
  extends: .deploy-db
  environment:
    name: uat
  dependencies:
    - build-uat
  before_script:
    - export ASPNETCORE_ENVIRONMENT=Uat
  only:
    - master

deploy-uat:
  extends: .deploy
  environment:
    name: uat
  dependencies:
    - deploy-db-uat
  before_script:
    - APP_VERSION=latest-uat
    - RANCHER_KEY=$RANCHER_PREPROD_KEY
    - RANCHER_SECRET=$RANCHER_PREPROD_SECRET
    - RANCHER_URL=$RANCHER_PREPROD_URL
  only:
    - master

###########################
### Production
###########################

build-prod:
  extends: .build
  environment:
    name: production
  before_script:
    - APP_VERSION=$CI_COMMIT_TAG
  only:
    - /^\d+.\d+.\d+$/
  except:
    - /^(?:[^m]|m[^a]|ma[^s]|mas[^t]|mast[^e]|maste[^r]).*@/

deploy-db-prod:
  extends: .deploy-db
  environment:
    name: production
  dependencies:
    - build-prod
  before_script:
    - export ASPNETCORE_ENVIRONMENT=Production
  only:
    - /^\d+.\d+.\d+$/
  except:
    - /^(?:[^m]|m[^a]|ma[^s]|mas[^t]|mast[^e]|maste[^r]).*@/

deploy-prod:
  extends: .deploy
  environment:
    name: production
  when: manual
  dependencies:
    - deploy-db-prod
  before_script:
    - APP_VERSION=$CI_COMMIT_TAG
    - RANCHER_KEY=$RANCHER_PROD_KEY
    - RANCHER_SECRET=$RANCHER_PROD_SECRET
    - RANCHER_URL=$RANCHER_PROD_URL
  only:
    - /^\d+.\d+.\d+$/
  except:
    - /^(?:[^m]|m[^a]|ma[^s]|mas[^t]|mast[^e]|maste[^r]).*@/

Когда Gitlab запускает test-merge-request, я получаю сообщение об ошибке ниже:

Fetching changes with git depth set to 50...
00:02
Initialized empty Git repository in /builds/finance/products/revenuemgmt/modules/membercreditor/.git/
Created fresh repository.
From https://our.org/finance/products/revenuemgmt/modules/membercreditor
 * [new ref]         refs/merge-requests/38/head -> refs/merge-requests/38/head
 * [new ref]         refs/pipelines/355543       -> refs/pipelines/355543
Checking out 603e9a2c as refs/merge-requests/38/head...
Skipping Git submodules setup

$ dotnet test ./Rm.MemberCreditor.Api.Tests/ -l:junit /p:CollectCoverage=true /p:Include="[Rm.*]*" /p:CoverletOutput=./TestResults/
00:12
FSC : error FS0078: Unable to find the file 'Legacy/Queries/GetOrderRelatedInfoForAccountingEntryCreation.sql' in any of /builds/finance/products/revenuemgmt/modules/membercreditor/Rm.MemberCreditor.Data [/builds/finance/products/revenuemgmt/modules/membercreditor/Rm.MemberCreditor.Data/Rm.MemberCreditor.Data.fsproj]

Uploading artifacts...
00:02
WARNING: ./*.Tests/TestResults/*.xml: no matching files 
ERROR: No files to upload                          
ERROR: Job failed: exit code 1

GetOrderRelatedInfoForAccountingEntryCreation.sql определяется как встроенный ресурс, я пытался принудительно скопировать файл в вывод, но я все еще получаю ту же самую ошибку.

1 Ответ

1 голос
/ 21 января 2020

Я не уверен, почему этот пост был отклонен, но забавный факт, кажется, есть ошибка в Rider 2019.3.1.

Проблема возникла из-за того, что, несмотря на то, что файл показывался как GetOrderRelatedInfoForAccountingEntryCreation.sql в случае Rider aka pascal, он был фактически записан на диске как верблюжий корпус (т.е. getOrderRelatedInfoForAccountingEntryCreation.sql), go рисунок .

Как только имя фактического файла на диске было установлено на pascal, все работало нормально.

...