Skip to content

Commit a1045c3

Browse files
authored
fix(ci): prevent flaky keyring tests by keeping daemons alive (#2963)
D-Bus and gnome-keyring-daemon were initialized in a separate CI step from test execution. The daemons could die between steps, causing IsLocked errors ~10-20%. Move initialization into the test shell itself.
1 parent c70ff95 commit a1045c3

File tree

2 files changed

+16
-8
lines changed

2 files changed

+16
-8
lines changed

.github/actions/rust/pre-merge/action.yml

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -96,10 +96,6 @@ runs:
9696
run: |
9797
sudo apt-get update --yes && sudo apt-get install --yes musl-tools gnome-keyring keyutils dbus-x11 libsecret-tools
9898
rm -f $HOME/.local/share/keyrings/*
99-
eval $(dbus-launch --sh-syntax)
100-
echo "DBUS_SESSION_BUS_ADDRESS=$DBUS_SESSION_BUS_ADDRESS" >> $GITHUB_ENV
101-
eval $(echo -n "test" | gnome-keyring-daemon --unlock --components=secrets)
102-
echo -n "warmup" | secret-tool store --label="ci-warmup" ci-test warmup
10399
shell: bash
104100

105101
- name: Install cargo-llvm-cov
@@ -111,6 +107,15 @@ runs:
111107
- name: Build and test with coverage
112108
if: inputs.task == 'test'
113109
run: |
110+
# Start D-Bus and unlock keyring in the same shell that runs tests,
111+
# so daemons are guaranteed alive for the entire test execution.
112+
if [[ "$RUNNER_OS" == "Linux" ]]; then
113+
eval $(dbus-launch --sh-syntax)
114+
export DBUS_SESSION_BUS_ADDRESS
115+
eval $(echo -n "test" | gnome-keyring-daemon --unlock --components=secrets)
116+
echo -n "warmup" | secret-tool store --label="ci-warmup" ci-test warmup
117+
fi
118+
114119
source <(cargo llvm-cov show-env --export-prefix)
115120
116121
bins_start=$(date +%s)

.github/workflows/post-merge.yml

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -190,10 +190,6 @@ jobs:
190190
sudo apt-get update --yes
191191
sudo apt-get install --yes gnome-keyring keyutils dbus-x11 libsecret-tools
192192
rm -f $HOME/.local/share/keyrings/*
193-
eval $(dbus-launch --sh-syntax)
194-
echo "DBUS_SESSION_BUS_ADDRESS=$DBUS_SESSION_BUS_ADDRESS" >> $GITHUB_ENV
195-
eval $(echo -n "test" | gnome-keyring-daemon --unlock --components=secrets)
196-
echo -n "warmup" | secret-tool store --label="ci-warmup" ci-test warmup
197193
198194
- name: Setup Rust with cache
199195
uses: ./.github/actions/utils/setup-rust-with-cache
@@ -207,6 +203,13 @@ jobs:
207203

208204
- name: Build and test with coverage
209205
run: |
206+
# Start D-Bus and unlock keyring in the same shell that runs tests,
207+
# so daemons are guaranteed alive for the entire test execution.
208+
eval $(dbus-launch --sh-syntax)
209+
export DBUS_SESSION_BUS_ADDRESS
210+
eval $(echo -n "test" | gnome-keyring-daemon --unlock --components=secrets)
211+
echo -n "warmup" | secret-tool store --label="ci-warmup" ci-test warmup
212+
210213
source <(cargo llvm-cov show-env --export-prefix)
211214
cargo build --locked
212215
cargo test --locked --no-run

0 commit comments

Comments
 (0)