From 4b2089bbf608e9d265ffcf439f638e1d34c8bf72 Mon Sep 17 00:00:00 2001 From: Major Hayden Date: Thu, 27 Feb 2020 11:03:07 -0600 Subject: [PATCH] =?UTF-8?q?=F0=9F=8C=AE=20Merge=20GitHub=20Actions=20workf?= =?UTF-8?q?lows?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit A single workflow allows us to re-use artifacts throughout all jobs. Also, we can fail the tests early if there's a linting issue before we spend time waiting for RPMs to build. Signed-off-by: Major Hayden --- .github/workflows/build_rpms.yml | 77 -------------------------------- .github/workflows/tests.yml | 68 ++++++++++++++++++++++++++++ 2 files changed, 68 insertions(+), 77 deletions(-) delete mode 100644 .github/workflows/build_rpms.yml diff --git a/.github/workflows/build_rpms.yml b/.github/workflows/build_rpms.yml deleted file mode 100644 index a177bfed..00000000 --- a/.github/workflows/build_rpms.yml +++ /dev/null @@ -1,77 +0,0 @@ -name: RPM Build - -# NOTE(mhayden): Restricting branches prevents jobs from being doubled since -# a push to a pull request triggers two events. -on: - pull_request: - branches: - - "*" - push: - branches: - - master - -jobs: - rpm_build: - name: "Build RPMs" - runs-on: ubuntu-latest - strategy: - fail-fast: false - matrix: - fedora_release: ["31", "32", "rawhide"] - container: - image: "docker.io/library/fedora:${{ matrix.fedora_release }}" - steps: - - name: Prepare container - run: | - echo "fastestmirror=1" >> /etc/dnf/dnf.conf - echo "install_weak_deps=0" >> /etc/dnf/dnf.conf - rm -fv /etc/yum.repos.d/fedora*modular* - dnf -y upgrade - dnf -y install dnf-plugins-core rpm-build rpmdevtools - - - name: Fetch .spec file - run: | - mkdir spec - # Fetch the spec file at the given commit, and prepend the commit sha to it - curl "https://raw.githubusercontent.com/osbuild/osbuild/${GITHUB_SHA}/osbuild.spec" -o osbuild.spec - echo "%global commit ${GITHUB_SHA}" | cat - osbuild.spec > spec/osbuild.spec - - - name: Install RPM build dependencies - run: dnf -y builddep spec/osbuild.spec - - - name: Fetch sources - run: | - mkdir sources - spectool -g spec/osbuild.spec -C sources/ - - - name: Build SRPM - run: | - mkdir srpms - rpmbuild -bs \ - --define "_sourcedir sources" \ - --define "_srcrpmdir srpms" \ - spec/osbuild.spec - - - name: Build RPMs - run: | - mkdir rpmbuild rpms build - rpmbuild -bb \ - --define "_sourcedir `pwd`/sources" \ - --define "_specdir `pwd`/spec" \ - --define "_builddir `pwd`/rpmbuild" \ - --define "_srcrpmdir `pwd`/srpms" \ - --define "_rpmdir `pwd`/rpms" \ - --define "_buildrootdir `pwd`/build" \ - spec/osbuild.spec - - - name: "Upload artifacts" - uses: actions/upload-artifact@v1 - with: - name: rpms - path: rpms/ - - - name: Test RPM installation - run: | - pushd rpms/noarch - dnf -y install $(ls *.rpm) - popd diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index c39a214e..6964945a 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -29,6 +29,7 @@ jobs: run: | cd osbuild pylint osbuild runners/* assemblers/* stages/* sources/* + unit_tests: name: "unit" runs-on: ubuntu-latest @@ -49,3 +50,70 @@ jobs: run: | cd osbuild python3 -m unittest -v test.test_objectstore + + rpm_build: + name: "RPM build" + needs: + - pylint + - unit_tests + runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + fedora_release: ["31", "32", "rawhide"] + container: + image: "docker.io/library/fedora:${{ matrix.fedora_release }}" + steps: + - name: Prepare container + run: | + echo "fastestmirror=1" >> /etc/dnf/dnf.conf + echo "install_weak_deps=0" >> /etc/dnf/dnf.conf + dnf -y upgrade + dnf -y install dnf-plugins-core rpm-build rpmdevtools + + - name: Fetch .spec file + run: | + mkdir spec + # Fetch the spec file at the given commit, and prepend the commit sha to it + curl "https://raw.githubusercontent.com/osbuild/osbuild/${GITHUB_SHA}/osbuild.spec" -o osbuild.spec + echo "%global commit ${GITHUB_SHA}" | cat - osbuild.spec > spec/osbuild.spec + + - name: Install RPM build dependencies + run: dnf -y builddep spec/osbuild.spec + + - name: Fetch sources + run: | + mkdir sources + spectool -g spec/osbuild.spec -C sources/ + + - name: Build SRPM + run: | + mkdir srpms + rpmbuild -bs \ + --define "_sourcedir sources" \ + --define "_srcrpmdir srpms" \ + spec/osbuild.spec + + - name: Build RPMs + run: | + mkdir rpmbuild rpms build + rpmbuild -bb \ + --define "_sourcedir `pwd`/sources" \ + --define "_specdir `pwd`/spec" \ + --define "_builddir `pwd`/rpmbuild" \ + --define "_srcrpmdir `pwd`/srpms" \ + --define "_rpmdir `pwd`/rpms" \ + --define "_buildrootdir `pwd`/build" \ + spec/osbuild.spec + + - name: "Upload artifacts" + uses: actions/upload-artifact@v1 + with: + name: rpms + path: rpms/ + + - name: Test RPM installation + run: | + pushd rpms/noarch + dnf -y install $(ls *.rpm) + popd