aboutsummaryrefslogtreecommitdiffstats
path: root/.github/workflows/test.yml
blob: 374447f8796280ec98beff34350dda39a235edd5 (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
name: CI

on: [push, pull_request]

jobs:
  ruby-versions:
    uses: ruby/actions/.github/workflows/ruby_versions.yml@master
    with:
      engine: cruby-truffleruby
      min_version: 2.6
  test:
    needs: ruby-versions
    name: >-
      ${{ matrix.os }} ${{ matrix.ruby }}
    runs-on: ${{ matrix.os }}
    strategy:
      fail-fast: false
      matrix:
        # ubuntu-22.04 uses OpenSSL 3.0, ubuntu-20.04 uses OpenSSL 1.1.1
        os: [ ubuntu-22.04, ubuntu-20.04, macos-latest, windows-latest ]
        ruby: ${{ fromJson(needs.ruby-versions.outputs.versions) }}
        exclude:
          # uses non-standard MSYS2 OpenSSL 3 package
          - { os: windows-latest, ruby: head }
          - { os: windows-latest, ruby: truffleruby }
          - { os: windows-latest, ruby: truffleruby-head }
          - { os: macos-latest,   ruby: truffleruby }
          - { os: ubuntu-20.04,   ruby: truffleruby }
        include:
          - { os: windows-latest, ruby: ucrt }
          - { os: windows-latest, ruby: mswin }

    steps:
      - name: repo checkout
        uses: actions/checkout@v3

      - name: load ruby
        uses: ruby/setup-ruby@v1
        with:
          ruby-version: ${{ matrix.ruby }}

      - name: depends
        run:  bundle install

      - name: compile
        run:  rake compile -- --enable-debug

      - name: test
        run:  rake test TESTOPTS="-v --no-show-detail-immediately" OSSL_MDEBUG=1
        timeout-minutes: 5

  test-openssls:
    name: >-
      ${{ matrix.openssl }} ${{ matrix.name_extra || '' }}
    runs-on: ${{ matrix.os }}
    strategy:
      fail-fast: false
      matrix:
        os: [ ubuntu-latest ]
        ruby: [ "3.0" ]
        openssl:
          - openssl-1.0.2u # EOL
          - openssl-1.1.0l # EOL
          - openssl-1.1.1t
          - openssl-3.0.8
          - libressl-3.1.5 # EOL
          - libressl-3.2.7 # EOL
          - libressl-3.3.6 # EOL
          - libressl-3.4.3 # EOL
          - libressl-3.5.3
          - libressl-3.6.1
          - libressl-3.7.0 # Development release
        fips_enabled: [ false ]
        include:
          - { os: ubuntu-latest, ruby: "3.0", openssl: openssl-3.0.8, fips_enabled: true, append_configure: 'enable-fips', name_extra: 'fips' }
    steps:
      - name: repo checkout
        uses: actions/checkout@v3

      - name: prepare openssl
        run: |
          mkdir -p tmp/build-openssl && cd tmp/build-openssl
          case ${{ matrix.openssl }} in
          openssl-*)
            curl -OL https://ftp.openssl.org/source/${{ matrix.openssl }}.tar.gz
            tar xf ${{ matrix.openssl }}.tar.gz && cd ${{ matrix.openssl }}
            # shared is required for 1.0.x.
            ./Configure --prefix=$HOME/.openssl/${{ matrix.openssl }} --libdir=lib \
                shared linux-x86_64 ${{ matrix.append_configure }}
            make depend
            ;;
          libressl-*)
            curl -OL https://ftp.openbsd.org/pub/OpenBSD/LibreSSL/${{ matrix.openssl }}.tar.gz
            tar xf ${{ matrix.openssl }}.tar.gz && cd ${{ matrix.openssl }}
            ./configure --prefix=$HOME/.openssl/${{ matrix.openssl }}
            ;;
          *)
            false
            ;;
          esac
          make -j4
          make install_sw

      - name: prepare openssl fips
        run: make install_fips
        working-directory: tmp/build-openssl/${{ matrix.openssl }}
        if: matrix.fips_enabled

      - name: set the open installed directory
        run: >
          sed -e "s|OPENSSL_DIR|$HOME/.openssl/${{ matrix.openssl }}|"
          test/openssl/fixtures/ssl/openssl_fips.cnf.tmpl >
          test/openssl/fixtures/ssl/openssl_fips.cnf
        if: matrix.fips_enabled

      - name: set openssl config file path for fips.
        run: echo "OPENSSL_CONF=$(pwd)/test/openssl/fixtures/ssl/openssl_fips.cnf" >> $GITHUB_ENV
        if: matrix.fips_enabled

      - name: set fips enviornment variable for testing.
        run: echo "TEST_RUBY_OPENSSL_FIPS_ENABLED=true" >> $GITHUB_ENV
        if: matrix.fips_enabled

      - name: load ruby
        uses: ruby/setup-ruby@v1
        with:
          ruby-version: ${{ matrix.ruby }}

      - name: depends
        run:  bundle install

      - name: compile
        run:  rake compile -- --enable-debug --with-openssl-dir=$HOME/.openssl/${{ matrix.openssl }}

      - name: test
        run:  rake test TESTOPTS="-v --no-show-detail-immediately" OSSL_MDEBUG=1
        timeout-minutes: 5
        if: ${{ !matrix.fips_enabled }}

      # Run only the passing tests on the FIPS mode as a temporary workaround.
      # TODO Fix other tests, and run all the tests on FIPS mode.
      - name: test on fips mode
        run:  ruby -Ilib test/openssl/test_fips.rb
        if: matrix.fips_enabled