File size: 2,303 Bytes
05c9ac2
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
test_linux_protobuf_generation:
  name: Protobuf Generation Tests
  agent:
    type: Unity::VM
    image: ml-agents/ml-agents-ubuntu-18.04:latest
    flavor: b1.large
  variables:
    GRPC_VERSION: "1.14.1"
    CS_PROTO_PATH: "com.unity.ml-agents/Runtime/Grpc/CommunicatorObjects"
  commands:
    - |
      sudo apt-get update && sudo apt-get install -y nuget
      eval "$($HOME/anaconda/bin/conda shell.bash hook)"
      conda activate python3.8
      nuget install Grpc.Tools -Version $GRPC_VERSION -OutputDirectory protobuf-definitions/
      python3 -m pip install --upgrade pip --index-url https://artifactory.prd.it.unity3d.com/artifactory/api/pypi/pypi/simple
      python3 -m pip install grpcio==1.28.1 grpcio-tools==1.13.0 protobuf==3.11.3 six==1.14.0 mypy-protobuf==1.16.0  --progress-bar=off --index-url https://artifactory.prd.it.unity3d.com/artifactory/api/pypi/pypi/simple
      pushd protobuf-definitions
      chmod +x Grpc.Tools.$GRPC_VERSION/tools/linux_x64/protoc
      chmod +x Grpc.Tools.$GRPC_VERSION/tools/linux_x64/grpc_csharp_plugin
      COMPILER=Grpc.Tools.$GRPC_VERSION/tools/linux_x64 ./make.sh
      popd
      mkdir -p artifacts
      touch artifacts/proto.patch
      git diff --exit-code -- :/ ":(exclude,top)$CS_PROTO_PATH/*.meta"                          \
      || { GIT_ERR=$?; echo "protobufs need to be regenerated, apply the patch uploaded to artifacts."; \
      echo "Apply the patch with the command 'git apply proto.patch'";                                  \
      git diff -- :/ ":(exclude,top)$CS_PROTO_PATH/*.meta" > ../artifacts/proto.patch; exit $GIT_ERR; }
  triggers:
    cancel_old_ci: true
    expression: |
      (pull_request.target eq "main" OR
      pull_request.target eq "develop" OR
      pull_request.target match "release.+") AND
      NOT pull_request.draft AND
      (pull_request.changes.any match "protobuf-definitions/**" OR
      pull_request.changes.any match "com.unity.ml-agents/Runtime/Grpc/CommunicatorObjects/**" OR
      pull_request.changes.any match "ml-agents-envs/mlagents_envs/communicator_objects/**" OR
      pull_request.changes.any match ".yamato/protobuf-generation-test.yml") AND
      NOT pull_request.changes.all match "protobuf-definitions/**/*.md"
  artifacts:
    patch:
      paths:
        - "artifacts/*.*"