summaryrefslogtreecommitdiff
path: root/.github/workflows/build.yml
blob: d3dc5d03129acb7e54a9b8a1c64b12bdb74c4eaf (plain)
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
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
name: "Build"

on:
  push:
    branches: ["*"]
  pull_request:
    branches: ["*"]

env:
  BUILD_DEPS: automake bison flex git libboost-all-dev libevent-dev libssl-dev libtool make pkg-config

permissions:
  contents: read

jobs:
  # TODO windows and macos
  compiler:
    strategy:
      matrix:
        os: [ubuntu-18.04, ubuntu-20.04]
    runs-on: ${{ matrix.os }}
    steps:
      - uses: actions/checkout@v3

      - name: Install dependencies
        run: |
          sudo apt-get update -yq
          sudo apt-get install -y --no-install-recommends g++ $BUILD_DEPS

      - name: Run bootstrap
        run: ./bootstrap.sh

      - name: Run configure
        run: ./configure --disable-debug --disable-tests --disable-libs

      - name: Run make
        run: make -j$(nproc)

      - name: Run install
        run: make install

      - name: Run thrift version
        run: /usr/local/bin/thrift -version

      # only upload while building ubuntu-20.04
      - name: Archive built thrift compiler
        if: matrix.os == 'ubuntu-20.04'
        uses: actions/upload-artifact@v3
        with:
          name: thrift-compiler
          path: compiler/cpp/thrift
          retention-days: 3

  lib-java-kotlin:
    needs: compiler
    runs-on: ubuntu-20.04
    env:
      GRADLE_VERSION: 7.5.1
    steps:
      - uses: actions/checkout@v3

      - uses: actions/setup-java@v3
        with:
          distribution: temurin
          java-version: 11
          cache: "gradle"

      - name: Install dependencies
        run: |
          sudo apt-get update -yq
          sudo apt-get install -y --no-install-recommends $BUILD_DEPS
          sudo apt-get install -y wget unzip ant maven

      - name: Setup gradle
        run: |
          wget https://services.gradle.org/distributions/gradle-$GRADLE_VERSION-bin.zip -q -O /tmp/gradle-$GRADLE_VERSION-bin.zip
          (echo "f6b8596b10cce501591e92f229816aa4046424f3b24d771751b06779d58c8ec4  /tmp/gradle-$GRADLE_VERSION-bin.zip" | sha256sum -c -)
          unzip -d /tmp /tmp/gradle-$GRADLE_VERSION-bin.zip
          sudo mv /tmp/gradle-$GRADLE_VERSION /usr/local/gradle
          sudo ln -s /usr/local/gradle/bin/gradle /usr/local/bin
          gradle --version

      - name: Run spotlessCheck for Java
        run: |
          cd lib/java
          gradle spotlessCheck

      - name: Run ktfmtCheck for Kotlin
        run: |
          cd lib/kotlin
          gradle ktfmtCheck

      - name: Run bootstrap
        run: ./bootstrap.sh

      - name: Run configure
        run: |
          ./configure \
            --disable-debug \
            --disable-tests \
            --disable-dependency-tracking \
            --without-cpp \
            --without-c_glib \
            --with-java \
            --with-kotlin \
            --without-python \
            --without-py3 \
            --without-ruby \
            --without-haxe \
            --without-netstd \
            --without-perl \
            --without-php \
            --without-php_extension \
            --without-dart \
            --without-erlang \
            --without-go \
            --without-d \
            --without-nodejs \
            --without-nodets \
            --without-lua \
            --without-rs \
            --without-swift

      - uses: actions/download-artifact@v3
        with:
          name: thrift-compiler
          path: compiler/cpp

      - name: Run thrift-compiler
        run: |
          chmod a+x compiler/cpp/thrift
          compiler/cpp/thrift -version

      - name: Run make for java
        run: make -C lib/java

      # this will invoke publishToMavenLocal and install locally
      - name: Run make install for java
        run: make -C lib/java install

      - name: Upload java libthrift artifacts
        uses: actions/upload-artifact@v3
        with:
          name: libthrift
          if-no-files-found: error
          path: ~/.m2/repository/org/apache/thrift

      - name: Run make check for java
        run: make -C lib/java check

      - name: Run make precross for java
        run: make -C lib/java precross

      - name: Upload java precross artifacts
        uses: actions/upload-artifact@v3
        with:
          name: java-precross
          if-no-files-found: error
          path: |
            lib/java/build/functionalTestJar/
            lib/java/build/runclient
            lib/java/build/runnonblockingserver
            lib/java/build/runserver
            lib/java/build/runservletserver
          retention-days: 3

      - name: Run make for kotlin
        run: make -C lib/kotlin

      - name: Run make check for kotlin
        run: make -C lib/kotlin check

      - name: Run make precross for kotlin
        run: make -C lib/kotlin precross

      - name: Upload kotlin precross artifacts
        uses: actions/upload-artifact@v3
        with:
          name: kotlin-precross
          if-no-files-found: error
          path: |
            lib/kotlin/cross-test-client/build/install/TestClient/
            lib/kotlin/cross-test-server/build/install/TestServer/
          retention-days: 3

  cross-test:
    needs:
      - lib-java-kotlin
    runs-on: ubuntu-20.04
    steps:
      - uses: actions/checkout@v3
      - uses: actions/setup-python@v3
        with:
          python-version: "3.x"
      - uses: actions/setup-java@v3
        with:
          distribution: temurin
          # here we intentionally use java 8 so that we also verify java 11 compiles to version 8
          java-version: 8
          cache: "gradle"

      - name: Download java precross artifacts
        uses: actions/download-artifact@v3
        with:
          name: java-precross
          path: lib/java/build

      - name: Download kotlin precross artifacts
        uses: actions/download-artifact@v3
        with:
          name: kotlin-precross
          path: lib/kotlin

      - name: Set back executable flags
        run: |
          chmod a+x \
            lib/java/build/run* \
            lib/kotlin/cross-test-client/build/install/TestClient/bin/* \
            lib/kotlin/cross-test-server/build/install/TestServer/bin/*

      - name: Run cross test
        env:
          THRIFT_CROSSTEST_CONCURRENCY: 4
          PRECROSS_LANGS: java,kotlin
        run: |
          python test/test.py \
            --retry-count 5 \
            --skip-known-failures \
            --server $PRECROSS_LANGS \
            --client $PRECROSS_LANGS

      - name: Upload log files from failed cross test runs
        uses: actions/upload-artifact@v3
        if: failure()
        with:
          name: cross-test-log
          path: test/log/
          retention-days: 3