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
|
name: tarball-ubuntu (reusable)
on:
workflow_call:
inputs:
archname:
description: 'archname (e.g. snapshot-master, snapshot-ruby_3_3)'
required: true
type: string
notify-release-channel:
description: 'Also send failure notifications to SNAPSHOT_SLACK_WEBHOOK_URL (schedule/release builds).'
required: false
type: boolean
default: false
secrets:
SIMPLER_ALERTS_URL:
required: false
SNAPSHOT_SLACK_WEBHOOK_URL:
required: false
permissions:
contents: read
jobs:
ubuntu:
strategy:
matrix:
test_task: [check, test-bundler-parallel, test-bundled-gems]
os: [ubuntu-24.04, ubuntu-22.04]
fail-fast: false
runs-on: ${{ matrix.os }}
env:
ARCHNAME: ${{ inputs.archname }}
steps:
- uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
with:
name: Packages
path: pkg
- name: Extract
run: tar xf pkg/*.tar.xz
- name: Install libraries
run: |
set -x
sudo apt-get update -q
sudo apt-get install --no-install-recommends -q -y build-essential libssl-dev libyaml-dev zlib1g-dev libffi-dev libgmp-dev bison- autoconf-
- uses: ruby/setup-ruby@afeafc3d1ab54a631816aba4c914a0081c12ff2f # v1.310.0
with:
ruby-version: '3.2'
# test-bundled-gems requires executable host ruby
if: matrix.test_task == 'test-bundled-gems'
- name: Fixed world writable dirs
run: |
mkdir -p $HOME/.local/share
mkdir -p $HOME/.cache/gem/specs
mkdir -p $HOME/.bundle/cache
mkdir -p $HOME/.ssh
chmod a-w $HOME/.bundle
# chmod a-w $HOME
# allow to write $HOME and check stats of HOME around tests (see below)
chmod -v a-w $HOME/.config
sudo chmod -R a-w /usr/share
sudo bash -c 'IFS=:; for d in '"$PATH"'; do chmod -v a-w $d; done' || :
- name: Set ENV
run: |
echo "JOBS=-j$((1 + $(nproc --all)))" >> $GITHUB_ENV
- name: configure
run: cd "$ARCHNAME/" && ./configure
- name: make
run: cd "$ARCHNAME/" && make $JOBS
- name: Save stats of HOME
run: |
set -euxo pipefail
cat >"$ARCHNAME/save-stats.rb" <<'EOF'
require 'pathname'
require 'digest'
out = []
[
Dir.home,
].each do |dir|
Dir.each_child(dir) do |name|
pn = File.join(dir, name)
st = File.stat(pn)
if st.file?
content = Digest::SHA1.file(pn).hexdigest
elsif st.directory? && st.nlink <= 10
content = Dir.children(pn).sort
end
out << [pn, "%o"%st.mode, st.nlink, st.uid, st.gid, st.size, content].to_s
rescue
out << [pn, $!.inspect].to_s
end
end
File.open(ARGV.shift, "w") do |io|
io.puts out.sort
end
EOF
make -C "$ARCHNAME" TESTRUN_SCRIPT=save-stats.rb RUNOPT=/tmp/stat-before-tests.txt runruby
- name: Tests
run: cd "$ARCHNAME/" && make $JOBS -s ${{ matrix.test_task }}
env:
RUBY_TESTOPTS: "-q --tty=no"
# test_sync_default_gems triggers gpg, whose agent processes leave
# $HOME/.gnupg around even when GNUPGHOME points elsewhere.
- name: Forcibly remove ~/.gnupg
run: rm -rf $HOME/.gnupg
- name: Diff stats of HOME
run: |
make -C "$ARCHNAME" TESTRUN_SCRIPT=save-stats.rb RUNOPT=/tmp/stat-after-tests.txt runruby
rm -f "$ARCHNAME/save-stats.rb"
diff -u /tmp/stat-before-tests.txt /tmp/stat-after-tests.txt
# leaked-globals since 2.7
- name: Leaked Globals
run: cd "$ARCHNAME/" && make -s leaked-globals
if: matrix.test_task == 'check'
- name: make install without root privilege
run: cd "$ARCHNAME/" && make $JOBS install DESTDIR="/tmp/destdir"
if: matrix.test_task == 'check'
- name: make install
run: cd "$ARCHNAME/" && sudo make $JOBS install
if: matrix.test_task == 'check'
- name: Verify installed binaries
run: |
/usr/local/bin/ruby -v
/usr/local/bin/gem -v
/usr/local/bin/bundle -v
if: matrix.test_task == 'check'
- name: Show .local
run: find $HOME/.local -ls
- uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3
with:
sparse-checkout: .github/actions/slack
sparse-checkout-cone-mode: false
persist-credentials: false
if: ${{ failure() }}
- uses: ./.github/actions/slack
with:
label: "${{ matrix.os }} / ${{ matrix.test_task }}"
SLACK_WEBHOOK_URL: ${{ secrets.SIMPLER_ALERTS_URL }} # ruby-lang slack: ruby/simpler-alerts-bot
if: ${{ failure() }}
- uses: ruby/action-slack@d260b61aa817726d5bedd22dd6cc305787fa4cdd # v4.0.0
with:
payload: |
{
"attachments": [{
"text": "${{ job.status }}: ${{ matrix.os }} / ${{ matrix.test_task }} <https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}|${{ inputs.archname }}>",
"color": "danger"
}]
}
env:
SLACK_WEBHOOK_URL: ${{ secrets.SNAPSHOT_SLACK_WEBHOOK_URL }}
if: failure() && inputs.notify-release-channel
|