From 8cb6715aab650b941e1e40489d9415886f5e0ac2 Mon Sep 17 00:00:00 2001 From: Takashi Sakamoto Date: Fri, 31 Jan 2020 23:05:40 +0900 Subject: [PATCH] Add support workflow of Github Actions Github Actions is tool to automate software development workflows for CI/CD. This tool has a remarkable point to share 'action' in repositories in github, which is a unit of processing defined by users. The users write and push 'workflow' with the 'action' into repository in github.com. When any workflow file is added to 'default' branch, the automation runs[2]. The defined actions run on virtual machine in Microsoft Azure (Standard_DS2_v2 as of today[2]). Three types of operating system are available: Windows, MacOS and Linux (Ubuntu). On the MacOS and Linux machine, 'sudo' is available to setup host environment for CI/CD, as well as Docker container is supported on the host. This commit adds a workflow file to automate build test. In this automation, Fedora 32 in Docker container and Ubuntu 19.10 in LXD container as build environments in Linux host. The automation is triggered in each 'push' and 'pull_request' event. The result is available in 'Actions' tab of repository page in github.com. [1] https://help.github.com/en/actions/automating-your-workflow-with-github-actions/about-github-actions [2] https://help.github.com/en/actions/automating-your-workflow-with-github-actions/configuring-a-workflow [3] https://help.github.com/en/actions/automating-your-workflow-with-github-actions/virtual-environments-for-github-hosted-runners Signed-off-by: Takashi Sakamoto --- .github/workflows/build.yml | 116 ++++++++++++++++++++++++++++++++++++ 1 file changed, 116 insertions(+) create mode 100644 .github/workflows/build.yml diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 00000000..ac2942c3 --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,116 @@ +name: Build test + +on: [push, pull_request] + +jobs: + build_in_fedora_on_docker: + runs-on: ubuntu-latest + container: + image: fedora:32 + steps: + - name: Checkout repository. + uses: actions/checkout@v2 + - name: Prepare build environment. + run: | + dnf -y upgrade + dnf -y install @development-tools + dnf -y install meson gobject-introspection-devel systemd-devel + dnf -y install gtk-doc python3-gobject + - name: Initialization for build. + run: | + meson --prefix=/tmp. -Dgtk_doc=true -Dwarning_level=3 . build + - name: Display configuration. + run: | + cd build + meson configure + - name: Build library. + run: | + cd build + ninja + - name: Test interfaces exposed by g-i. + run: | + cd build + meson test + - name: Test install. + run: | + cd build + meson install + + build_in_ubuntu_on_lxd: + runs-on: ubuntu-latest + steps: + - name: Install and initialize LXD + run: | + sudo snap install lxd + sudo lxd init --auto + - name: Launch container + run: | + sudo lxc launch ubuntu:19.10/amd64 builder + sudo lxc exec builder -- bash -c 'while [ "$(systemctl is-system-running 2>/dev/null)" != "running" ] && [ "$(systemctl is-system-running 2>/dev/null)" != "degraded" ]; do :; done' + - name: Prepare build environment. + run: | + sudo lxc exec builder -- su ubuntu -c 'sudo apt-get update' + sudo lxc exec builder -- su ubuntu -c 'sudo apt-get -y full-upgrade' + sudo lxc exec builder -- su ubuntu -c 'sudo apt-get install -y git build-essential' + sudo lxc exec builder -- su ubuntu -c 'sudo apt-get install -y meson ninja-build libglib2.0-dev libudev-dev gobject-introspection libgirepository1.0-dev' + sudo lxc exec builder -- su ubuntu -c 'sudo apt-get install -y gtk-doc-tools python3-gi' + - name: Clone repository. + run: | + sudo lxc exec builder -- su ubuntu -c "cd; git clone http://github.com/${GITHUB_REPOSITORY} local-repository" + - name: Generate archive. + run: | + sudo lxc exec builder -- su ubuntu -c "cd; cd local-repository; git archive --format=tar --prefix=dist/ ${GITHUB_SHA} | xz > ../archive.tar.xz" + - name: Expand archive. + run: | + sudo lxc exec builder -- su ubuntu -c 'cd; tar xf archive.tar.xz' + - name: Initialization for build + run: | + sudo lxc exec builder -- su ubuntu -c 'cd; cd dist; meson --prefix=/home/ubuntu/install -Dgtk_doc=true -Dwarning_level=3 . build' + - name: Display configuration. + run: | + sudo lxc exec builder -- su ubuntu -c 'cd; cd dist/build; meson configure' + - name: Build library. + run: | + sudo lxc exec builder -- su ubuntu -c 'cd; cd dist/build; ninja' + - name: Test interfaces exposed by g-i. + run: | + sudo lxc exec builder -- su ubuntu -c 'cd; cd dist/build; meson test' + - name: Test install. + run: | + sudo lxc exec builder -- su ubuntu -c 'cd; cd dist/build; meson install' + +# MEMO: my backup. +# build_in_ubuntu_on_docker: +# runs-on: ubuntu-latest +# container: +# image: ubuntu:19.10 +# steps: +# - name: Checkout repository. +# uses: actions/checkout@v2 +# - name: Prepare build environment. +# run: | +# apt-get update +# apt-get -y install apt-utils +# apt-get -y full-upgrade +# apt-get install -y git build-essential +# apt-get install -y meson ninja-build libglib2.0-dev libudev-dev gobject-introspection libgirepository1.0-dev +# apt-get install -y gtk-doc-tools python3-gi +# - name: Initialization for build. +# run: | +# meson --prefix=/tmp. -Dgtk_doc=true -Dwarning_level=3 . build +# - name: Display configuration. +# run: | +# cd build +# meson configure +# - name: Build library. +# run: | +# cd build +# ninja +# - name: Test interfaces exposed by g-i. +# run: | +# cd build +# meson test +# - name: Test install. +# run: | +# cd build +# meson install