summaryrefslogtreecommitdiff
path: root/.circleci/config.yml
blob: 9806dc94f32840b444b7c3abc63f9ea1693de883 (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
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
version: 2.1

jobs:
  linux:
    parameters:
      target:
        type: string
      library:
        type: string
        default: ""
      dl_path:
        type: string
        default: ""
      version:
        type: string
        default: ""
      vendored:
        type: boolean
        default: false
      no_run:
        type: boolean
        default: false
      image:
        type: string
        default: 1.36.0
      minimal_build:
        type: boolean
        default: false
    docker:
      - image: rust:<< parameters.image >>
    environment:
      RUST_BACKTRACE: 1
      OPENSSL_DIR: /opt/openssl
      CARGO_TARGET_ARM_UNKNOWN_LINUX_GNUEABIHF_LINKER: arm-linux-gnueabihf-gcc
      CARGO_TARGET_ARM_UNKNOWN_LINUX_GNUEABIHF_AR: arm-linux-gnueabihf-ar
      CARGO_TARGET_ARM_UNKNOWN_LINUX_GNUEABIHF_RUNNER: qemu-arm-static
    steps:
      - checkout
      - run: apt-get update
      - run: apt-get remove -y libssl-dev
      - run: |
          case "<< parameters.target >>" in
          "i686-unknown-linux-gnu")
            apt-get install -y --no-install-recommends gcc-multilib
            ;;
          "x86_64-unknown-linux-musl")
            apt-get install -y --no-install-recommends musl-tools
            ;;
          "arm-unknown-linux-gnueabihf")
            dpkg --add-architecture armhf
            apt-get update
            apt-get install -y --no-install-recommends \
              gcc-arm-linux-gnueabihf \
              libc6-dev:armhf \
              qemu-user-static
            ;;
          "x86_64-unknown-linux-gnu")
            exit 0
          esac

          rustup target add << parameters.target >>
      - unless:
          condition: << parameters.vendored >>
          steps:
            - restore_cache:
                key: openssl-<< parameters.target >>-<< parameters.library >>-<< parameters.version >>
            - run: |
                if [ -d "$OPENSSL_DIR" ]; then
                  exit 0
                fi

                case "<< parameters.library >>" in
                "libressl")
                  URL="https://ftp.openbsd.org/pub/OpenBSD/LibreSSL/libressl-<< parameters.version >>.tar.gz"
                  ;;
                "openssl")
                  URL="https://openssl.org/source<< parameters.dl_path >>/openssl-<< parameters.version >>.tar.gz"
                  ;;
                esac

                case "<< parameters.target >>" in
                "x86_64-unknown-linux-gnu")
                  OS_COMPILER=linux-x86_64
                  OS_FLAGS=""
                  ;;
                "i686-unknown-linux-gnu")
                  OS_COMPILER=linux-elf
                  OS_FLAGS=-m32
                  ;;
                "arm-unknown-linux-gnueabihf")
                  OS_COMPILER=linux-armv4
                  OS_FLAGS=""
                  export AR=arm-linux-gnueabihf-ar
                  export CC=arm-linux-gnueabihf-gcc
                  ;;
                esac

                mkdir /tmp/build
                cd /tmp/build

                curl -L $URL | tar --strip-components=1 -xzf -

                case "<< parameters.library >>" in
                "openssl")
                  ./Configure --prefix=$OPENSSL_DIR $OS_COMPILER -fPIC -g $OS_FLAGS no-shared
                  ;;
                "libressl")
                  ./configure --prefix=$OPENSSL_DIR --disable-shared --with-pic
                  ;;
                esac

                make
                make install_sw
            - save_cache:
                key: openssl-<< parameters.target >>-<< parameters.library >>-<< parameters.version >>
                paths:
                  - /opt/openssl
      - restore_cache:
          key: registry
      - run: cargo generate-lockfile
      - when:
          condition: << parameters.minimal_build >>
          steps:
            - run: cargo update -p pkg-config --precise 0.3.14
      - save_cache:
          key: registry-{{ .BuildNum }}
          paths:
            - /usr/local/cargo/registry/index
      - restore_cache:
          key: deps-<< parameters.image >>-<< parameters.target >>-<< parameters.library >>-<< parameters.version >>-{{ checksum "Cargo.lock" }}
      - run: |
          cargo build \
            --manifest-path=openssl/Cargo.toml \
            <<# parameters.vendored >>--features vendored<</ parameters.vendored >> \
            --target << parameters.target >>
      - unless:
          condition: << parameters.minimal_build >>
          steps:
            - run: |
                cargo run \
                  --manifest-path=systest/Cargo.toml \
                  <<# parameters.vendored >>--features vendored<</ parameters.vendored >> \
                  --target << parameters.target >>
            - run: |
                cargo test \
                  --manifest-path=openssl-errors/Cargo.toml \
                  <<# parameters.vendored >>--features openssl-sys/vendored<</ parameters.vendored >> \
                  --target << parameters.target >> \
                  <<# parameters.no_run >>--no-run<</ parameters.no_run >>
            - run: |
                ulimit -c unlimited
                cargo test \
                  --manifest-path=openssl/Cargo.toml \
                  <<# parameters.vendored >>--features vendored<</ parameters.vendored >> \
                  --target << parameters.target >> \
                  <<# parameters.no_run >>--no-run<</ parameters.no_run >>
      - save_cache:
          key: deps-<< parameters.image >>-<< parameters.target >>-<< parameters.library >>-<< parameters.version >>-{{ checksum "Cargo.lock" }}
          paths:
            - /usr/local/cargo/registry/cache
            - target
      - run:
          command: |
            mkdir -p /tmp/core_dumps
            find . -name "core.*" -exec cp \{\} /tmp/core_dumps \;
            cp target/<< parameters.target >>/debug/openssl-* /tmp/core_dumps
          when: on_fail
      - store_artifacts:
          path: /tmp/core_dumps

  macos:
    parameters:
      vendored:
        type: boolean
        default: false
      image:
        type: string
        default: 1.36.0
    macos:
      xcode: "12.2.0"
    environment:
      RUST_BACKTRACE: 1
    steps:
      - checkout
      - run: curl https://sh.rustup.rs -sSf | sh -s -- -y --default-toolchain << parameters.image >>
      - run: sudo ln -s ~/.cargo/bin/* /usr/local/bin
      - run: cargo generate-lockfile
      - restore_cache:
          key: deps-<< parameters.image >>-macos-<< parameters.vendored >>-{{ checksum "Cargo.lock" }}
      - run: |
          cargo run \
            --manifest-path=systest/Cargo.toml \
            <<# parameters.vendored >> --features vendored <</ parameters.vendored >>
      - run: |
          cargo test \
            --manifest-path=openssl-errors/Cargo.toml \
            <<# parameters.vendored >> --features openssl-sys/vendored <</ parameters.vendored >>
      - run: |
          cargo test \
            --manifest-path=openssl/Cargo.toml \
            <<# parameters.vendored >> --features vendored <</ parameters.vendored >>
      - save_cache:
          key: deps-<< parameters.image >>-macos-<< parameters.vendored >>-{{ checksum "Cargo.lock" }}
          paths:
            - ~/.cargo/registry/cache
            - target

openssl_111: &openssl_111
  library: openssl
  version: 1.1.1i
openssl_110: &openssl_110
  library: openssl
  version: 1.1.0l
  dl_path: /old/1.1.0
openssl_102: &openssl_102
  library: openssl
  version: 1.0.2u
  dl_path: /old/1.0.2
openssl_101: &openssl_101
  library: openssl
  version: 1.0.1u
  dl_path: /old/1.0.1

workflows:
  test:
    jobs:
      - linux:
          name: musl-vendored
          target: x86_64-unknown-linux-musl
          vendored: true
      - linux:
          name: x86_64-vendored
          target: x86_64-unknown-linux-gnu
          vendored: true
      - linux:
          <<: *openssl_111
          name: x86_64-openssl-1.1.1
          target: x86_64-unknown-linux-gnu
      - linux:
          <<: *openssl_110
          name: x86_64-openssl-1.1.0
          target: x86_64-unknown-linux-gnu
      - linux:
          <<: *openssl_102
          name: x86_64-openssl-1.0.2
          target: x86_64-unknown-linux-gnu
      - linux:
          <<: *openssl_101
          name: x86_64-openssl-1.0.1
          target: x86_64-unknown-linux-gnu
      - linux:
          name: i686-vendored
          target: i686-unknown-linux-gnu
          vendored: true
      - linux:
          <<: *openssl_111
          name: i686-openssl-1.1.1
          target: i686-unknown-linux-gnu
      - linux:
          <<: *openssl_110
          name: i686-openssl-1.1.0
          target: i686-unknown-linux-gnu
      - linux:
          <<: *openssl_102
          name: i686-openssl-1.0.2
          target: i686-unknown-linux-gnu
      - linux:
          name: armhf-vendored
          target: arm-unknown-linux-gnueabihf
          vendored: true
          no_run: true
      - linux:
          <<: *openssl_111
          name: armhf-openssl-1.1.1
          target: arm-unknown-linux-gnueabihf
          no_run: true
      - linux:
          <<: *openssl_110
          name: armhf-openssl-1.1.0
          target: arm-unknown-linux-gnueabihf
          no_run: true
      - linux:
          <<: *openssl_102
          name: armhf-openssl-1.0.2
          target: arm-unknown-linux-gnueabihf
          no_run: true
      - linux:
          name: x86_64-libressl-2.5
          target: x86_64-unknown-linux-gnu
          library: libressl
          version: 2.5.5
      - linux:
          name: x86_64-libressl-3.3.1
          target: x86_64-unknown-linux-gnu
          library: libressl
          version: 3.3.1
      - macos:
          name: macos
      - macos:
          name: macos-vendored
          vendored: true