Skip to content

Commit

Permalink
Migrate to GH actions (#4)
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
SilleBille authored Apr 24, 2020
1 parent b7f0975 commit e5eff20
Show file tree
Hide file tree
Showing 7 changed files with 107 additions and 48 deletions.
91 changes: 91 additions & 0 deletions .github/workflows/required.yml
Original file line number Diff line number Diff line change
@@ -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
41 changes: 0 additions & 41 deletions .travis.yml

This file was deleted.

16 changes: 16 additions & 0 deletions ci/container-init.sh
Original file line number Diff line number Diff line change
@@ -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"
File renamed without changes.
File renamed without changes.
File renamed without changes.
7 changes: 0 additions & 7 deletions travis/container-init.sh

This file was deleted.

0 comments on commit e5eff20

Please sign in to comment.