From e5eff20cb2fc0d4de16a4ba380bd4307539d7a03 Mon Sep 17 00:00:00 2001 From: Dinesh Prasanth M K Date: Fri, 24 Apr 2020 12:33:46 -0400 Subject: [PATCH] Migrate to GH actions (#4) This patch migrates CI from Travis to Github Actions. There are 2 stages: - Build stage: Where the actual build happens - Test stage: Where the tests are executed Build artifacts are uploaded to the workflow Signed-off-by: Dinesh Prasanth M K --- .github/workflows/required.yml | 91 ++++++++++++++++++++++++++++++++++ .travis.yml | 41 --------------- ci/container-init.sh | 16 ++++++ {travis => ci}/ds-create.sh | 0 {travis => ci}/ds-remove.sh | 0 {travis => ci}/tools-test.sh | 0 travis/container-init.sh | 7 --- 7 files changed, 107 insertions(+), 48 deletions(-) create mode 100644 .github/workflows/required.yml delete mode 100644 .travis.yml create mode 100755 ci/container-init.sh rename {travis => ci}/ds-create.sh (100%) rename {travis => ci}/ds-remove.sh (100%) rename {travis => ci}/tools-test.sh (100%) delete mode 100755 travis/container-init.sh diff --git a/.github/workflows/required.yml b/.github/workflows/required.yml new file mode 100644 index 0000000..70511a6 --- /dev/null +++ b/.github/workflows/required.yml @@ -0,0 +1,91 @@ +name: Required Tests + +on: + push: + branches: + - master + pull_request: + branches: + - master + +jobs: + build: + name: Build + strategy: + matrix: + os: ['30', '31'] + runs-on: ubuntu-latest + container: fedora:${{ matrix.os }} + steps: + + - name: Install required packages + run: dnf install -y dnf-plugins-core rpm-build git + + - name: Clone the repository + uses: actions/checkout@v2 + + - name: Enable PKI COPR repo + run: dnf copr -y enable @pki/master + + - name: Installed build deps + run: dnf builddep -y --spec ldapjdk.spec + + - name: Build artifacts + run: ./build.sh --with-timestamp --with-commit-id --work-dir=../packages rpm + + - name: Compress RPMS + run: tar -czf ldapjdk-rpms.tar.gz ../packages/RPMS/* + + # upload-artifact runs on host-vm rather than inside the container. Fixed in v2 (unreleased) + # Bug: https://github.com/actions/upload-artifact/issues/13#issuecomment-532936650 + - name: Upload RPM artifacts + uses: actions/upload-artifact@v1 + with: + name: ldapjdk-build-${{ matrix.os }} + path: ldapjdk-rpms.tar.gz + + test: + name: Tests + needs: build + strategy: + matrix: + os: ['30', '31'] + runs-on: ubuntu-latest + env: + LDAPJDKDIR: /tmp/workdir/ldapjdk + CONTAINER: ldapjdk-test + steps: + - name: Clone the repository + uses: actions/checkout@v2 + + - name: Download ldapjdk binaries from Build job + uses: actions/download-artifact@v1 + with: + name: ldapjdk-build-${{ matrix.os }} + + - name: Extract tar.gz for rpms + run: tar -xzf ldapjdk-build-${{ matrix.os }}/ldapjdk-rpms.tar.gz + + - name: Setup required test environment + run: IMAGE=fedora:${{ matrix.os }} ci/container-init.sh + + - name: Install required packages + run: | + docker exec -i ${CONTAINER} rm -f /var/cache/dnf/metadata_lock.pid + docker exec -i ${CONTAINER} bash -c "dnf update -y && dnf clean all" + docker exec -i ${CONTAINER} dnf install -y 389-ds-base-legacy-tools findutils dnf-plugins-core sudo 389-ds-base + + - name: Enable PKI COPR repo + run: docker exec -i ${CONTAINER} dnf copr -y enable @pki/master + + - name: Install ldapjdk packages from Build job + run: docker exec -i ${CONTAINER} bash -c "find ${LDAPJDKDIR}/packages/ -name '*.rpm' | xargs dnf -y install" + + - name: Create DS instance + run: docker exec -i ${CONTAINER} ${LDAPJDKDIR}/ci/ds-create.sh + + - name: Run ldapjdk Tests + run: docker exec -i ${CONTAINER} ${LDAPJDKDIR}/ci/tools-test.sh + + - name: Remove DS instance + run: docker exec -i ${CONTAINER} ${LDAPJDKDIR}/ci/ds-remove.sh diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 6567f75..0000000 --- a/.travis.yml +++ /dev/null @@ -1,41 +0,0 @@ -# BEGIN COPYRIGHT BLOCK -# (C) 2018 Red Hat, Inc. -# All rights reserved. -# END COPYRIGHT BLOCK - -services: - - docker - -env: - - FEDORA=29 - - FEDORA=30 - -install: - - docker pull registry.fedoraproject.org/fedora:$FEDORA - - docker run - --name container - --hostname server.example.com - --tmpfs /tmp - --tmpfs /run - --volume /sys/fs/cgroup:/sys/fs/cgroup:ro - --volume $(pwd):/root/ldapjdk - --detach - -i - registry.fedoraproject.org/fedora:$FEDORA - "/usr/sbin/init" - - docker exec container /root/ldapjdk/travis/container-init.sh - - docker exec container dnf install -y dnf-plugins-core rpm-build - - docker exec container dnf copr -y enable @pki/master - - docker exec container dnf builddep -y --spec /root/ldapjdk/ldapjdk.spec - - docker exec container /root/ldapjdk/build.sh --with-timestamp --with-commit-id rpm - - docker exec container rpm -Uvh /root/build/ldapjdk/RPMS/* - - docker exec container dnf install -y 389-ds-base 389-ds-base-legacy-tools - -script: - - docker exec container /root/ldapjdk/travis/ds-create.sh - - docker exec container /root/ldapjdk/travis/tools-test.sh - - docker exec container /root/ldapjdk/travis/ds-remove.sh - -after_script: - - docker kill container - - docker rm container diff --git a/ci/container-init.sh b/ci/container-init.sh new file mode 100755 index 0000000..083ed5f --- /dev/null +++ b/ci/container-init.sh @@ -0,0 +1,16 @@ +#!/bin/bash -ex + +docker pull registry.fedoraproject.org/${IMAGE} + +docker run \ + --name ${CONTAINER} \ + --hostname server.example.com \ + --tmpfs /tmp \ + --tmpfs /run \ + --volume /sys/fs/cgroup:/sys/fs/cgroup:ro \ + --volume ${GITHUB_WORKSPACE}:${LDAPJDKDIR} \ + -e LDAPJDKDIR="${LDAPJDKDIR}" \ + --detach \ + -i \ + registry.fedoraproject.org/${IMAGE} \ + "/usr/sbin/init" diff --git a/travis/ds-create.sh b/ci/ds-create.sh similarity index 100% rename from travis/ds-create.sh rename to ci/ds-create.sh diff --git a/travis/ds-remove.sh b/ci/ds-remove.sh similarity index 100% rename from travis/ds-remove.sh rename to ci/ds-remove.sh diff --git a/travis/tools-test.sh b/ci/tools-test.sh similarity index 100% rename from travis/tools-test.sh rename to ci/tools-test.sh diff --git a/travis/container-init.sh b/travis/container-init.sh deleted file mode 100755 index f2bdd11..0000000 --- a/travis/container-init.sh +++ /dev/null @@ -1,7 +0,0 @@ -#!/bin/bash -e - -# workaround for -# [Errno 2] No such file or directory: '/var/cache/dnf/metadata_lock.pid' -rm -f /var/cache/dnf/metadata_lock.pid -dnf clean all -dnf makecache || :