aboutsummaryrefslogtreecommitdiffstats
path: root/.github/workflows/build_and_test_ya.yml
blob: b6421585d67b574ea20d011cf600fad8c369e9d4 (plain) (blame)
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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
name: Ya-Build-and-Test

on:
  workflow_call:
    inputs:
      build_target:
        type: string
        default: "ydb/"
        description: "limit build and test to specific target"
      build_preset:
        type: string
      runner_label:
        type: string
        default: "linux"
        description: "runner label"
      runner_additional_label:
        type: string
        default: "linux"
        description: "additional runner label, can be empty"
      run_build:
        type: boolean
        default: true
        description: "run build"
      run_tests:
        type: boolean
        default: true
        description: "run tests"
      test_threads:
        type: string
        default: 28
        description: "Test threads count"
      link_threads:
        type: string
        default: 8
        description: "link threads count"
      test_size:
        type: string
        default: "small,medium,large"
      test_type:
        type: string
        default: "unittest,py3test,py2test,pytest"
      folder_prefix:
        type: string
        default: "ya-"
      cache_tests:
        type: boolean
        default: false
        description: "Use cache for tests"
      put_build_results_to_cache:
        type: boolean
        default: true
defaults:
  run:
    shell: bash
jobs:
  main:
    name: Build and test ${{ inputs.build_preset }}
    runs-on: [ self-hosted, "${{ inputs.runner_label }}", "${{ inputs.runner_additional_label || inputs.runner_label }}"]
    steps:
    - name: Checkout PR
      uses: actions/checkout@v3
      if: github.event.pull_request.head.sha != ''
      with:
        ref: ${{ github.event.pull_request.head.sha }}
    - name: Checkout
      uses: actions/checkout@v3
      if: github.event.pull_request.head.sha == ''
    
    - name: comment-build-start
      if: github.event_name == 'pull_request' || github.event_name == 'pull_request_target'
      shell: bash
      env:
        BUILD_PRESET: ${{ inputs.build_preset }}
        GITHUB_TOKEN: ${{ github.token }}
      run: |
        jobs_url="https://api.github.com/repos/${GITHUB_REPOSITORY}/actions/runs/${GITHUB_RUN_ID}/jobs"
        # tricky: we are searching job with name that contains build_preset
        check_url=$(curl -s $jobs_url | jq --arg n "$BUILD_PRESET" -r '.jobs[] | select(.name | contains($n)) | .html_url')
        
        echo "Pre-commit [check]($check_url) for ${{ github.event.pull_request.head.sha }} has started." | .github/scripts/tests/comment-pr.py --rewrite
    
    - name: Prepare s3cmd
      uses: ./.github/actions/s3cmd
      with:
        s3_bucket: ${{ vars.AWS_BUCKET }}
        s3_endpoint: ${{ vars.AWS_ENDPOINT }}
        s3_key_id: ${{ secrets.AWS_KEY_ID }}
        s3_key_secret: ${{ secrets.AWS_KEY_VALUE }}
        folder_prefix: ya-
        build_preset: ${{ inputs.build_preset }}

    - name: Build
      uses: ./.github/actions/build_ya
      if: inputs.run_build
      with:
        build_target: ${{ inputs.build_target }}
        build_preset: ${{ inputs.build_preset }}
        bazel_remote_uri: ${{ vars.REMOTE_CACHE_URL_YA || '' }}
        bazel_remote_username: ${{ inputs.put_build_results_to_cache && secrets.REMOTE_CACHE_USERNAME || '' }}
        bazel_remote_password: ${{ inputs.put_build_results_to_cache && secrets.REMOTE_CACHE_PASSWORD || '' }}
        link_threads: ${{ inputs.link_threads }}

    - name: Run tests
      uses: ./.github/actions/test_ya
      if: inputs.run_tests
      with:
        build_target: ${{ inputs.build_target }}
        build_preset: ${{ inputs.build_preset }}
        test_size: ${{ inputs.test_size }}
        test_type: ${{ inputs.test_type }}
        testman_token: ${{ secrets.TESTMO_TOKEN }}
        testman_url: ${{ vars.TESTMO_URL }}
        testman_project_id: ${{ vars.TESTMO_PROJECT_ID }}
        bazel_remote_uri: ${{ vars.REMOTE_CACHE_URL_YA || '' }}
        bazel_remote_username: ${{ inputs.put_build_results_to_cache && secrets.REMOTE_CACHE_USERNAME || '' }}
        bazel_remote_password: ${{ inputs.put_build_results_to_cache && secrets.REMOTE_CACHE_PASSWORD || '' }}
        link_threads: ${{ inputs.link_threads }}
        test_threads: ${{ inputs.test_threads }}
    
    - name: comment-if-cancel
      if: cancelled() && (github.event_name == 'pull_request' || github.event_name == 'pull_request_target')
      env:
        BUILD_PRESET: ${{ inputs.build_preset }}
        GITHUB_TOKEN: ${{ github.token }}
      run:  echo "Check cancelled" | .github/scripts/tests/comment-pr.py --color black