Skip to content

Commit f64a28f

Browse files
committed
store/keychain(ci): linux default keychain collection
Signed-off-by: Alano Terblanche <18033717+Benehiko@users.noreply.github.com>
1 parent 16bfddd commit f64a28f

5 files changed

Lines changed: 79 additions & 18 deletions

File tree

.github/workflows/keychain.yml

Lines changed: 24 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,35 @@ on:
99
paths:
1010
- 'store/**'
1111
jobs:
12-
tests:
13-
name: KeychainTests
12+
linux-keychain:
13+
name: LinuxKeychainTests
14+
runs-on: ubuntu-24.04
15+
strategy:
16+
fail-fast: false
17+
steps:
18+
- name: Checkout
19+
uses: actions/checkout@v4
20+
- name: Hub login
21+
uses: docker/login-action@v3
22+
with:
23+
username: ${{ vars.DOCKERBUILDBOT_USERNAME }}
24+
password: ${{ secrets.DOCKERBUILDBOT_WRITE_PAT }}
25+
- name: Set up Docker Buildx
26+
id: buildx
27+
uses: docker/setup-buildx-action@v3
28+
with:
29+
driver: cloud
30+
endpoint: "docker/secrets-engine"
31+
install: true
32+
- name: Test
33+
run: make keychain-linux-unit-tests
34+
tests-other:
35+
name: OtherKeychainTests
1436
runs-on: ${{ matrix.os }}
1537
strategy:
1638
fail-fast: false
1739
matrix:
1840
os:
19-
- ubuntu-24.04
20-
- ubuntu-22.04
2141
- macOS-15
2242
- macOS-14
2343
- macOS-13
@@ -30,10 +50,5 @@ jobs:
3050
uses: actions/setup-go@v5
3151
with:
3252
go-version-file: ./store/go.mod
33-
- name: Install deps (ubuntu)
34-
if: startsWith(matrix.os, 'ubuntu-')
35-
run: |
36-
sudo apt-get update
37-
sudo apt-get install -y dbus-x11 gnome-keyring
3853
- name: Test keychain
3954
run: make keychain-unit-tests

Makefile

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,8 @@ DOCKER_BUILD_ARGS := --build-arg GO_VERSION \
2828
--build-arg GOLANGCI_LINT_VERSION \
2929
--build-arg NRI_PLUGIN_BINARY \
3030
--build-arg BUF_VERSION \
31-
--build-arg GIT_TAG
31+
--build-arg GIT_TAG \
32+
--build-arg MAIN_MODULE_PATH
3233

3334
GO_TEST := go test
3435
ifneq ($(shell sh -c "which gotestsum 2> /dev/null"),)
@@ -54,8 +55,11 @@ clean: ## remove built binaries and packages
5455
unit-tests:
5556
CGO_ENABLED=0 go test -v -tags="gen" $$(go list ./... | grep -v /store/)
5657

58+
keychain-linux-unit-tests:
59+
@docker buildx build $(DOCKER_BUILD_ARGS) --target=fedora43-gnome-keyring --file store/Dockerfile .
60+
5761
keychain-unit-tests:
58-
$(MAKE) -C store/ unit-tests
62+
CGO_ENABLED=1 go test -v $$(go list ./store/keychain/...)
5963

6064
nri-plugin:
6165
CGO_ENABLED=0 GOOS=${TARGETOS} GOARCH=${TARGETARCH} go build -trimpath -ldflags "-s -w ${GO_LDFLAGS}" -o ./dist/$(NRI_PLUGIN_BINARY)$(EXTENSION) ./cmd/nri-plugin

store/Dockerfile

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
ARG GO_VERSION=latest
2+
3+
FROM --platform=${BUILDPLATFORM} golang:${GO_VERSION}-alpine AS go-base
4+
5+
FROM --platform=${BUILDPLATFORM} fedora:42 AS fedora42
6+
RUN dnf install -y dbus gnome-keyring
7+
COPY --from=go-base /usr/local/go /usr/local/go
8+
ENV PATH="/usr/local/go/bin:${PATH}"
9+
RUN useradd -ms /bin/bash user
10+
USER user
11+
WORKDIR /app
12+
RUN --mount=type=bind,target=.
13+
14+
FROM --platform=${BUILDPLATFORM} fedora:43 AS fedora43
15+
RUN dnf install -y dbus gnome-keyring
16+
COPY --from=go-base /usr/local/go /usr/local/go
17+
ENV PATH="/usr/local/go/bin:${PATH}"
18+
RUN useradd -ms /bin/bash user
19+
USER user
20+
WORKDIR /app
21+
RUN --mount=type=bind,target=.
22+
23+
FROM fedora43 AS fedora43-gnome-keyring
24+
ENV CGO_ENABLED=0
25+
USER user
26+
WORKDIR /app
27+
RUN --mount=type=bind,target=. \
28+
--mount=type=cache,target=/go/pkg/mod \
29+
--mount=type=cache,target=/root/.cache/go-build \
30+
/app/store/scripts/keychain \
31+
go test -v ./store/keychain/...

store/Makefile

Lines changed: 0 additions & 7 deletions
This file was deleted.

store/scripts/keychain

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
#!/bin/sh
2+
3+
set -euxo pipefail
4+
mkdir -p ~/.local/share/keyrings
5+
touch ~/.local/share/keyrings/login.keyring
6+
7+
# Start D-Bus session (dbus must be installed)
8+
export DBUS_SESSION_BUS_ADDRESS=$(dbus-daemon --session --print-address --fork)
9+
10+
# create fake passwordless 'login' keyring
11+
echo '[keyring]
12+
display-name=login
13+
ctime=1750965549
14+
mtime=0
15+
lock-on-idle=false
16+
lock-after=false' >> ~/.local/share/keyrings/login.keyring
17+
18+
gnome-keyring-daemon --start --components=secrets

0 commit comments

Comments
 (0)