summaryrefslogtreecommitdiffstats
path: root/.github/workflows/macos.yml
blob: 0cfea7e269124fb9972cc69d9f559c8a1f2f5c25 (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
# Copyright (c) 2023 [Ribose Inc](https://www.ribose.com).
# All rights reserved.
# This file is a part of rnp
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
# 1. Redistributions of source code must retain the above copyright
#    notice, this list of conditions and the following disclaimer.
# 2. Redistributions in binary form must reproduce the above copyright
#    notice, this list of conditions and the following disclaimer in the
#    documentation and/or other materials provided with the distribution.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
# ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
# TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS
# BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.

name: macos

on:
  push:
    branches:
      - main
      - 'release/**'
    paths-ignore:
      - '/*.sh'
      - '/.*'
      - '/_*'
      - 'docs/**'
      - '**.adoc'
      - '**.md'
      - '**.nix'
      - 'flake.lock'
      - '.github/workflows/*.yml'
      - '!.github/workflows/macos.yml'
  pull_request:
    paths-ignore:
      - '/*.sh'
      - '/.*'
      - '/_*'
      - 'docs/**'
      - '**.adoc'
      - '**.md'
      - '**.nix'
      - 'flake.lock'

concurrency:
  group: '${{ github.workflow }}-${{ github.job }}-${{ github.head_ref || github.ref_name }}'
  cancel-in-progress: true

env:
  BOTAN_VERSION: 2.19.3

jobs:
  tests:
    name: ${{ matrix.os }} [ backend ${{ matrix.backend }}, shared libs ${{ matrix.shared_libs }} ]
    runs-on: ${{ matrix.os }}
    strategy:
      fail-fast: false
      matrix:
# On MacOS gcc is alias of clang these days
        os: [ macos-11, macos-12 ]
        backend: [ 'botan' ]
        shared_libs: [ 'on' ]
        include:
          - { os: 'macos-11', backend: 'openssl@1.1', shared_libs: 'on' }
          - { os: 'macos-12', backend: 'openssl@3', shared_libs: 'on' }
          - { os: 'macos-12', backend: 'botan', shared_libs: 'off' }

    if: "!contains(github.event.head_commit.message, 'skip ci')"
    timeout-minutes: 250

    steps:
      - uses: actions/checkout@v3
        with:
          fetch-depth: 1
          submodules: true

      - name: Configure openssl 1.1 backend
        if: matrix.backend == 'openssl@1.1'
        run: |
          echo "brew \"openssl@1.1\"" >> Brewfile
          echo "OPENSSL_ROOT_DIR=$(brew --prefix openssl@1.1)" >> $GITHUB_ENV
          echo "CRYPTO_BACKEND=openssl" >> $GITHUB_ENV

      - name: Configure openssl 3 backend
        if: matrix.backend == 'openssl@3'
        run: |
          echo "brew \"openssl@3\"" >> Brewfile
          echo "OPENSSL_ROOT_DIR=$(brew --prefix openssl@3)" >> $GITHUB_ENV
          echo "CRYPTO_BACKEND=openssl" >> $GITHUB_ENV

#      Brew installs Botan3 now and it is not supported yet
#
#      - name: Configure botan backend
#        if: ${{ matrix.backend == 'botan' }}
#        run: |
#          echo "brew \"botan\"" >> Brewfile
#          echo "CRYPTO_BACKEND=botan" >> $GITHUB_ENV

      - name: Install dependencies
        run: brew bundle

      - name: Botan2 cache
        id: cache
        uses: actions/cache@v3
        if: matrix.backend == 'botan'
        with:
          path: Botan-${{ env.BOTAN_VERSION }}
          key: ${{ matrix.os }}-Botan-${{ env.BOTAN_VERSION }}

      - name: Build Botan2
        if:  matrix.backend == 'botan' && steps.cache.outputs.cache-hit != 'true'
        run: |
          wget -qO- https://botan.randombit.net/releases/Botan-${{ env.BOTAN_VERSION }}.tar.xz | tar xvJ
          cd Botan-${{ env.BOTAN_VERSION }}
          ./configure.py --prefix=/usr/local
          make
          cd ..

      - name: Install Botan2
        if:  matrix.backend == 'botan'
        run: |
          cd Botan-${{ env.BOTAN_VERSION }}
          sudo make install
          cd ..

      - name: Configure
        run: |
          echo "CORES=$(sysctl -n hw.ncpu)" >> $GITHUB_ENV
          echo "RNP_INSTALL=$PWD/rnp-install" >> $GITHUB_ENV
          cmake -B build -DBUILD_SHARED_LIBS=${{ matrix.shared_libs }}   \
                         -DCMAKE_BUILD_TYPE=Release                      \
                         -DCMAKE_INSTALL_PREFIX="$PWD/rnp-install"       \
                         -DDOWNLOAD_GTEST=OFF                            \
                         -DCRYPTO_BACKEND=${{ env.CRYPTO_BACKEND }}      .

      - name: Build
        run: cmake --build build --config Release --parallel ${{ env.CORES }}

      - name: Install
        run: cmake --install build

      - name: Test
        run: |
          mkdir -p "build/Testing/Temporary"
          cp "cmake/CTestCostData.txt" "build/Testing/Temporary"
          export PATH="$PWD/build/src/lib:$PATH"
          ctest --parallel ${{ env.CORES }} --test-dir build -C Debug --output-on-failure

      - name: Checkout shell test framework
        if: matrix.shared_libs == 'on'
        uses: actions/checkout@v3
        with:
          repository: kward/shunit2
          path: ci/tests/shunit2

      - name: Run additional ci tests
        if: matrix.shared_libs == 'on'
        run: zsh -o shwordsplit -- ci/tests/ci-tests.sh