Skip to content

Commit 9bcc9f4

Browse files
committed
Update .github/workflows/test.yml
This include the following changes: - Use Bundler cache provided by ruby/actions. "bundle install" is no longer necessary. Rake must be invoked through "bundle exec". - Use OpenSSL source from GitHub openssl/openssl tags. - Cache compiled OpenSSL/LibreSSL when possible. - Change no-legacy tests to use OpenSSL 3.3 to allow caching. - Add timeout for "rake test_fips". - Misc formatting cleanup.
1 parent ce2a091 commit 9bcc9f4

File tree

1 file changed

+56
-62
lines changed

1 file changed

+56
-62
lines changed

.github/workflows/test.yml

Lines changed: 56 additions & 62 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: >-
@@ -43,26 +44,25 @@ jobs:
4344
run: echo "MAKEFLAGS=V=1" >> $GITHUB_ENV
4445
if: runner.os == 'Linux' || runner.os == 'macOS'
4546

46-
- name: set flags to check compiler warnings.
47+
- name: set flags to check compiler warnings
4748
run: echo "RUBY_OPENSSL_EXTCFLAGS=-Werror" >> $GITHUB_ENV
4849
if: ${{ !matrix.skip-warnings }}
4950

50-
- name: compile
51+
- name: rake compile
5152
run: bundle exec rake compile
5253

53-
- name: test
54+
- name: rake test
5455
run: bundle exec rake test TESTOPTS="-v --no-show-detail-immediately"
5556
timeout-minutes: 5
5657

5758
test-openssls:
5859
name: >-
59-
${{ matrix.openssl }} ${{ matrix.name-extra || '' }}
60-
runs-on: ${{ matrix.os }}
60+
${{ matrix.openssl }} ${{ matrix.name-extra }}
61+
runs-on: ubuntu-latest
6162
strategy:
6263
fail-fast: false
6364
matrix:
64-
os: [ ubuntu-latest ]
65-
ruby: [ "3.0" ]
65+
name-extra: [ '' ]
6666
openssl:
6767
# https://openssl-library.org/source/
6868
- openssl-1.0.2u # EOL
@@ -72,6 +72,7 @@ jobs:
7272
- openssl-3.1.6
7373
- openssl-3.2.2
7474
- openssl-3.3.1
75+
- openssl-master
7576
# http://www.libressl.org/releases.html
7677
- libressl-3.1.5 # EOL
7778
- libressl-3.2.7 # EOL
@@ -82,94 +83,87 @@ jobs:
8283
- libressl-3.7.3 # EOL
8384
- libressl-3.8.4
8485
- libressl-3.9.2
85-
fips-enabled: [ false ]
8686
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' }
87+
- { name-extra: 'with fips provider', openssl: openssl-3.0.14, fips-enabled: true }
88+
- { name-extra: 'with fips provider', openssl: openssl-3.1.6, fips-enabled: true }
89+
- { name-extra: 'with fips provider', openssl: openssl-3.2.2, fips-enabled: true }
90+
- { name-extra: 'with fips provider', openssl: openssl-3.3.1, fips-enabled: true }
91+
- { name-extra: 'with fips provider', openssl: openssl-master, fips-enabled: true }
92+
- { name-extra: 'without legacy provider', openssl: openssl-3.3.1, append-configure: 'no-legacy' }
9493
steps:
9594
- name: repo checkout
9695
uses: actions/checkout@v4
9796

98-
- name: prepare openssl
97+
- id: cache-openssl
98+
uses: actions/cache@v4
99+
with:
100+
path: ~/openssl
101+
key: openssl-${{ runner.os }}-${{ matrix.openssl }}-${{ matrix.append-configure || 'default' }}
102+
if: matrix.openssl != 'openssl-master' && matrix.openssl != 'libressl-master'
103+
104+
- name: Compile OpenSSL library
105+
if: steps.cache-openssl.outputs.cache-hit != 'true'
99106
run: |
100107
# Enable Bash debugging option temporarily for debugging use.
101108
set -x
102109
mkdir -p tmp/build-openssl && cd tmp/build-openssl
103110
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
111+
openssl-1.*)
112+
OPENSSL_COMMIT=$(echo ${{ matrix.openssl }} | sed -e 's/^openssl-/OpenSSL_/' | sed -e 's/\./_/g')
113+
git clone -b $OPENSSL_COMMIT --depth 1 https://github.com/openssl/openssl.git .
114+
echo "Git commit: $(git rev-parse HEAD)"
114115
# 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
116+
./Configure --prefix=$HOME/openssl --libdir=lib shared linux-x86_64
117+
make depend && make -j4 && make install_sw
118+
;;
119+
openssl-*)
120+
OPENSSL_COMMIT=${{ matrix.openssl == 'openssl-master' && 'master' || matrix.openssl }}
121+
git clone -b $OPENSSL_COMMIT --depth 1 https://github.com/openssl/openssl.git .
122+
echo "Git commit: $(git rev-parse HEAD)"
123+
./Configure --prefix=$HOME/openssl --libdir=lib enable-fips ${{ matrix.append-configure }}
124+
make -j4 && make install_sw && make install_fips
118125
;;
119126
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 }}
127+
curl -L https://ftp.openbsd.org/pub/OpenBSD/LibreSSL/${{ matrix.openssl }}.tar.gz | \
128+
tar xzf - --strip-components=1
129+
./configure --prefix=$HOME/openssl
130+
make -j4 && make install
123131
;;
124132
*)
125133
false
126134
;;
127135
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
145136
146137
- name: load ruby
147138
uses: ruby/setup-ruby@v1
148139
with:
149-
ruby-version: ${{ matrix.ruby }}
150-
151-
- name: depends
152-
run: bundle install
140+
ruby-version: '3.0'
141+
bundler-cache: true
153142

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

158-
- name: set flags to check compiler warnings.
146+
- name: set flags to check compiler warnings
159147
run: echo "RUBY_OPENSSL_EXTCFLAGS=-Werror" >> $GITHUB_ENV
160148
if: ${{ !matrix.skip-warnings }}
161149

162-
- name: compile
163-
run: rake compile -- --with-openssl-dir=$HOME/.openssl/${{ matrix.openssl }}
150+
- name: rake compile
151+
run: bundle exec rake compile -- --with-openssl-dir=$HOME/openssl
164152

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

170164
# Run only the passing tests on the FIPS module as a temporary workaround.
171165
# 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"
166+
- name: rake test_fips
167+
run: bundle exec rake test_fips TESTOPTS="-v --no-show-detail-immediately"
168+
timeout-minutes: 5
175169
if: matrix.fips-enabled

0 commit comments

Comments
 (0)