Skip to content

Commit a664af8

Browse files
authored
Merge pull request #784 from rhenium/ky/github-actions-cleanup
Update .github/workflows/test.yml
2 parents ce2a091 + 3651884 commit a664af8

File tree

2 files changed

+66
-77
lines changed

2 files changed

+66
-77
lines changed

.github/workflows/test.yml

Lines changed: 56 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ jobs:
88
with:
99
engine: cruby-truffleruby
1010
min_version: 2.7
11+
1112
test:
1213
needs: ruby-versions
1314
name: >-
@@ -22,8 +23,6 @@ jobs:
2223
exclude:
2324
- { os: windows-latest, ruby: truffleruby }
2425
- { os: windows-latest, ruby: truffleruby-head }
25-
- { os: macos-latest, ruby: truffleruby }
26-
- { os: ubuntu-20.04, ruby: truffleruby }
2726
include:
2827
- { os: windows-latest, ruby: ucrt }
2928
- { os: windows-latest, ruby: mswin }
@@ -43,26 +42,25 @@ jobs:
4342
run: echo "MAKEFLAGS=V=1" >> $GITHUB_ENV
4443
if: runner.os == 'Linux' || runner.os == 'macOS'
4544

46-
- name: set flags to check compiler warnings.
45+
- name: set flags to check compiler warnings
4746
run: echo "RUBY_OPENSSL_EXTCFLAGS=-Werror" >> $GITHUB_ENV
4847
if: ${{ !matrix.skip-warnings }}
4948

50-
- name: compile
49+
- name: rake compile
5150
run: bundle exec rake compile
5251

53-
- name: test
52+
- name: rake test
5453
run: bundle exec rake test TESTOPTS="-v --no-show-detail-immediately"
5554
timeout-minutes: 5
5655

5756
test-openssls:
5857
name: >-
59-
${{ matrix.openssl }} ${{ matrix.name-extra || '' }}
60-
runs-on: ${{ matrix.os }}
58+
${{ matrix.openssl }} ${{ matrix.name-extra }}
59+
runs-on: ubuntu-latest
6160
strategy:
6261
fail-fast: false
6362
matrix:
64-
os: [ ubuntu-latest ]
65-
ruby: [ "3.0" ]
63+
name-extra: [ '' ]
6664
openssl:
6765
# https://openssl-library.org/source/
6866
- openssl-1.0.2u # EOL
@@ -72,6 +70,7 @@ jobs:
7270
- openssl-3.1.6
7371
- openssl-3.2.2
7472
- openssl-3.3.1
73+
- openssl-master
7574
# http://www.libressl.org/releases.html
7675
- libressl-3.1.5 # EOL
7776
- libressl-3.2.7 # EOL
@@ -82,94 +81,87 @@ jobs:
8281
- libressl-3.7.3 # EOL
8382
- libressl-3.8.4
8483
- libressl-3.9.2
85-
fips-enabled: [ false ]
8684
include:
87-
- { os: ubuntu-latest, ruby: "3.0", openssl: openssl-3.0.14, fips-enabled: true, append-configure: 'enable-fips', name-extra: 'fips' }
88-
- { os: ubuntu-latest, ruby: "3.0", openssl: openssl-3.1.6, fips-enabled: true, append-configure: 'enable-fips', name-extra: 'fips' }
89-
- { os: ubuntu-latest, ruby: "3.0", openssl: openssl-3.2.2, fips-enabled: true, append-configure: 'enable-fips', name-extra: 'fips' }
90-
- { os: ubuntu-latest, ruby: "3.0", openssl: openssl-3.3.1, fips-enabled: true, append-configure: 'enable-fips', name-extra: 'fips' }
91-
- { os: ubuntu-latest, ruby: "3.0", openssl: openssl-head, git: 'https://github.com/openssl/openssl.git', branch: 'master' }
92-
- { os: ubuntu-latest, ruby: "3.0", openssl: openssl-head, git: 'https://github.com/openssl/openssl.git', branch: 'master', fips-enabled: true, append-configure: 'enable-fips', name-extra: 'fips' }
93-
- { os: ubuntu-latest, ruby: "3.0", openssl: openssl-head, git: 'https://github.com/openssl/openssl.git', branch: 'master', append-configure: 'no-legacy', name-extra: 'no-legacy' }
85+
- { name-extra: 'with fips provider', openssl: openssl-3.0.14, fips-enabled: true }
86+
- { name-extra: 'with fips provider', openssl: openssl-3.1.6, fips-enabled: true }
87+
- { name-extra: 'with fips provider', openssl: openssl-3.2.2, fips-enabled: true }
88+
- { name-extra: 'with fips provider', openssl: openssl-3.3.1, fips-enabled: true }
89+
- { name-extra: 'with fips provider', openssl: openssl-master, fips-enabled: true }
90+
- { name-extra: 'without legacy provider', openssl: openssl-3.3.1, append-configure: 'no-legacy' }
9491
steps:
9592
- name: repo checkout
9693
uses: actions/checkout@v4
9794

98-
- name: prepare openssl
95+
- id: cache-openssl
96+
uses: actions/cache@v4
97+
with:
98+
path: ~/openssl
99+
key: openssl-${{ runner.os }}-${{ matrix.openssl }}-${{ matrix.append-configure || 'default' }}
100+
if: matrix.openssl != 'openssl-master' && matrix.openssl != 'libressl-master'
101+
102+
- name: Compile OpenSSL library
103+
if: steps.cache-openssl.outputs.cache-hit != 'true'
99104
run: |
100105
# Enable Bash debugging option temporarily for debugging use.
101106
set -x
102107
mkdir -p tmp/build-openssl && cd tmp/build-openssl
103108
case ${{ matrix.openssl }} in
104-
openssl-*)
105-
if [ -z "${{ matrix.git }}" ]; then
106-
curl -OL https://openssl.org/source/${{ matrix.openssl }}.tar.gz
107-
tar xf ${{ matrix.openssl }}.tar.gz && cd ${{ matrix.openssl }}
108-
else
109-
git clone -b ${{ matrix.branch }} --depth 1 ${{ matrix.git }} ${{ matrix.openssl }}
110-
cd ${{ matrix.openssl }}
111-
# Log the commit hash.
112-
echo "Git commit: $(git rev-parse HEAD)"
113-
fi
109+
openssl-1.*)
110+
OPENSSL_COMMIT=$(echo ${{ matrix.openssl }} | sed -e 's/^openssl-/OpenSSL_/' | sed -e 's/\./_/g')
111+
git clone -b $OPENSSL_COMMIT --depth 1 https://github.com/openssl/openssl.git .
112+
echo "Git commit: $(git rev-parse HEAD)"
114113
# shared is required for 1.0.x.
115-
./Configure --prefix=$HOME/.openssl/${{ matrix.openssl }} --libdir=lib \
116-
shared linux-x86_64 ${{ matrix.append-configure }}
117-
make depend
114+
./Configure --prefix=$HOME/openssl --libdir=lib shared linux-x86_64
115+
make depend && make -j4 && make install_sw
116+
;;
117+
openssl-*)
118+
OPENSSL_COMMIT=${{ matrix.openssl == 'openssl-master' && 'master' || matrix.openssl }}
119+
git clone -b $OPENSSL_COMMIT --depth 1 https://github.com/openssl/openssl.git .
120+
echo "Git commit: $(git rev-parse HEAD)"
121+
./Configure --prefix=$HOME/openssl --libdir=lib enable-fips ${{ matrix.append-configure }}
122+
make -j4 && make install_sw && make install_fips
118123
;;
119124
libressl-*)
120-
curl -OL https://ftp.openbsd.org/pub/OpenBSD/LibreSSL/${{ matrix.openssl }}.tar.gz
121-
tar xf ${{ matrix.openssl }}.tar.gz && cd ${{ matrix.openssl }}
122-
./configure --prefix=$HOME/.openssl/${{ matrix.openssl }}
125+
curl -L https://ftp.openbsd.org/pub/OpenBSD/LibreSSL/${{ matrix.openssl }}.tar.gz | \
126+
tar xzf - --strip-components=1
127+
./configure --prefix=$HOME/openssl
128+
make -j4 && make install
123129
;;
124130
*)
125131
false
126132
;;
127133
esac
128-
make -j4
129-
make install_sw
130-
131-
- name: prepare openssl fips
132-
run: make install_fips
133-
working-directory: tmp/build-openssl/${{ matrix.openssl }}
134-
if: matrix.fips-enabled
135-
136-
- name: set the open installed directory
137-
run: >
138-
sed -e "s|OPENSSL_DIR|$HOME/.openssl/${{ matrix.openssl }}|"
139-
tool/openssl_fips.cnf.tmpl > tmp/openssl_fips.cnf
140-
if: matrix.fips-enabled
141-
142-
- name: set openssl config file path for fips.
143-
run: echo "OPENSSL_CONF=$(pwd)/tmp/openssl_fips.cnf" >> $GITHUB_ENV
144-
if: matrix.fips-enabled
145134
146135
- name: load ruby
147136
uses: ruby/setup-ruby@v1
148137
with:
149-
ruby-version: ${{ matrix.ruby }}
150-
151-
- name: depends
152-
run: bundle install
138+
ruby-version: '3.0'
139+
bundler-cache: true
153140

154141
- name: enable mkmf verbose
155142
run: echo "MAKEFLAGS=V=1" >> $GITHUB_ENV
156-
if: runner.os == 'Linux' || runner.os == 'macOS'
157143

158-
- name: set flags to check compiler warnings.
144+
- name: set flags to check compiler warnings
159145
run: echo "RUBY_OPENSSL_EXTCFLAGS=-Werror" >> $GITHUB_ENV
160146
if: ${{ !matrix.skip-warnings }}
161147

162-
- name: compile
163-
run: rake compile -- --with-openssl-dir=$HOME/.openssl/${{ matrix.openssl }}
148+
- name: rake compile
149+
run: bundle exec rake compile -- --with-openssl-dir=$HOME/openssl
164150

165-
- name: test
166-
run: rake test TESTOPTS="-v --no-show-detail-immediately"
151+
- name: setup OpenSSL config file for fips
152+
run: |
153+
sed -e "s|OPENSSL_DIR|$HOME/openssl|" tool/openssl_fips.cnf.tmpl > tmp/openssl_fips.cnf
154+
echo "OPENSSL_CONF=$(pwd)/tmp/openssl_fips.cnf" >> $GITHUB_ENV
155+
if: matrix.fips-enabled
156+
157+
- name: rake test
158+
run: bundle exec rake test TESTOPTS="-v --no-show-detail-immediately"
167159
timeout-minutes: 5
168160
if: ${{ !matrix.fips-enabled }}
169161

170162
# Run only the passing tests on the FIPS module as a temporary workaround.
171163
# TODO Fix other tests, and run all the tests on FIPS module.
172-
- name: test on fips module
173-
run: |
174-
rake test_fips TESTOPTS="-v --no-show-detail-immediately"
164+
- name: rake test_fips
165+
run: bundle exec rake test_fips TESTOPTS="-v --no-show-detail-immediately"
166+
timeout-minutes: 5
175167
if: matrix.fips-enabled

test/openssl/test_pkey_dsa.rb

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,11 @@
44
if defined?(OpenSSL) && defined?(OpenSSL::PKey::DSA)
55

66
class OpenSSL::TestPKeyDSA < OpenSSL::PKeyTestCase
7+
def setup
8+
# May not be available in FIPS mode as DSA has been deprecated in FIPS 186-5
9+
omit_on_fips
10+
end
11+
712
def test_private
813
key = Fixtures.pkey("dsa1024")
914
assert_equal true, key.private?
@@ -31,6 +36,11 @@ def test_new_break
3136
def test_generate
3237
# DSA.generate used to call DSA_generate_parameters_ex(), which adjusts the
3338
# size of q according to the size of p
39+
key1024 = OpenSSL::PKey::DSA.generate(1024)
40+
assert_predicate key1024, :private?
41+
assert_equal 1024, key1024.p.num_bits
42+
assert_equal 160, key1024.q.num_bits
43+
3444
key2048 = OpenSSL::PKey::DSA.generate(2048)
3545
assert_equal 2048, key2048.p.num_bits
3646
assert_equal 256, key2048.q.num_bits
@@ -42,17 +52,6 @@ def test_generate
4252
end
4353
end
4454

45-
def test_generate_on_non_fips
46-
# DSA with 1024 bits is invalid on FIPS 186-4.
47-
# https://github.com/openssl/openssl/commit/49ed5ba8f62875074f04417189147fd3dda072ab
48-
omit_on_fips
49-
50-
key1024 = OpenSSL::PKey::DSA.generate(1024)
51-
assert_predicate key1024, :private?
52-
assert_equal 1024, key1024.p.num_bits
53-
assert_equal 160, key1024.q.num_bits
54-
end
55-
5655
def test_sign_verify
5756
# The DSA valid size is 2048 or 3072 on FIPS.
5857
# https://github.com/openssl/openssl/blob/7649b5548e5c0352b91d9d3ed695e42a2ac1e99c/providers/common/securitycheck.c#L185-L188
@@ -135,8 +134,6 @@ def test_DSAPrivateKey
135134
end
136135

137136
def test_DSAPrivateKey_encrypted
138-
omit_on_fips
139-
140137
# key = abcdef
141138
dsa512 = Fixtures.pkey("dsa512")
142139
pem = <<~EOF

0 commit comments

Comments
 (0)