Skip to content

fix ci rpm build

fix ci rpm build #960

Workflow file for this run

name: Build
on:
push:
branches:
- main
pull_request:
jobs:
golangci-lint:
name: golangci-lint
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Run golangci-lint
uses: golangci/golangci-lint-action@v3
test:
name: go test
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Set up Go
uses: actions/setup-go@v3
with:
go-version: 1.16
- name: Set up gotestfmt
uses: haveyoudebuggedit/gotestfmt-action@v2
- uses: actions/cache@v3
with:
path: |
~/go/pkg/mod
~/.cache/go-build
key: go-test-${{ hashFiles('**/go.sum') }}
restore-keys: go-test-
- name: Run go test
run: |
set -euo pipefail
go generate
go test -json -v -client=mock ./... 2>&1 | tee /tmp/gotest.log | gotestfmt
- name: Upload test log
uses: actions/upload-artifact@v3
if: always()
with:
name: test-log
path: /tmp/gotest.log
if-no-files-found: error
generate:
name: go generate
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Set up Go
uses: actions/setup-go@v3
with:
go-version: 1.16
- uses: actions/cache@v3
with:
path: |
~/go/pkg/mod
~/.cache/go-build
key: go-test-${{ hashFiles('**/go.sum') }}
restore-keys: go-generate-
- name: Run go generate
run: ./.github/scripts/gogenerate.sh
rpm:
# The RPM step builds an RPM to test with the oVirt System Test. This can be invoked by typing /ost in the comment.
name: Build RPM
needs:
- generate
- test
- golangci-lint
runs-on: ubuntu-latest
container:
image: quay.io/centos/centos:stream8
steps:
- name: prepare env
run: |
yum install -y git createrepo_c rpm-build golang make
- name: Set up Go
uses: actions/setup-go@v3
with:
go-version: 1.16
- name: Checkout
uses: actions/checkout@v3
- name : Compile go-ovirt-client tests and Build go-ovirt-client-tests RPM
run: |
SUFFIX=.$(date -u +%Y%m%d%H%M%S).git$(git rev-parse --short HEAD)
mkdir -p go-ovirt-client-tests-bin
go generate
go test -v -c -o go-ovirt-client-tests-bin/go-ovirt-client-tests-exe
mkdir -p BUILDROOT SOURCES
cp go-ovirt-client-tests-bin/go-ovirt-client-tests-exe SOURCES/
tar cvzf go-ovirt-client-tests.tar.gz go-ovirt-client-tests-bin/
cp go-ovirt-client-tests.tar.gz SOURCES
git config --global --add safe.directory '*'
rpmbuild -D "_topdir $(pwd)" -D "release_suffix ${SUFFIX}" -bb go-ovirt-client-tests.spec
- name: Collect artifacts
run: |
mkdir -p exported-artifacts
find . -iname \*rpm -exec mv "{}" exported-artifacts/ \;
ls -l exported-artifacts
- name: Upload artifacts
uses: ovirt/upload-rpms-action@main
with:
directory: exported-artifacts
- name: "Send comment to PR"
continue-on-error: true
run: |
set -euo pipefail
echo 'Your build is now ready for live testing. A maintainer now needs to issue the `/ost` command in order to proceed with testing.' >/tmp/comment
gh pr comment ${{needs.build.outputs.PR_ID}} -F /tmp/comment
env:
GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"