Skip to content

Commit fd56c4d

Browse files
committed
Lift CI updates from mozilla/neqo
1 parent 2d2bbcc commit fd56c4d

17 files changed

Lines changed: 341 additions & 256 deletions

File tree

.github/actionlint.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,4 @@ self-hosted-runner:
44
labels:
55
- moonshot
66
- moonshot-exp
7+
- codspeed-macro

.github/actions/check-android/action.yml

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -20,17 +20,14 @@ inputs:
2020
minimum-nss-version:
2121
description: 'If NSS is required, the minimum version required.'
2222
default: ''
23-
codecov-token:
24-
description: 'Codecov token, if Codecov upload is desired.'
25-
default: ''
2623
github-token:
2724
description: 'A Github PAT'
2825
required: true
2926

3027
runs:
3128
using: composite
3229
steps:
33-
- uses: actions/setup-java@dded0888837ed1f317902acf8a20df0ad188d165 # v5.0.0
30+
- uses: actions/setup-java@f2beeb24e141e01a676f977032f5a29d81c9e27e # v5.1.0
3431
with:
3532
distribution: zulu
3633
java-version: 23
@@ -94,19 +91,11 @@ runs:
9491
EOF
9592
chmod a+x /tmp/rust-android-run-tests-on-emulator.sh
9693
97-
- uses: reactivecircus/android-emulator-runner@1dcd0090116d15e7c562f8db72807de5e036a4ed # v2.34.0
94+
- uses: reactivecircus/android-emulator-runner@b530d96654c385303d652368551fb075bc2f0b6b # v2.35.0
9895
with:
9996
api-level: ${{ inputs.api-level }}
10097
arch: ${{ startsWith(inputs.target, 'x86_64') && 'x86_64' || (startsWith(inputs.target, 'i686') && 'x86' || (startsWith(inputs.target, 'aarch64') && 'arm64-v8a')) }}
10198
ndk: ${{ inputs.ndk-version }}
10299
emulator-boot-timeout: 120
103100
disk-size: 2G
104101
script: /tmp/rust-android-run-tests-on-emulator.sh
105-
106-
- if: ${{ inputs.codecov-token != '' }}
107-
uses: codecov/codecov-action@fdcc8476540edceab3de004e990f80d881c6cc00 # v5.5.0
108-
with:
109-
files: lcov.info
110-
fail_ci_if_error: false
111-
token: ${{ inputs.codecov-token }}
112-
verbose: true

.github/actions/check-vm/action.yml

Lines changed: 25 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ runs:
3030
freebsd) pkg install -y curl llvm nss pkgconf
3131
;;
3232
openbsd) # TODO: Is there a way to not pin the version of llvm? -z to pkg_add does not work.
33-
pkg_add rust rust-clippy rust-rustfmt llvm-19.1.7p3 nss pkgconf # rustup does not support OpenBSD at all
33+
pkg_add rust rust-clippy rust-rustfmt llvm-21.1.2p0 nss # rustup does not support OpenBSD at all
3434
;;
3535
netbsd) /usr/sbin/pkg_add pkgin && pkgin -y install curl clang nss pkgconf
3636
;;
@@ -56,9 +56,9 @@ runs:
5656
freebsd) sh rustup.sh --default-toolchain stable --profile minimal --component clippy,llvm-tools,rustfmt -y
5757
. "\$HOME/.cargo/env"
5858
;;
59-
openbsd) export LIBCLANG_PATH=/usr/local/llvm19/lib
60-
export LLVM_COV=/usr/local/llvm19/bin/llvm-cov
61-
export LLVM_PROFDATA=/usr/local/llvm19/bin/llvm-profdata
59+
openbsd) export LIBCLANG_PATH=/usr/local/llvm21/lib
60+
export LLVM_COV=/usr/local/llvm21/bin/llvm-cov
61+
export LLVM_PROFDATA=/usr/local/llvm21/bin/llvm-profdata
6262
[ "$WORKSPACE" ] && EXCLUDE="--exclude fuzz" # Fuzzing not supported on OpenBSD
6363
;;
6464
netbsd) sh rustup.sh --default-toolchain stable --profile minimal --component clippy,llvm-tools,rustfmt -y
@@ -86,7 +86,7 @@ runs:
8686
cargo fmt --all -- --check
8787
case "$PLATFORM" in
8888
freebsd) cargo install cargo-llvm-cov --locked
89-
cargo llvm-cov test --locked --no-fail-fast --lcov --output-path lcov.info
89+
cargo llvm-cov test --locked --no-fail-fast --codecov --output-path codecov.json
9090
;;
9191
*) # FIXME: No profiler support on other platforms, error is: cannot find crate for profiler_builtins
9292
cargo test --locked --no-fail-fast # We do this instead for now
@@ -102,45 +102,57 @@ runs:
102102
} >> "$GITHUB_OUTPUT"
103103
104104
curl -o "$WD/rustup.sh" --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs
105-
echo "envs=CARGO_TERM_COLOR RUST_BACKTRACE RUST_LOG GITHUB_ACTIONS RUST_TEST_TIME_UNIT RUST_TEST_TIME_INTEGRATION RUST_TEST_TIME_DOCTEST WD" >> "$GITHUB_OUTPUT"
105+
echo "envs=CARGO_TERM_COLOR RUST_BACKTRACE RUST_LOG RUST_TEST_TIME_UNIT RUST_TEST_TIME_INTEGRATION RUST_TEST_TIME_DOCTEST WD" >> "$GITHUB_OUTPUT"
106106
107107
- if: ${{ inputs.platform == 'freebsd' }}
108-
uses: vmactions/freebsd-vm@966989c456d41351f095a421f60e71342d3bce41 # v1.2.1
108+
uses: vmactions/freebsd-vm@ba6bedee4a4884da2b782a41a64329a1c8e42ffb # v1.3.8
109109
with:
110110
usesh: true
111+
disable-cache: true
111112
envs: ${{ steps.prep.outputs.envs }}
112113
prepare: ${{ steps.prep.outputs.prepare }}
113114
run: ${{ steps.prep.outputs.run }}
114115

115116
- if: ${{ inputs.platform == 'openbsd' }}
116-
uses: vmactions/openbsd-vm@0d65352eee1508bab7cb12d130536d3a556be487 # v1.1.8
117+
uses: vmactions/openbsd-vm@f5b9bc1261c3d4eed9639fcae0cf5dcc5374ca0c # v1.3.2
117118
with:
118119
usesh: true
120+
disable-cache: true
119121
envs: ${{ steps.prep.outputs.envs }}
120122
prepare: ${{ steps.prep.outputs.prepare }}
121123
run: ${{ steps.prep.outputs.run }}
122124

123125
- if: ${{ inputs.platform == 'netbsd' }}
124-
uses: vmactions/netbsd-vm@d0228be27fbaba19418cc1b332609a895cf16561 # v1.1.9
126+
uses: vmactions/netbsd-vm@37b614756f0b44b02f5dab4fd9ecb27545d1785e # v1.3.2
125127
with:
126128
usesh: true
129+
disable-cache: true
127130
envs: ${{ steps.prep.outputs.envs }}
128131
prepare: ${{ steps.prep.outputs.prepare }}
129132
run: ${{ steps.prep.outputs.run }}
130133

131134
- if: ${{ inputs.platform == 'solaris' }}
132-
uses: vmactions/solaris-vm@58cbd70c6e051860f9b8f65908cc582938fbbdba # v1.1.5
135+
uses: vmactions/solaris-vm@37d40b6627e80434541454b42841caa4cc77d0cf # v1.2.7
133136
with:
134137
release: "11.4-gcc"
135138
usesh: true
139+
disable-cache: true
136140
envs: ${{ steps.prep.outputs.envs }}
137141
prepare: ${{ steps.prep.outputs.prepare }}
138142
run: ${{ steps.prep.outputs.run }}
139143

140-
- if: ${{ inputs.codecov-token != '' }}
141-
uses: codecov/codecov-action@fdcc8476540edceab3de004e990f80d881c6cc00 # v5.5.0
144+
- id: check-coverage
145+
shell: bash
146+
env:
147+
WORKING_DIR: ${{ inputs.working-directory }}
148+
run: test -f "$WORKING_DIR/codecov.json" && echo "exists=true" >> "$GITHUB_OUTPUT" || true
149+
150+
- if: ${{ steps.check-coverage.outputs.exists == 'true' }}
151+
uses: codecov/codecov-action@671740ac38dd9b0130fbe1cec585b89eea48d3de # v5.5.2
142152
with:
143-
files: lcov.info
153+
files: codecov.json
154+
working-directory: ${{ inputs.working-directory }}
144155
fail_ci_if_error: false
145156
token: ${{ inputs.codecov-token }}
146157
verbose: true
158+
flags: ${{ inputs.platform }}

.github/actions/nss/action.yml

Lines changed: 60 additions & 71 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,6 @@ name: Install NSS
22
description: Install NSS
33

44
inputs:
5-
type:
6-
description: "When building, whether to do a debug or release build of NSS"
7-
default: "Release"
85
minimum-version:
96
description: "Minimum required version of NSS"
107
required: true
@@ -17,16 +14,16 @@ runs:
1714
steps:
1815
- name: Install system NSS (Linux)
1916
shell: bash
20-
if: ${{ runner.os == 'Linux' && runner.environment == 'github-hosted' && inputs.target == '' }}
17+
if: ${{ runner.os == 'Linux' && inputs.target == '' && (runner.environment != 'self-hosted' || contains(runner.name, 'CodSpeed')) }}
2118
env:
2219
DEBIAN_FRONTEND: noninteractive
2320
run: |
2421
[ "$APT_UPDATED" ] || sudo apt-get update && echo "APT_UPDATED=1" >> "$GITHUB_ENV"
25-
sudo apt-get install -y --no-install-recommends libnss3-dev pkg-config
22+
sudo apt-get install -y --no-install-recommends libnss3-dev
2623
2724
- name: Install system NSS (MacOS)
2825
shell: bash
29-
if: ${{ runner.os == 'MacOS' && runner.environment == 'github-hosted' && inputs.target == '' }}
26+
if: ${{ runner.os == 'MacOS' && inputs.target == '' }}
3027
run: |
3128
[ "$BREW_UPDATED" ] || brew update && echo "BREW_UPDATED=1" >> "$GITHUB_ENV"
3229
brew install nss
@@ -38,25 +35,9 @@ runs:
3835
shell: bash
3936
if: inputs.target == ''
4037
run: |
41-
if ! command -v pkg-config &> /dev/null; then
42-
echo "pkg-config: not found"
43-
exit 0
44-
fi
45-
if ! pkg-config --exists nss; then
46-
echo "pkg-config: NSS not found"
47-
exit 0
48-
fi
49-
NSS_VERSION="$(pkg-config --modversion nss)"
50-
if [ "$?" -ne 0 ]; then
51-
echo "pkg-config: failed to determine NSS version"
52-
exit 0
53-
fi
54-
NSS_MAJOR=$(echo "$NSS_VERSION" | cut -d. -f1)
55-
NSS_MINOR=$(echo "$NSS_VERSION" | cut -d. -f2)
56-
REQ_NSS_MAJOR=$(echo "$MIN_VERSION" | cut -d. -f1)
57-
REQ_NSS_MINOR=$(echo "$MIN_VERSION" | cut -d. -f2)
58-
if [[ "$NSS_MAJOR" -lt "$REQ_NSS_MAJOR" || "$NSS_MAJOR" -eq "$REQ_NSS_MAJOR" && "$NSS_MINOR" -lt "$REQ_NSS_MINOR" ]]; then
59-
echo "System NSS is too old: $NSS_VERSION"
38+
if ! pkg-config --atleast-version "$MIN_VERSION" nss; then
39+
echo -n "System NSS needs ${MIN_VERSION}, got "
40+
pkg-config --modversion nss 2>/dev/null || echo "pkg-config error"
6041
exit 0
6142
fi
6243
echo "System NSS is suitable: $NSS_VERSION"
@@ -69,11 +50,11 @@ runs:
6950
#
7051
# Also, only enable sscache on our self-hosted runner, because the GitHub cache limit
7152
# is too small for this to be effective there.
72-
if: ${{ env.SCCACHE_ENABLED != '1' && !steps.system_nss.outputs.suitable && runner.environment != 'github-hosted' }}
73-
uses: mozilla-actions/sccache-action@2e7f9ec7921547d4b46598398ca573513895d0bd # v0.0.4
53+
if: ${{ env.SCCACHE_ENABLED != '1' && !steps.system_nss.outputs.suitable && runner.environment == 'self-hosted' && !contains(runner.name, 'CodSpeed') }}
54+
uses: mozilla-actions/sccache-action@7d986dd989559c6ecdb630a3fd2557667be217ad # v0.0.9
7455

7556
- name: Enable sscache
76-
if: ${{ !steps.system_nss.outputs.suitable && runner.environment != 'github-hosted' }}
57+
if: ${{ !steps.system_nss.outputs.suitable && runner.environment == 'self-hosted' && !contains(runner.name, 'CodSpeed') }}
7758
env:
7859
RUNNER_ENVIRONMENT: ${{ runner.environment }}
7960
RUNNER_OS: ${{ runner.os }}
@@ -87,54 +68,61 @@ runs:
8768
fi
8869
echo "CMAKE_C_COMPILER_LAUNCHER=sccache" >> "$GITHUB_ENV"
8970
echo "CMAKE_CXX_COMPILER_LAUNCHER=sccache" >> "$GITHUB_ENV"
90-
if [ "$RUNNER_ENVIRONMENT" == "github-hosted" ]; then
91-
echo "SCCACHE_GHA_ENABLED=true" >> "$GITHUB_ENV"
92-
fi
71+
echo "SCCACHE_GHA_ENABLED=true" >> "$GITHUB_ENV"
9372
94-
- name: Checkout NSS
73+
- name: Retrieve NSS
74+
id: nss
9575
if: ${{ !steps.system_nss.outputs.suitable }}
96-
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
97-
with:
98-
repository: nss-dev/nss
99-
path: nss
100-
persist-credentials: false
76+
shell: bash
77+
env:
78+
NSS_VERSION: "3.120" # TODO: Bump this periodically; also in qns/Dockerfile. Trailing zeroes are stripped w/o quotes!
79+
run: |
80+
NSS_TAG="${NSS_VERSION//./_}"
81+
NSS_URL="https://ftp.mozilla.org/pub/security/nss/releases/NSS_${NSS_TAG}_RTM/src/nss-${NSS_VERSION}.tar.gz"
82+
echo "Retrieving NSS $NSS_VERSION from $NSS_URL"
83+
curl -L "$NSS_URL" | tar xz --strip-components=1
84+
echo "version=$NSS_VERSION" >> "$GITHUB_OUTPUT"
10185
10286
- name: Retrieve NSPR
10387
id: nspr
10488
if: ${{ !steps.system_nss.outputs.suitable }}
10589
shell: bash
10690
env:
107-
NSPR_VERSION: 4.37 # This changes so rarely that we can hardcode it.
91+
NSPR_VERSION: "4.38.2" # TODO: Bump this periodically; also in qns/Dockerfile. Trailing zeroes are stripped w/o quotes!
10892
run: |
109-
curl -L https://ftp.mozilla.org/pub/nspr/releases/v$NSPR_VERSION/src/nspr-$NSPR_VERSION.tar.gz |
110-
tar xz --strip-components=1
93+
NSPR_URL="https://ftp.mozilla.org/pub/nspr/releases/v$NSPR_VERSION/src/nspr-$NSPR_VERSION.tar.gz"
94+
echo "Retrieving NSPR $NSPR_VERSION from $NSPR_URL"
95+
curl -L "$NSPR_URL" | tar xz --strip-components=1
11196
echo "version=$NSPR_VERSION" >> "$GITHUB_OUTPUT"
11297
113-
- name: Store NSS version
114-
id: nss
115-
if: ${{ !steps.system_nss.outputs.suitable }}
98+
- name: Store Ubuntu release code name (Linux)
99+
id: ubuntu_release
116100
shell: bash
101+
if: ${{ runner.os == 'Linux' && !steps.system_nss.outputs.suitable }}
117102
run: |
118-
NSS_HEAD=$(git -C nss rev-parse HEAD)
119-
echo "version=$NSS_HEAD" >> "$GITHUB_OUTPUT"
120-
121-
- name: Cache NSS
103+
# Store Ubuntu release codename for use in cache key.
104+
. /etc/os-release
105+
echo "codename=-$UBUNTU_CODENAME" >> "$GITHUB_OUTPUT"
106+
107+
# Use restore-only here so PRs don't create redundant caches. PRs restore
108+
# from main; only main saves new caches. This reduces churn and evictions.
109+
# Downside: PRs that change NSS version/build will rebuild on every CI run.
110+
- name: Restore NSS cache
122111
id: cache
123-
if: ${{ !steps.system_nss.outputs.suitable && runner.environment == 'github-hosted' }}
124-
uses: actions/cache@0400d5f644dc74513175e3cd8d07132dd4860809 # v4.2.4
112+
if: ${{ !steps.system_nss.outputs.suitable }}
113+
uses: actions/cache/restore@0057852bfaa89a56745cba8c7296529d2fc39830 # v4.3.0
125114
with:
126115
path: dist
127-
key: nss-${{ inputs.target && inputs.target || runner.os }}-${{ runner.arch }}-${{ inputs.type }}-${{ steps.nss.outputs.version }}-${{ steps.nspr.outputs.version }}
116+
key: nss-${{ inputs.target || runner.os }}${{ steps.ubuntu_release.outputs.codename }}-${{ runner.arch }}-${{ steps.nss.outputs.version }}-${{ steps.nspr.outputs.version }}
128117

129118
- name: Check if build is needed
130119
id: check_build
131120
if: ${{ !steps.system_nss.outputs.suitable }}
132121
env:
133122
CACHE_HIT: ${{ steps.cache.outputs.cache-hit }}
134-
RUNNER_ENVIRONMENT: ${{ runner.environment }}
135123
shell: bash
136124
run: |
137-
if [ "$RUNNER_ENVIRONMENT" != "github-hosted" ] || [ ! "$CACHE_HIT" ]; then
125+
if [ "$CACHE_HIT" != "true" ]; then
138126
echo "Building NSS from source"
139127
echo "build_nss=1" >> "$GITHUB_OUTPUT"
140128
else
@@ -143,7 +131,7 @@ runs:
143131
144132
- name: Install build dependencies (Linux)
145133
shell: bash
146-
if: ${{ runner.os == 'Linux' && steps.check_build.outputs.build_nss && runner.environment == 'github-hosted' }}
134+
if: ${{ runner.os == 'Linux' && steps.check_build.outputs.build_nss && (runner.environment != 'self-hosted' || contains(runner.name, 'CodSpeed')) }}
147135
env:
148136
DEBIAN_FRONTEND: noninteractive
149137
run: sudo apt-get install -y --no-install-recommends gyp ninja-build
@@ -191,17 +179,14 @@ runs:
191179
shell: bash
192180
if: ${{ !steps.system_nss.outputs.suitable }}
193181
env:
194-
NSS_TARGET: ${{ inputs.type }}
195-
NSS_TYPE: ${{ inputs.type }}
196182
NSS_DIR: ${{ github.workspace }}/nss
197183
RUNNER_OS: ${{ runner.os }}
198184
WORKSPACE: ${{ github.workspace }}
199185
run: | # zizmor: ignore[github-env] We need to write to GITHUB_PATH on Windows.
200-
NSS_OUT="$WORKSPACE/dist/$NSS_TARGET"
186+
NSS_OUT="$WORKSPACE/dist/Release"
201187
{
202188
echo "LD_LIBRARY_PATH=$NSS_OUT/lib"
203189
echo "DYLD_FALLBACK_LIBRARY_PATH=$NSS_OUT/lib"
204-
echo "NSS_TARGET=$NSS_TARGET"
205190
echo "NSS_DIR=$NSS_DIR"
206191
echo "NSS_PREBUILT=1"
207192
} >> "$GITHUB_ENV"
@@ -216,13 +201,10 @@ runs:
216201
TARGET_PLATFORM: ${{ inputs.target }}
217202
RUNNER_OS: ${{ runner.os }}
218203
run: |
219-
if [ "$NSS_TARGET" != "Debug" ]; then
220-
# We want to do an optimized build for accurate CPU profiling, but
221-
# we also want debug symbols and frame pointers for that, which the normal optimized NSS
222-
# build process doesn't provide.
223-
OPT="-o"
224-
[ "$RUNNER_OS" != "Windows" ] && export CFLAGS="-ggdb3 -fno-omit-frame-pointer"
225-
fi
204+
# We want to do an optimized build for accurate CPU profiling, but
205+
# we also want debug symbols and frame pointers for that, which the normal optimized NSS
206+
# build process doesn't provide.
207+
[ "$RUNNER_OS" != "Windows" ] && export CFLAGS="-ggdb3 -fno-omit-frame-pointer"
226208
if [[ $TARGET_PLATFORM == *-android* ]]; then
227209
for file in build-nss-android.sh build-android-common.sh; do
228210
curl -o "$file" -sSf "https://raw.githubusercontent.com/mozilla/application-services/refs/tags/v137.0/libs/$file"
@@ -238,12 +220,12 @@ runs:
238220
find /tmp/tmp.* > tmp
239221
CERTUTIL="$(grep certutil tmp)"
240222
TARGET_DIR="$(dirname $(dirname $CERTUTIL))"
241-
mkdir -p "dist/$NSS_TARGET"
242-
cp -vaL "$TARGET_DIR"/* "dist/$NSS_TARGET/"
223+
mkdir -p "dist/Release"
224+
cp -vaL "$TARGET_DIR"/* "dist/Release/"
243225
NSPR_H="$(grep nspr.h tmp)"
244226
INCLUDE_DIR="$(dirname $NSPR_H)"
245-
mkdir -p "dist/$NSS_TARGET/include/nspr"
246-
cp -vaL "$INCLUDE_DIR"/* "dist/$NSS_TARGET/include/nspr"
227+
mkdir -p "dist/Release/include/nspr"
228+
cp -vaL "$INCLUDE_DIR"/* "dist/Release/include/nspr"
247229
CHACHA="$(grep chacha20poly1305.h tmp)"
248230
PRIVATE_DIR="$(dirname $(dirname $CHACHA))"
249231
mkdir -p "dist/private"
@@ -254,9 +236,16 @@ runs:
254236
cp -vaL "$PUBLIC_DIR"/* "dist/"
255237
LIBNSPR4="$(grep lib/libnspr4.a tmp)"
256238
LIB_DIR="$(dirname $LIBNSPR4)"
257-
mkdir -p "dist/$NSS_TARGET/lib"
258-
cp -vaL "$LIB_DIR"/* "dist/$NSS_TARGET/lib"
239+
mkdir -p "dist/Release/lib"
240+
cp -vaL "$LIB_DIR"/* "dist/Release/lib"
259241
else
260242
[ "$SCCACHE_CC" ] && [ "$SCCACHE_CXX" ] && export CC="$SCCACHE_CC" CXX="$SCCACHE_CXX"
261-
$NSS_DIR/build.sh -g -Ddisable_tests=1 -Ddisable_dbm=1 -Ddisable_libpkix=1 -Ddisable_ckbi=1 -Ddisable_fips=1 $OPT --static
243+
$NSS_DIR/build.sh -g -Ddisable_tests=1 -Ddisable_dbm=1 -Ddisable_libpkix=1 -Ddisable_ckbi=1 -Ddisable_fips=1 --opt --static
262244
fi
245+
246+
- name: Save NSS cache
247+
if: ${{ steps.check_build.outputs.build_nss && github.event_name != 'pull_request' }}
248+
uses: actions/cache/save@0057852bfaa89a56745cba8c7296529d2fc39830 # v4.3.0
249+
with:
250+
path: dist
251+
key: nss-${{ inputs.target || runner.os }}${{ steps.ubuntu_release.outputs.codename }}-${{ runner.arch }}-${{ steps.nss.outputs.version }}-${{ steps.nspr.outputs.version }}

0 commit comments

Comments
 (0)