kafka

Форк
0
/
build.yml 
195 строк · 7.3 Кб
1
# Licensed to the Apache Software Foundation (ASF) under one or more
2
# contributor license agreements.  See the NOTICE file distributed with
3
# this work for additional information regarding copyright ownership.
4
# The ASF licenses this file to You under the Apache License, Version 2.0
5
# (the "License"); you may not use this file except in compliance with
6
# the License.  You may obtain a copy of the License at
7
#
8
#    http://www.apache.org/licenses/LICENSE-2.0
9
#
10
# Unless required by applicable law or agreed to in writing, software
11
# distributed under the License is distributed on an "AS IS" BASIS,
12
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
# See the License for the specific language governing permissions and
14
# limitations under the License.
15

16
name: Check and Test
17

18
# This workflow should only be called from ci.yml which is triggered on
19
# the "pull_request" event type. We should never dispatch this workflow from
20
# a "pull_request_target" event.
21
on:
22
  workflow_call:
23
    inputs:
24
      gradle-cache-read-only:
25
        description: "Should the Gradle cache be read-only?"
26
        default: true
27
        type: boolean
28
      gradle-cache-write-only:
29
        description: "Should the Gradle cache be write-only?"
30
        default: false
31
        type: boolean
32
      is-public-fork:
33
        description: "Is this CI run from a public fork?"
34
        default: true
35
        type: boolean
36

37
jobs:
38
  validate:
39
    runs-on: ubuntu-latest
40
    name: Compile and Check Java
41
    outputs:
42
      is-draft: ${{ steps.check-draft-pr.outputs.is-draft }}
43
    steps:
44
      - name: Env
45
        run: printenv
46
        env:
47
          GITHUB_CONTEXT: ${{ toJson(github) }}
48
      - name: Check for Draft PR
49
        id: check-draft-pr
50
        if: |
51
          github.event_name == 'pull_request' && 
52
          github.event.pull_request.draft
53
        run: echo "is-draft=true" >> "$GITHUB_OUTPUT"
54
      - name: Checkout code
55
        uses: actions/checkout@v4
56
        with:
57
          persist-credentials: false
58
      - uses: actions/setup-python@v5
59
        with:
60
          python-version: '3.12'
61
      - name: Setup Gradle
62
        uses: ./.github/actions/setup-gradle
63
        with:
64
          java-version: 21
65
          gradle-cache-read-only: ${{ inputs.gradle-cache-read-only }}
66
          gradle-cache-write-only: ${{ inputs.gradle-cache-write-only }}
67
          develocity-access-key: ${{ secrets.GE_ACCESS_TOKEN }}
68
      - name: Compile and validate
69
        env:
70
          SCAN_ARG: ${{ inputs.is-public-fork && '--no-scan' || '--scan' }}
71
        # Gradle flags
72
        # --build-cache:  Let Gradle restore the build cache
73
        # --info:         For now, we'll generate lots of logs while setting up the GH Actions
74
        # --scan:         Publish the build scan. This will only work on PRs from apache/kafka and trunk
75
        # --no-scan:      For public fork PRs, we won't attempt to publish the scan
76
        run: |
77
          ./gradlew --build-cache --info $SCAN_ARG check -x test
78
      - name: Archive check reports
79
        if: always()
80
        uses: actions/upload-artifact@v4
81
        with:
82
          name: check-reports
83
          path: |
84
            **/build/**/*.html
85
          compression-level: 9
86
          if-no-files-found: ignore
87
      - name: Annotate checkstyle errors
88
        # Avoid duplicate annotations, only run on java 21
89
        if: failure()
90
        run: python .github/scripts/checkstyle.py
91
        env:
92
          GITHUB_WORKSPACE: ${{ github.workspace }}
93
      - name: Annotate Rat errors
94
        # Avoid duplicate annotations, only run on java 21
95
        if: failure()
96
        run: python .github/scripts/rat.py
97
        env:
98
          GITHUB_WORKSPACE: ${{ github.workspace }}
99

100
  test:
101
    needs: validate
102
    if: ${{ ! needs.validate.outputs.is-draft }}
103
    runs-on: ubuntu-latest
104
    strategy:
105
      fail-fast: false
106
      matrix:
107
        java: [ 21, 11 ]  # If we change these, make sure to adjust ci-complete.yml
108
    name: JUnit tests Java ${{ matrix.java }}
109
    steps:
110
      - name: Checkout code
111
        uses: actions/checkout@v4
112
        with:
113
          persist-credentials: false
114
      - uses: actions/setup-python@v5
115
        with:
116
          python-version: '3.12'
117
      - run: pip install -r .github/scripts/requirements.txt
118
      - name: Setup Gradle
119
        uses: ./.github/actions/setup-gradle
120
        with:
121
          java-version: ${{ matrix.java }}
122
          gradle-cache-read-only: ${{ inputs.gradle-cache-read-only }}
123
          gradle-cache-write-only: ${{ inputs.gradle-cache-write-only }}
124
          develocity-access-key: ${{ secrets.GE_ACCESS_TOKEN }}
125
      - name: Test
126
        # Gradle flags
127
        # --build-cache:  Let Gradle restore the build cache
128
        # --no-scan:      Don't attempt to publish the scan yet. We want to archive it first.
129
        # --continue:     Keep running even if a test fails
130
        # -PcommitId      Prevent the Git SHA being written into the jar files (which breaks caching)
131
        id: junit-test
132
        env:
133
          TIMEOUT_MINUTES: 180  # 3 hours
134
        run: |
135
          set +e
136
          ./.github/scripts/thread-dump.sh &
137
          timeout ${TIMEOUT_MINUTES}m ./gradlew --build-cache --continue --no-scan \
138
          -PtestLoggingEvents=started,passed,skipped,failed \
139
          -PmaxParallelForks=2 \
140
          -PmaxTestRetries=1 -PmaxTestRetryFailures=3 \
141
          -PmaxQuarantineTestRetries=3 -PmaxQuarantineTestRetryFailures=0 \
142
          -PcommitId=xxxxxxxxxxxxxxxx \
143
          quarantinedTest test
144
          exitcode="$?"
145
          echo "exitcode=$exitcode" >> $GITHUB_OUTPUT
146
      - name: Archive JUnit HTML reports
147
        uses: actions/upload-artifact@v4
148
        id: junit-upload-artifact
149
        with:
150
          name: junit-reports-${{ matrix.java }}
151
          path: |
152
            **/build/reports/tests/*
153
          compression-level: 9
154
          if-no-files-found: ignore
155
      - name: Archive JUnit XML
156
        uses: actions/upload-artifact@v4
157
        with:
158
          name: junit-xml-${{ matrix.java }}
159
          path: |
160
            build/junit-xml/**/*.xml
161
          compression-level: 9
162
          if-no-files-found: ignore
163
      - name: Archive Thread Dumps
164
        id: thread-dump-upload-artifact
165
        if: always() && steps.junit-test.outputs.exitcode == '124'
166
        uses: actions/upload-artifact@v4
167
        with:
168
          name: junit-thread-dumps-${{ matrix.java }}
169
          path: |
170
            thread-dumps/*
171
          compression-level: 9
172
          if-no-files-found: ignore
173
      - name: Parse JUnit tests
174
        run: python .github/scripts/junit.py --export-test-catalog ./test-catalog >> $GITHUB_STEP_SUMMARY
175
        env:
176
          GITHUB_WORKSPACE: ${{ github.workspace }}
177
          JUNIT_REPORT_URL: ${{ steps.junit-upload-artifact.outputs.artifact-url }}
178
          THREAD_DUMP_URL: ${{ steps.thread-dump-upload-artifact.outputs.artifact-url }}
179
          GRADLE_EXIT_CODE: ${{ steps.junit-test.outputs.exitcode }}
180
      - name: Archive Test Catalog
181
        if: ${{ always() && matrix.java == '21' }}
182
        uses: actions/upload-artifact@v4
183
        with:
184
          name: test-catalog
185
          path: test-catalog
186
          compression-level: 9
187
          if-no-files-found: ignore
188
      - name: Archive Build Scan
189
        if: always()
190
        uses: actions/upload-artifact@v4
191
        with:
192
          name: build-scan-test-${{ matrix.java }}
193
          path: ~/.gradle/build-scan-data
194
          compression-level: 9
195
          if-no-files-found: ignore
196

Использование cookies

Мы используем файлы cookie в соответствии с Политикой конфиденциальности и Политикой использования cookies.

Нажимая кнопку «Принимаю», Вы даете АО «СберТех» согласие на обработку Ваших персональных данных в целях совершенствования нашего веб-сайта и Сервиса GitVerse, а также повышения удобства их использования.

Запретить использование cookies Вы можете самостоятельно в настройках Вашего браузера.