3 Commits

Author SHA256 Message Date
Jan Zerebecki
50e5fa7f88 Add ci jobs for go vendor
All checks were successful
go-generate-check / go-generate-check (push) Successful in 6s
go-vendor-check / go-vendor-check (push) Successful in 6s
2025-09-11 15:46:12 +02:00
Jan Zerebecki
efc3228abe Add ci jobs for go generate
either to check it produces no diff, or to manually trigger pushing any
diff as a commmit to the current branch.
2025-09-11 15:46:10 +02:00
Jan Zerebecki
d59e55a31d Build rest and run tests
Build binaries that depend on mocks.
Build some binaries that where added since and add sub-package for them.
Run go test where they exist.
2025-09-11 15:45:36 +02:00
7 changed files with 209 additions and 55 deletions

View File

@@ -0,0 +1,30 @@
name: go-generate-check
on:
push:
branches: ['main']
pull_request:
paths:
- '**.go'
- '**.mod'
- '**.sum'
workflow_dispatch:
jobs:
go-generate-check:
name: go-generate-check
container:
image: registry.opensuse.org/devel/factory/git-workflow/containers/opensuse/bci/golang-extended:latest
steps:
- run: git clone --no-checkout --depth 1 ${{ gitea.server_url }}/${{ gitea.repository }} .
- run: git fetch origin ${{ gitea.ref }}
- run: git checkout FETCH_HEAD
- run: go generate -C common
- run: go generate -C workflow-pr
- run: go generate -C workflow-pr/interfaces
- run: git add -N .; git diff
- run: |
status=$(git status --short)
if [[ -n "$status" ]]; then
echo -e "$status"
echo "Please commit the differences from running: go generate"
false
fi

View File

@@ -0,0 +1,25 @@
name: go-generate-push
on:
workflow_dispatch:
jobs:
go-generate-push:
name: go-generate-push
container:
image: registry.opensuse.org/devel/factory/git-workflow/containers/opensuse/bci/golang-extended:latest
steps:
- run: git clone --no-checkout --depth 1 ${{ gitea.server_url }}/${{ gitea.repository }} .
- run: git fetch origin ${{ gitea.ref }}
- run: git checkout FETCH_HEAD
- run: go generate -C common
- run: go generate -C workflow-pr
- run: go generate -C workflow-pr/interfaces
- run: |
host=${{ gitea.server_url }}
host=${host#https://}
echo $host
git remote set-url origin "https://x-access-token:${{ secrets.GITEA_TOKEN }}@$host/${{ gitea.repository }}"
git config user.name "Gitea Actions"
git config user.email "gitea_noreply@opensuse.org"
- run: 'git status --short; git status --porcelain=2|grep --quiet -v . || ( git add .;git commit -m "CI run result of: go generate"; git push origin HEAD:${{ gitea.ref }} )'
- run: git log -p FETCH_HEAD...HEAD
- run: git log --numstat FETCH_HEAD...HEAD

View File

@@ -0,0 +1,30 @@
name: go-vendor-check
on:
push:
branches: ['main']
pull_request:
paths:
- '**.mod'
- '**.sum'
workflow_dispatch:
jobs:
go-generate-check:
name: go-vendor-check
container:
image: registry.opensuse.org/devel/factory/git-workflow/containers/opensuse/bci/golang-extended:latest
steps:
- run: git clone --no-checkout --depth 1 ${{ gitea.server_url }}/${{ gitea.repository }} .
- run: git fetch origin ${{ gitea.ref }}
- run: git checkout FETCH_HEAD
- run: go mod download
- run: go mod vendor
- run: go mod verify
- run: git add -N .; git diff
- run: go mod tidy -diff || true
- run: |
status=$(git status --short)
if [[ -n "$status" ]]; then
echo -e "$status"
echo "Please commit the differences from running: go generate"
false
fi

View File

@@ -0,0 +1,26 @@
name: go-generate-push
on:
workflow_dispatch:
jobs:
go-generate-push:
name: go-generate-push
container:
image: registry.opensuse.org/devel/factory/git-workflow/containers/opensuse/bci/golang-extended:latest
steps:
- run: git clone --no-checkout --depth 1 ${{ gitea.server_url }}/${{ gitea.repository }} .
- run: git fetch origin ${{ gitea.ref }}
- run: git checkout FETCH_HEAD
- run: go mod download
- run: go mod vendor
- run: go mod verify
- run: |
host=${{ gitea.server_url }}
host=${host#https://}
echo $host
git remote set-url origin "https://x-access-token:${{ secrets.GITEA_TOKEN }}@$host/${{ gitea.repository }}"
git config user.name "Gitea Actions"
git config user.email "gitea_noreply@opensuse.org"
- run: 'git status --short; git status --porcelain=2|grep --quiet -v . || ( git add .;git commit -m "CI run result of: go mod vendor"; git push origin HEAD:${{ gitea.ref }} )'
- run: go mod tidy -diff || true
- run: git log -p FETCH_HEAD...HEAD
- run: git log --numstat FETCH_HEAD...HEAD

3
.gitignore vendored
View File

@@ -1,5 +1,2 @@
node_modules
*.obscpio
autogits-tmp.tar.zst
*.osc *.osc
*.conf *.conf

View File

@@ -1,15 +0,0 @@
<services>
<!-- workaround, go_modules needs a tar and obs_scm doesn't take file://. -->
<service name="roast" mode="manual">
<param name="target">.</param>
<param name="reproducible">true</param>
<param name="outfile">autogits-tmp.tar.zst</param>
<param name="exclude">autogits-tmp.tar.zst</param>
</service>
<service name="go_modules" mode="manual">
<param name="basename">./</param>
<param name="compression">zst</param>
<param name="vendorname">vendor</param>
</service>
</services>

View File

@@ -22,6 +22,7 @@ Release: 0
Summary: GitWorkflow utilities Summary: GitWorkflow utilities
License: GPL-2.0-or-later License: GPL-2.0-or-later
URL: https://src.opensuse.org/adamm/autogits URL: https://src.opensuse.org/adamm/autogits
BuildRequires: git
BuildRequires: systemd-rpm-macros BuildRequires: systemd-rpm-macros
BuildRequires: go BuildRequires: go
%{?systemd_ordering} %{?systemd_ordering}
@@ -30,61 +31,86 @@ BuildRequires: go
Git Workflow tooling and utilities enabling automated handing of OBS projects Git Workflow tooling and utilities enabling automated handing of OBS projects
as git repositories as git repositories
%package -n hujson
%package -n autogits-devel-importer
Summary: Imports devel projects from obs to git
%description -n autogits-devel-importer
Command-line tool to import devel projects from obs to git
%package -n autogits-doc
Summary: Common documentation files
%description -n autogits-doc
Common documentation files
%package -n autogits-hujson
Summary: HuJSON to JSON parser Summary: HuJSON to JSON parser
%description -n hujson %description -n autogits-hujson
HuJSON to JSON parser, using stdin -> stdout pipe HuJSON to JSON parser, using stdin -> stdout pipe
%package -n gitea-events-rabbitmq-publisher
%package -n autogits-gitea-events-rabbitmq-publisher
Summary: Publishes Gitea webhook data via RabbitMQ Summary: Publishes Gitea webhook data via RabbitMQ
%description -n gitea-events-rabbitmq-publisher %description -n autogits-gitea-events-rabbitmq-publisher
Listens on an HTTP socket and publishes Gitea events on a RabbitMQ instance Listens on an HTTP socket and publishes Gitea events on a RabbitMQ instance
with a topic with a topic
<scope>.src.$organization.$webhook_type.[$webhook_action_type] <scope>.src.$organization.$webhook_type.[$webhook_action_type]
%package -n doc %package -n autogits-gitea-status-proxy
Summary: Common documentation files Summary: gitea-status-proxy
%description -n doc %description -n autogits-gitea-status-proxy
Common documentation files
%package -n group-review %package -n autogits-group-review
Summary: Reviews of groups defined in ProjectGit Summary: Reviews of groups defined in ProjectGit
%description -n group-review %description -n autogits-group-review
Is used to handle reviews associated with groups defined in the Is used to handle reviews associated with groups defined in the
ProjectGit. ProjectGit.
%package -n obs-staging-bot %package -n autogits-obs-forward-bot
Summary: obs-forward-bot
%description -n autogits-obs-forward-bot
%package -n autogits-obs-staging-bot
Summary: Build a PR against a ProjectGit, if review is requested Summary: Build a PR against a ProjectGit, if review is requested
%description -n obs-staging-bot %description -n autogits-obs-staging-bot
Build a PR against a ProjectGit, if review is requested. Build a PR against a ProjectGit, if review is requested.
%package -n obs-status-service %package -n autogits-obs-status-service
Summary: Reports build status of OBS service as an easily to produce SVG Summary: Reports build status of OBS service as an easily to produce SVG
%description -n obs-status-service %description -n autogits-obs-status-service
Reports build status of OBS service as an easily to produce SVG Reports build status of OBS service as an easily to produce SVG
%package -n workflow-direct %package -n autogits-workflow-direct
Summary: Keep ProjectGit in sync for a devel project Summary: Keep ProjectGit in sync for a devel project
Requires: openssh-clients
Requires: git-core
%description -n workflow-direct %description -n autogits-workflow-direct
Keep ProjectGit in sync with packages in the organization of a devel project Keep ProjectGit in sync with packages in the organization of a devel project
%package -n workflow-pr %package -n autogits-workflow-pr
Summary: Keeps ProjectGit PR in-sync with a PackageGit PR Summary: Keeps ProjectGit PR in-sync with a PackageGit PR
Requires: openssh-clients
Requires: git-core
%description -n workflow-pr %description -n autogits-workflow-pr
Keeps ProjectGit PR in-sync with a PackageGit PR Keeps ProjectGit PR in-sync with a PackageGit PR
@@ -93,15 +119,24 @@ Keeps ProjectGit PR in-sync with a PackageGit PR
cp -r /home/abuild/rpmbuild/SOURCES/* ./ cp -r /home/abuild/rpmbuild/SOURCES/* ./
%build %build
go build \
-C devel-importer \
-buildmode=pie
go build \ go build \
-C hujson \ -C hujson \
-buildmode=pie -buildmode=pie
go build \ go build \
-C gitea-events-rabbitmq-publisher \ -C gitea-events-rabbitmq-publisher \
-buildmode=pie -buildmode=pie
go build \
-C gitea_status_proxy \
-buildmode=pie
go build \ go build \
-C group-review \ -C group-review \
-buildmode=pie -buildmode=pie
go build \
-C obs-forward-bot \
-buildmode=pie
go build \ go build \
-C obs-staging-bot \ -C obs-staging-bot \
-buildmode=pie -buildmode=pie
@@ -115,10 +150,23 @@ go build \
-C workflow-pr \ -C workflow-pr \
-buildmode=pie -buildmode=pie
%check
# TODO currently needs the source git history, maybe rewrite to create a git repo in the test?
#go test -C common
go test -C group-review
go test -C obs-staging-bot
go test -C obs-status-service
go test -C workflow-direct
# TODO build fails
#go test -C workflow-pr
%install %install
install -D -m0755 devel-importer/devel-importer %{buildroot}%{_bindir}/devel-importer
install -D -m0755 gitea-events-rabbitmq-publisher/gitea-events-rabbitmq-publisher %{buildroot}%{_bindir}/gitea-events-rabbitmq-publisher install -D -m0755 gitea-events-rabbitmq-publisher/gitea-events-rabbitmq-publisher %{buildroot}%{_bindir}/gitea-events-rabbitmq-publisher
install -D -m0644 systemd/gitea-events-rabbitmq-publisher.service %{buildroot}%{_unitdir}/gitea-events-rabbitmq-publisher.service install -D -m0644 systemd/gitea-events-rabbitmq-publisher.service %{buildroot}%{_unitdir}/gitea-events-rabbitmq-publisher.service
install -D -m0755 gitea_status_proxy/gitea_status_proxy %{buildroot}%{_bindir}/gitea_status_proxy
install -D -m0755 group-review/group-review %{buildroot}%{_bindir}/group-review install -D -m0755 group-review/group-review %{buildroot}%{_bindir}/group-review
install -D -m0755 obs-forward-bot/obs-forward-bot %{buildroot}%{_bindir}/obs-forward-bot
install -D -m0755 obs-staging-bot/obs-staging-bot %{buildroot}%{_bindir}/obs-staging-bot install -D -m0755 obs-staging-bot/obs-staging-bot %{buildroot}%{_bindir}/obs-staging-bot
install -D -m0644 systemd/obs-staging-bot.service %{buildroot}%{_unitdir}/obs-staging-bot.service install -D -m0644 systemd/obs-staging-bot.service %{buildroot}%{_unitdir}/obs-staging-bot.service
install -D -m0755 obs-status-service/obs-status-service %{buildroot}%{_bindir}/obs-status-service install -D -m0755 obs-status-service/obs-status-service %{buildroot}%{_bindir}/obs-status-service
@@ -126,67 +174,80 @@ install -D -m0755 workflow-direct/workflow-direct
install -D -m0755 workflow-pr/workflow-pr %{buildroot}%{_bindir}/workflow-pr install -D -m0755 workflow-pr/workflow-pr %{buildroot}%{_bindir}/workflow-pr
install -D -m0755 hujson/hujson %{buildroot}%{_bindir}/hujson install -D -m0755 hujson/hujson %{buildroot}%{_bindir}/hujson
%pre -n gitea-events-rabbitmq-publisher %pre -n autogits-gitea-events-rabbitmq-publisher
%service_add_pre gitea-events-rabbitmq-publisher.service %service_add_pre gitea-events-rabbitmq-publisher.service
%post -n gitea-events-rabbitmq-publisher %post -n autogits-gitea-events-rabbitmq-publisher
%service_add_post gitea-events-rabbitmq-publisher.service %service_add_post gitea-events-rabbitmq-publisher.service
%preun -n gitea-events-rabbitmq-publisher %preun -n autogits-gitea-events-rabbitmq-publisher
%service_del_preun gitea-events-rabbitmq-publisher.service %service_del_preun gitea-events-rabbitmq-publisher.service
%postun -n gitea-events-rabbitmq-publisher %postun -n autogits-gitea-events-rabbitmq-publisher
%service_del_postun gitea-events-rabbitmq-publisher.service %service_del_postun gitea-events-rabbitmq-publisher.service
%pre -n obs-staging-bot %pre -n autogits-obs-staging-bot
%service_add_pre obs-staging-bot.service %service_add_pre obs-staging-bot.service
%post -n obs-staging-bot %post -n autogits-obs-staging-bot
%service_add_post obs-staging-bot.service %service_add_post obs-staging-bot.service
%preun -n obs-staging-bot %preun -n autogits-obs-staging-bot
%service_del_preun obs-staging-bot.service %service_del_preun obs-staging-bot.service
%postun -n obs-staging-bot %postun -n autogits-obs-staging-bot
%service_del_postun obs-staging-bot.service %service_del_postun obs-staging-bot.service
%files -n gitea-events-rabbitmq-publisher %files -n autogits-devel-importer
%license COPYING
%doc devel-importer/README.md
%{_bindir}/devel-importer
%files -n autogits-hujson
%license COPYING
%{_bindir}/hujson
%files -n autogits-doc
%license COPYING
%doc doc/README.md
%doc doc/workflows.md
%files -n autogits-gitea-events-rabbitmq-publisher
%license COPYING %license COPYING
%doc gitea-events-rabbitmq-publisher/README.md %doc gitea-events-rabbitmq-publisher/README.md
%{_bindir}/gitea-events-rabbitmq-publisher %{_bindir}/gitea-events-rabbitmq-publisher
%{_unitdir}/gitea-events-rabbitmq-publisher.service %{_unitdir}/gitea-events-rabbitmq-publisher.service
%files -n doc %files -n autogits-gitea-status-proxy
%license COPYING %license COPYING
%doc doc/README.md %{_bindir}/gitea_status_proxy
%doc doc/workflows.md
%files -n group-review %files -n autogits-group-review
%license COPYING %license COPYING
%doc group-review/README.md %doc group-review/README.md
%{_bindir}/group-review %{_bindir}/group-review
%files -n hujson %files -n autogits-obs-forward-bot
%license COPYING %license COPYING
%{_bindir}/hujson %{_bindir}/obs-forward-bot
%files -n obs-staging-bot %files -n autogits-obs-staging-bot
%license COPYING %license COPYING
%doc obs-staging-bot/README.md %doc obs-staging-bot/README.md
%{_bindir}/obs-staging-bot %{_bindir}/obs-staging-bot
%{_unitdir}/obs-staging-bot.service %{_unitdir}/obs-staging-bot.service
%files -n obs-status-service %files -n autogits-obs-status-service
%license COPYING %license COPYING
%doc obs-status-service/README.md %doc obs-status-service/README.md
%{_bindir}/obs-status-service %{_bindir}/obs-status-service
%files -n workflow-direct %files -n autogits-workflow-direct
%license COPYING %license COPYING
%doc workflow-direct/README.md %doc workflow-direct/README.md
%{_bindir}/workflow-direct %{_bindir}/workflow-direct
%files -n workflow-pr %files -n autogits-workflow-pr
%license COPYING %license COPYING
%doc workflow-pr/README.md %doc workflow-pr/README.md
%{_bindir}/workflow-pr %{_bindir}/workflow-pr