Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
File renamed without changes.
2 changes: 1 addition & 1 deletion .github/scripts/fdo-utils.sh
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,6 @@ test_onboarding () {
get_ov_from_manufacturer ${manufacturer_service} "${guid}" ${owner_ov}
set_owner_redirect_info ${owner_service} ${owner_ip} ${owner_port}
send_ov_to_owner ${owner_service} ${owner_ov}
run_to0 ${owner_service} "${guid}"
sleep 20
run_fido_device_onboard ${owner_onboard_log}
}
2 changes: 1 addition & 1 deletion .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:
- name: Install golang
uses: actions/setup-go@v5
with:
go-version: "1.23"
go-version: "1.25"

- name: Check out repository code
uses: actions/checkout@v4
Expand Down
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@ go.work.sum
*.db
.vscode/*
go-fdo-client
go-fdo-client-*.tar.gz
go-fdo-client-*.tar.*
rpmbuild
134 changes: 103 additions & 31 deletions .packit.yaml
Original file line number Diff line number Diff line change
@@ -1,9 +1,16 @@
---
# https://packit.dev/docs/configuration/

# We want to generate packages with the original commit sha
# https://packit.dev/docs/configuration#merge_pr_in_ci
merge_pr_in_ci: false

files_to_sync:
- src:
- ".packit.yaml"
- "build/package/rpm/go-fdo-client.spec"
- "build/package/rpm/go-vendor-tools.toml"
- "build/package/rpm/go-fdo-client-*-vendor.tar.gz"
- "build/package/rpm/go-fdo-client-*-vendor.tar.bz2"
dest: .

upstream_package_name: go-fdo-client
Expand All @@ -13,13 +20,12 @@ upstream_tag_template: v{version}
copy_upstream_release_description: true

srpm_build_deps:
- make
- git
- golang
- go-vendor-tools
- gzip
- tar
- python3-tomlkit
- askalono-cli
- rpmdevtools

packages:
go-fdo-client-fedora:
Expand All @@ -33,64 +39,130 @@ packages:
pkg_tool: centpkg

actions:
pre-sync:
- make vendor-tarball VERSION=${PACKIT_PROJECT_VERSION}
create-archive:
- make packit-create-archive VERSION=${PACKIT_PROJECT_VERSION}
post-upstream-clone:
- |
bash -xc '
#! /bin/bash
export SPEC_FILE="${PACKIT_UPSTREAM_REPO}/build/package/rpm/go-fdo-client.spec"
export COMMIT="$(GIT_DIR="${PACKIT_UPSTREAM_REPO}"/.git git rev-parse HEAD)"
sed -i "s/^%global commit\(\s*\).*/%global commit\1${COMMIT}/" ${SPEC_FILE}
'
post-modifications:
# https://fedora.gitlab.io/sigs/go/go-vendor-tools/scenarios/#manual-update
- |
bash -xc '
#! /bin/bash
export GOTOOLCHAIN=auto
export BASE_DIR=${PACKIT_UPSTREAM_REPO}/build/package/rpm
export GO_VENDOR_TOOLS_CONFIG=${BASE_DIR}/go-vendor-tools.toml
export SPEC_FILE=${BASE_DIR}/go-fdo-client.spec
# Download the source tarball (Source0) needed by go_vendor_archive
spectool -g -C ${BASE_DIR} ${SPEC_FILE} || exit 1
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The spec file used here doesn't have commit/version/release modified (it seems it's using the hardcoded commit value) see https://dashboard.packit.dev/jobs/propose-downstream/22467

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, it looks like fix-spec-file does not apply to propose-downstream action, we need to modify the commit hash in the post-upstream-clone or pre-sync hooks. See: https://packit.dev/docs/configuration/actions

go_vendor_archive create --config ${GO_VENDOR_TOOLS_CONFIG} ${SPEC_FILE}
go_vendor_license \
--config ${GO_VENDOR_TOOLS_CONFIG} \
--path ${SPEC_FILE} \
report \
--verify-spec
'

jobs:

# Fedora jobs

# We build and test Fedora 43 ('latest-stable'), Fedora 44 ('latest' when branched) and Fedora Rawhide
# because they are the only ones officially released with golang >= 1.25.0
- &copr_fedora
job: copr_build
packages: [go-fdo-client-fedora]
trigger: pull_request
targets:
- fedora-stable
- fedora-development
targets: &copr_fedora_targets
- "fedora-latest-stable-x86_64"
- "fedora-latest-stable-aarch64"
- "fedora-latest-x86_64"
- "fedora-latest-aarch64"
- "fedora-rawhide-x86_64"
- "fedora-rawhide-aarch64"

# Build all versions in '@fedora-iot/copr' copr because it's possible to add golang >= 1.25.0
# see: https://copr.fedorainfracloud.org/coprs/g/fedora-iot/fedora-iot/edit_chroot/fedora-42-x86_64/
- <<: *copr_fedora
trigger: commit
branch: main
owner: "@fedora-iot"
project: fedora-iot
targets:
- "fedora-stable-x86_64"
- "fedora-stable-aarch64"
- "fedora-development-x86_64"
- "fedora-development-aarch64"
- "fedora-eln-x86_64"
- "fedora-eln-aarch64"

# Only Fedora >= 43 have golang >= 1.25.0
- job: propose_downstream
trigger: release
packages: [go-fdo-client-fedora]
# Avoid divergent branches: https://packit.dev/docs/fedora-releases-guide/non-divergent-dist-git-branches
dist_git_branches:
- fedora-stable
- fedora-development
rawhide:
fast_forward_merge_into: ["fedora-latest-stable","fedora-latest"]

- job: koji_build
trigger: commit
allowed_pr_authors: [all_committers]
dist_git_branches: &fedora_dist_git_branches
- "fedora-latest-stable"
- "fedora-latest"
- "fedora-rawhide"

- job: bodhi_update
trigger: commit
allowed_builders: [all_committers]
dist_git_branches: *fedora_dist_git_branches

# Fedora E2E Testing jobs
# We build and test Fedora 43 ('latest-stable'), Fedora 44 ('latest' when branched) and Fedora Rawhide
# because they are the only ones officially released with golang >= 1.25.0
- job: tests
trigger: pull_request
identifier: e2e-fedora
tmt_plan: test/fmf/plans/e2e
packages: [go-fdo-client-fedora]
targets: *copr_fedora_targets

# CentOS jobs

- &copr_centos
job: copr_build
packages: [go-fdo-client-centos]
trigger: pull_request
targets:
- epel-9
- epel-10
targets: &copr_centos_targets
- "centos-stream-9-x86_64"
- "centos-stream-9-aarch64"
- "centos-stream-10-x86_64"
- "centos-stream-10-aarch64"

- <<: *copr_centos
trigger: commit
branch: main
owner: "@fedora-iot"
project: fedora-iot

- job: tests
trigger: pull_request
identifier: e2e-fedora
fmf_path: test/fmf
tmt_plan: plans/e2e
packages: [go-fdo-client-fedora]
targets:
- fedora-stable
- fedora-development
- "centos-stream-9-x86_64"
- "centos-stream-9-aarch64"
- "centos-stream-10-x86_64"
- "centos-stream-10-aarch64"
- "epel-9-x86"
- "epel-9-aarch64"
- "epel-10-x86"
- "epel-10-aarch64"

# CentOS E2E Testing jobs
#
- job: tests
trigger: pull_request
identifier: e2e-centos
fmf_path: test/fmf
tmt_plan: plans/e2e
tmt_plan: test/fmf/plans/e2e
packages: [go-fdo-client-centos]
targets:
- epel-9
- epel-10

targets: *copr_centos_targets
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# SPDX-License-Identifier: Apache 2.0

FROM golang:1.23-alpine AS builder
FROM golang:1.25-alpine AS builder

WORKDIR /go/src/app
COPY . .
Expand Down
76 changes: 44 additions & 32 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,54 +1,65 @@
COMMIT := $(shell git rev-parse --short HEAD)
DATE := $(shell date "+%Y%m%d")
VERSION := git$(DATE).$(COMMIT)
PROJECT := go-fdo-client

SOURCEDIR := $(CURDIR)/build/package/rpm
SPEC_FILE_NAME := $(PROJECT).spec
SPEC_FILE := $(SOURCEDIR)/$(SPEC_FILE_NAME)
GO_VENDOR_TOOLS_FILE := $(SOURCEDIR)/go-vendor-tools.toml
PROJECT := go-fdo-client
RPM_BASE_DIR := $(CURDIR)/build/package/rpm
SPEC_FILE_NAME := $(PROJECT).spec
SPEC_FILE := $(RPM_BASE_DIR)/$(SPEC_FILE_NAME)
COMMIT_SHORT := $(shell git rev-parse --short HEAD)
VERSION := $(shell bash -c "set -o pipefail; git describe --tags | sed -e 's/^v//' -e 's/-.*//'")
ifeq ($(VERSION),)
VERSION := $(shell grep 'Version:' $(SPEC_FILE) | awk '{printf "%s", $$2}')
endif

ARCH := $(shell uname -m)

SOURCEDIR := $(CURDIR)/build/package/rpm
SPEC_FILE_NAME := $(PROJECT).spec
SPEC_FILE := $(SOURCEDIR)/$(SPEC_FILE_NAME)
GO_VENDOR_TOOLS_FILE_NAME := go-vendor-tools.toml
GO_VENDOR_TOOLS_FILE := $(SOURCEDIR)/$(GO_VENDOR_TOOLS_FILE_NAME)

SOURCE_TARBALL := $(SOURCEDIR)/$(PROJECT)-$(VERSION).tar.gz
VENDOR_TARBALL := $(SOURCEDIR)/$(PROJECT)-$(VERSION)-vendor.tar.gz
VENDOR_TARBALL := $(SOURCEDIR)/$(PROJECT)-$(VERSION)-vendor.tar.bz2

# Build the Go project
.PHONY: all build tidy fmt vet test
.PHONY: all
all: build test

.PHONY: build
build: tidy fmt vet
go build -ldflags="-X github.com/fido-device-onboard/go-fdo-client/internal/version.VERSION=${VERSION}"
go build -ldflags="-X github.com/fido-device-onboard/go-fdo-client/internal/version.VERSION=$(VERSION)"

.PHONY: tidy
tidy:
go mod tidy

.PHONY: fmt
fmt:
go fmt ./...

.PHONY: vet
vet:
go vet ./...

.PHONY: test
test:
go test -v ./...

# Packit helpers
.PHONY: vendor-tarball packit-create-archive vendor-licenses

.PHONY: vendor-tarball
vendor-tarball: $(VENDOR_TARBALL)

$(VENDOR_TARBALL):
rm -rf vendor; \
command -v go_vendor_archive || sudo dnf install -y go-vendor-tools python3-tomlkit; \
go_vendor_archive create --compression gz --config $(GO_VENDOR_TOOLS_FILE) --write-config --output $(VENDOR_TARBALL) .; \
go_vendor_archive create --config $(GO_VENDOR_TOOLS_FILE) --write-config --output $(VENDOR_TARBALL) .; \
rm -rf vendor;

packit-create-archive: $(SOURCE_TARBALL) $(VENDOR_TARBALL)
@ls -1 "$(SOURCE_TARBALL)" | head -n1
.PHONY: source-tarball
source-tarball: $(SOURCE_TARBALL)

$(SOURCE_TARBALL):
mkdir -p "$(SOURCEDIR)"
git archive --format=tar --prefix="$(PROJECT)-$(VERSION)/" HEAD | gzip > "$(SOURCE_TARBALL)"

.PHONY: vendor-licenses
vendor-licenses:
go_vendor_license --config "$(GO_VENDOR_TOOLS_FILE)" .

Expand All @@ -64,10 +75,6 @@ vendor-licenses:
# ./rpmbuild, using rpmbuild's usual directory structure (in lowercase).
#

RPM_BASE_DIR := $(CURDIR)/build/package/rpm
SPEC_FILE_NAME := $(PROJECT).spec
SPEC_FILE := $(RPM_BASE_DIR)/$(SPEC_FILE_NAME)

RPMBUILD_TOP_DIR := $(CURDIR)/rpmbuild
RPMBUILD_BUILD_DIR := $(RPMBUILD_TOP_DIR)/build
RPMBUILD_RPMS_DIR := $(RPMBUILD_TOP_DIR)/rpms
Expand All @@ -79,14 +86,15 @@ RPMBUILD_BUILDROOT_DIR := $(RPMBUILD_TOP_DIR)/buildroot
RPMBUILD_GOLANG_VENDOR_TOOLS_FILE := $(RPMBUILD_SOURCES_DIR)/$(GO_VENDOR_TOOLS_FILE_NAME)
RPMBUILD_SPECFILE := $(RPMBUILD_SPECS_DIR)/$(PROJECT)-$(VERSION).spec
RPMBUILD_TARBALL := $(RPMBUILD_SOURCES_DIR)/$(PROJECT)-$(VERSION).tar.gz
RPMBUILD_VENDOR_TARBALL := $(RPMBUILD_SOURCES_DIR)/$(PROJECT)-$(VERSION)-vendor.tar.gz
RPMBUILD_VENDOR_TARBALL := $(RPMBUILD_SOURCES_DIR)/$(PROJECT)-$(VERSION)-vendor.tar.bz2
RPMBUILD_SRPM_FILE := $(RPMBUILD_SRPMS_DIR)/$(PROJECT)-$(VERSION)-git$(COMMIT_SHORT).src.rpm
RPMBUILD_RPM_FILE := $(RPMBUILD_RPMS_DIR)/$(ARCH)/$(PROJECT)-$(VERSION)-git$(COMMIT_SHORT).$(ARCH).rpm

# Render a versioned spec into ./rpmbuild/specs (keeps source spec pristine)
$(RPMBUILD_SPECFILE):
mkdir -p $(RPMBUILD_SPECS_DIR)
sed -e "s|^Version:.*|Version: $(VERSION)|;" \
-e "s|^Source0:.*|Source0: $(PROJECT)-$(VERSION).tar.gz|;" \
-e "s|^Source1:.*|Source1: $(PROJECT)-$(VERSION)-vendor.tar.gz|;" \
sed -e "s/^Version:\(\s*\).*/Version:\1$(VERSION)/;" \
-e "s/^Release:\(\s*\).*/Release:\1git$(COMMIT_SHORT)/;" \
$(SPEC_FILE) > $(RPMBUILD_SPECFILE)

# Copy sources into ./rpmbuild/sources
Expand All @@ -100,9 +108,7 @@ $(RPMBUILD_GOLANG_VENDOR_TOOLS_FILE):
mkdir -p $(RPMBUILD_SOURCES_DIR)
cp -f $(GO_VENDOR_TOOLS_FILE) $(RPMBUILD_GOLANG_VENDOR_TOOLS_FILE)

# Build SRPM locally (outputs under ./rpmbuild)
.PHONY: srpm
srpm: $(RPMBUILD_SPECFILE) $(RPMBUILD_TARBALL) $(RPMBUILD_GOLANG_VENDOR_TOOLS_FILE)
$(RPMBUILD_SRPM_FILE): $(RPMBUILD_SPECFILE) $(RPMBUILD_TARBALL) $(RPMBUILD_GOLANG_VENDOR_TOOLS_FILE)
command -v rpmbuild >/dev/null || { echo "rpmbuild missing"; exit 1; }
rpmbuild -bs \
--define "_topdir $(RPMBUILD_TOP_DIR)" \
Expand All @@ -114,9 +120,7 @@ srpm: $(RPMBUILD_SPECFILE) $(RPMBUILD_TARBALL) $(RPMBUILD_GOLANG_VENDOR_TOOLS_FI
--define "_buildrootdir $(RPMBUILD_BUILDROOT_DIR)" \
$(RPMBUILD_SPECFILE)

# Build binary RPM locally (optional)
.PHONY: rpm
rpm: $(RPMBUILD_SPECFILE) $(RPMBUILD_TARBALL) $(RPMBUILD_GOLANG_VENDOR_TOOLS_FILE)
$(RPMBUILD_RPM_FILE): $(RPMBUILD_SPECFILE) $(RPMBUILD_TARBALL) $(RPMBUILD_GOLANG_VENDOR_TOOLS_FILE)
command -v rpmbuild >/dev/null || { echo "rpmbuild missing"; exit 1; }
# Uncomment to auto-install build deps on your host:
# sudo dnf builddep -y $(RPMBUILD_SPECFILE)
Expand All @@ -129,3 +133,11 @@ rpm: $(RPMBUILD_SPECFILE) $(RPMBUILD_TARBALL) $(RPMBUILD_GOLANG_VENDOR_TOOLS_FIL
--define "_builddir $(RPMBUILD_BUILD_DIR)" \
--define "_buildrootdir $(RPMBUILD_BUILDROOT_DIR)" \
$(RPMBUILD_SPECFILE)

# Build SRPM locally (outputs under ./rpmbuild)
.PHONY: srpm
srpm: $(RPMBUILD_SRPM_FILE)

# Build binary RPM locally (optional)
.PHONY: rpm
rpm: $(RPMBUILD_RPM_FILE)
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

## Prerequisites

- Go 1.23.0 or later
- Go 1.25.0 or later
- A Go module initialized with `go mod init`

## Building the Client Application
Expand Down
Loading
Loading