-
Notifications
You must be signed in to change notification settings - Fork 24
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Enable Packit integration in pull requests #143
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
# This file is used by the Packit service. | ||
# Currently it is used for the gating of pull requests. | ||
# | ||
# See the documentation for more information: | ||
# https://packit.dev/docs/configuration/ | ||
|
||
# We need a specfile to build the RPM package. | ||
# But instead of storing it in this repository, | ||
# we use the one that exists already in src.fedoraproject.org/rpms/golang. | ||
# In particular, we use the specfile from the branch `eln`. | ||
# We'll create the temporary folder .packit_rpm to store the content of the | ||
# Fedora repository. | ||
specfile_path: .packit_rpm/golang.spec | ||
|
||
# We need to tell Packit which files to sync from the upstream repository. | ||
files_to_sync: | ||
- .packit.yaml | ||
- ./scripts/packit.sh | ||
|
||
srpm_build_deps: | ||
- golang | ||
- net-tools | ||
- openssl-devel | ||
- glibc-static | ||
- perl-interpreter | ||
- procps-ng | ||
|
||
# The name of the package in the upstream repository. | ||
upstream_package_name: golang | ||
# The name of the package in Fedora. | ||
downstream_package_name: golang | ||
# Use a different tag template for the upstream repository. | ||
#upstream_tag_template: "v{version}" | ||
|
||
actions: | ||
create-archive: | ||
- "bash ./scripts/packit.sh create-archive" | ||
post-upstream-clone: | ||
# Use the Fedora ELN package. | ||
- "git clone https://src.fedoraproject.org/rpms/golang.git .packit_rpm --branch eln" | ||
fix-spec-file: | ||
# Fix the specfile by running the ./scripts/packit.sh script | ||
# We cannot put the content of the script inside the yaml due to limitations of the format | ||
- "bash ./scripts/packit.sh" | ||
|
||
jobs: | ||
# Build the package in Fedora ELN when a pull request is opened. | ||
# It can be requested by adding a comment with the text: /packit copr-build | ||
- job: copr_build | ||
trigger: pull_request | ||
targets: | ||
- fedora-eln-aarch64 | ||
- fedora-eln-ppc64le | ||
- fedora-eln-s390x | ||
- fedora-eln-x86_64 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I would recommend adding There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. quick note, currently we don't have epel-10 targets on copr, so it'll only be epel-9. But centos stream can have both 9 and 10. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I am concern that will increase the complexity as CentOS Stream and ELN spec files might be potentially different at some times, but we should try on CentOS Stream too for sure. Not sure about EPEL, why is necessary? There is no golang spec file for EPEL 8/9. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There are maybe two approaches you can try:
I guess we could leave that for a followup PR.
This could instead be a BTW, a quirk about copr is that on a rhel / centos-stream env if you run This could also be left for a followup. |
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
#!/usr/bin/env bash | ||
# This script execute a set of steps needed by the .packit.yaml file | ||
|
||
# Detect the Go version targeted in the PR | ||
version=$(awk '/github.com\/golang\/go/ {gsub(/[: "go]/, "", $2); print $2}' config/versions.json) | ||
# Split the version using '.' as the delimiter | ||
IFS='.' read -ra parts <<< "$version" | ||
# Extract the first two parts and store in go_api | ||
go_api="${parts[0]}.${parts[1]}" | ||
# Extract the third part and store in go_patch | ||
go_patch="${parts[2]}" | ||
# Create a high package release number. This is a dirty hack. | ||
pkg_release="99" | ||
|
||
package="go$version-$pkg_release-openssl-fips" | ||
|
||
if [ "$1" = "create-archive" ]; then | ||
git archive --verbose --output $package.tar.gz --prefix go-$package/ HEAD | ||
ls -1t ./go*-openssl-fips.tar.gz | head -n 1 | ||
else | ||
# Drop fedora.go file | ||
rm -fv .packit_rpm/fedora.go | ||
sed -i '/SOURCE2/d' .packit_rpm/golang.spec | ||
sed -i '/fedora.go/d' .packit_rpm/golang.spec | ||
# Drop all the patches, we don't know if they can be apply to the new code | ||
rm -fv .packit_rpm/*.patch | ||
sed -ri '/^Patch[0-9]*:.+$/d' .packit_rpm/golang.spec | ||
|
||
# Update the Go version in golang.spec with the value of $go_api and $go_patch | ||
sed -i "s/%global go_api .*/%global go_api $go_api/" .packit_rpm/golang.spec | ||
sed -i "s/%global go_patch .*/%global go_patch $go_patch/" .packit_rpm/golang.spec | ||
sed -i "s/%global pkg_release .*/%global pkg_release $pkg_release/" .packit_rpm/golang.spec | ||
fi |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you need the changes from this script reflected in the final downstream rpm as well?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You mean if they will be included in the CentOS Stream packages? They are only for this GitHub project, I don't think we need them anywhere else.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In that case, line 18 can be removed too.