ci: QEMU based cross compiled testing
[openssl.git] / .github / workflows / cross-compiles.yml
1 name: Cross Compile
2
3 on: [pull_request, push]
4
5 jobs:
6   cross-compilation:
7     strategy:
8       fail-fast: false
9       matrix:
10         # The platform matrix specifies:
11         #   arch: the architecture to build for, this defines the tool-chain
12         #         prefix {arch}- and the Debian compiler package gcc-{arch}
13         #         name.
14         #   libs: the Debian package for the necessary link/runtime libraries.
15         #   target: the OpenSSL configuration target to use, this is passed
16         #           directly to the config command line.
17         #   tests: omit this to run all the tests using QEMU, set it to "none"
18         #          to never run the tests, otherwise it's value is passed to
19         #          the "make test" command to allow selectiving disabling of
20         #          tests.
21         platform: [
22           {
23             arch: aarch64-linux-gnu,
24             libs: libc6-dev-arm64-cross,
25             target: linux-aarch64
26           }, {
27             arch: alpha-linux-gnu,
28             libs: libc6.1-dev-alpha-cross,
29             target: linux-alpha-gcc
30           }, {
31             arch: arm-linux-gnueabi,
32             libs: libc6-dev-armel-cross,
33             target: linux-armv4,
34             tests: -test_includes -test_store -test_x509_store
35           }, {
36             arch: arm-linux-gnueabihf,
37             libs: libc6-dev-armhf-cross,
38             target: linux-armv4,
39             tests: -test_includes -test_store -test_x509_store
40           }, {
41             arch: hppa-linux-gnu,
42             libs: libc6-dev-hppa-cross,
43             target: linux-generic32,
44             tests: none #-test_includes -test_store -test_x509_store
45           }, {
46             arch: m68k-linux-gnu,
47             libs: libc6-dev-m68k-cross,
48             target: linux-latomic no-asm,
49             tests: none #-test_includes -test_store -test_x509_store -test_includes
50           }, {
51             arch: mips-linux-gnu,
52             libs: libc6-dev-mips-cross,
53             target: linux-mips32,
54             tests: none
55           }, {
56             arch: mips64-linux-gnuabi64,
57             libs: libc6-dev-mips64-cross,
58             target: linux64-mips64,
59             tests: none
60           }, {
61             arch: mipsel-linux-gnu,
62             libs: libc6-dev-mipsel-cross,
63             target: linux-mips32,
64             tests: -test_includes -test_store -test_x509_store
65           }, {
66             arch: powerpc64le-linux-gnu,
67             libs: libc6-dev-ppc64el-cross,
68             target: linux-ppc64le
69           }, {
70             arch: riscv64-linux-gnu,
71             libs: libc6-dev-riscv64-cross,
72             target: linux64-riscv64
73           }, {
74             arch: s390x-linux-gnu,
75             libs: libc6-dev-s390x-cross,
76             target: linux64-s390x
77           }, {
78             arch: sh4-linux-gnu,
79             libs: libc6-dev-sh4-cross,
80             target: linux-latomic,
81             tests: -test_includes -test_store -test_x509_store -test_async
82           }, {
83             arch: sparc64-linux-gnu,
84             libs: libc6-dev-sparc64-cross,
85             target: linux64-sparcv9,
86             tests: none
87           }
88         ]
89     runs-on: ubuntu-latest
90     steps:
91     - name: install packages
92       run: |
93         sudo apt-get update
94         sudo apt-get -yq --force-yes install \
95             gcc-${{ matrix.platform.arch }} \
96             ${{ matrix.platform.libs }}
97     - uses: actions/checkout@v2
98
99     - name: config
100       run: |
101         ./config --banner=Configured --strict-warnings enable-fips \
102                  --cross-compile-prefix=${{ matrix.platform.arch }}- \
103                  ${{ matrix.platform.target }}
104     - name: config dump
105       run: ./configdata.pm --dump
106
107     - name: make
108       run: make -s -j4
109
110     - name: install qemu
111       if: github.event_name == 'push' && matrix.platform.tests != 'none'
112       run: sudo apt-get -yq --force-yes install qemu-user
113
114     - name: make all tests
115       if: github.event_name == 'push' && matrix.platform.tests == ''
116       run: |
117         make test HARNESS_JOBS=${HARNESS_JOBS:-4} \
118                   QEMU_LD_PREFIX=/usr/${{ matrix.platform.arch }}
119     - name: make some tests
120       if: github.event_name == 'push' && matrix.platform.tests != 'none' && matrix.platform.tests != ''
121       run: |
122         make test HARNESS_JOBS=${HARNESS_JOBS:-4} \
123                   TESTS="${{ matrix.platform.tests }}" \
124                   QEMU_LD_PREFIX=/usr/${{ matrix.platform.arch }}