aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJan Macku <jamacku@redhat.com>2021-01-21 11:54:47 +0100
committerJan Macku <jamacku@redhat.com>2021-03-11 13:25:30 +0100
commit915e2fa334d22c23dbf1ef277bb82ca2511c55e0 (patch)
treece6057fb31664057f02093c146ece834dadb580a
parent2480546a44b35ce03bf900249e8a2cbc0da08289 (diff)
downloadinitscripts-915e2fa334d22c23dbf1ef277bb82ca2511c55e0.tar
initscripts-915e2fa334d22c23dbf1ef277bb82ca2511c55e0.tar.gz
initscripts-915e2fa334d22c23dbf1ef277bb82ca2511c55e0.tar.bz2
initscripts-915e2fa334d22c23dbf1ef277bb82ca2511c55e0.tar.xz
initscripts-915e2fa334d22c23dbf1ef277bb82ca2511c55e0.zip
ci: Migrate from Travis to GH Actions
There are two workflows, integration_test and shellcheck_test. Those are similar to original travis jobs. Co-authored-by: Frantisek Sumsal <frantisek@sumsal.cz>
-rwxr-xr-x.github/workflows/check-shell.sh (renamed from .ci/check-shell.sh)18
-rw-r--r--.github/workflows/exception-list.txt (renamed from .ci/exception-list.txt)0
-rw-r--r--.github/workflows/functions.sh (renamed from .ci/functions.sh)0
-rw-r--r--.github/workflows/integration_test.yml23
-rw-r--r--.github/workflows/script-list.txt (renamed from .ci/script-list.txt)0
-rw-r--r--.github/workflows/shellcheck_test.yml28
-rw-r--r--.travis.yml35
-rw-r--r--README.md2
8 files changed, 63 insertions, 43 deletions
diff --git a/.ci/check-shell.sh b/.github/workflows/check-shell.sh
index 6fef7dd1..e250142c 100755
--- a/.ci/check-shell.sh
+++ b/.github/workflows/check-shell.sh
@@ -1,21 +1,25 @@
#!/bin/bash
-# Path is wrong because of travis
-. ./.ci/functions.sh
+SCRIPT_DIR="$(dirname "$(readlink -f "$0")")"
+
+. $SCRIPT_DIR/functions.sh
+
+git_base=$1
+git_head=$2
# ------------ #
# FILE PATHS #
# ------------ #
-# https://medium.com/@joey_9999/how-to-only-lint-files-a-git-pull-request-modifies-3f02254ec5e0
+# https://github.com/actions/runner/issues/342
# get names of files from PR (excluding deleted files)
-git diff --name-only --diff-filter=db "${TRAVIS_COMMIT_RANGE}" > ../pr-changes.txt
+git diff --name-only --diff-filter=db "$git_base".."$git_head" > ../pr-changes.txt
# Find modified shell scripts
list_of_changes=()
file_to_array "../pr-changes.txt" "list_of_changes" 0
list_of_scripts=()
-file_to_array "./.ci/script-list.txt" "list_of_scripts" 1
+file_to_array "$SCRIPT_DIR/script-list.txt" "list_of_scripts" 1
# Create list of scripts for testing
list_of_changed_scripts=()
@@ -27,7 +31,7 @@ done
# Get list of exceptions
list_of_exceptions=()
-file_to_array "./.ci/exception-list.txt" "list_of_exceptions" 1
+file_to_array "$SCRIPT_DIR/exception-list.txt" "list_of_exceptions" 1
string_of_exceptions=$(join_by , "${list_of_exceptions[@]}")
echo -e "\n"
@@ -50,7 +54,7 @@ echo -e "\n"
shellcheck --format=gcc --exclude="${string_of_exceptions}" "${list_of_changed_scripts[@]}" 2> /dev/null | sed -e 's|$| <--[shellcheck]|' > ../pr-br-shellcheck.err
# make destination branch
-[[ ${TRAVIS_COMMIT_RANGE} =~ ^([0-9|a-f]*?)\. ]] && git checkout -q -b ci_br_dest "${BASH_REMATCH[1]}"
+git checkout -q -b ci_br_dest "$git_base"
shellcheck --format=gcc --exclude="${string_of_exceptions}" "${list_of_changed_scripts[@]}" 2> /dev/null | sed -e 's|$| <--[shellcheck]|' > ../dest-br-shellcheck.err
diff --git a/.ci/exception-list.txt b/.github/workflows/exception-list.txt
index 5b093820..5b093820 100644
--- a/.ci/exception-list.txt
+++ b/.github/workflows/exception-list.txt
diff --git a/.ci/functions.sh b/.github/workflows/functions.sh
index cbe00874..cbe00874 100644
--- a/.ci/functions.sh
+++ b/.github/workflows/functions.sh
diff --git a/.github/workflows/integration_test.yml b/.github/workflows/integration_test.yml
new file mode 100644
index 00000000..0975a35c
--- /dev/null
+++ b/.github/workflows/integration_test.yml
@@ -0,0 +1,23 @@
+# https://docs.github.com/en/actions/reference/workflow-syntax-for-github-actions
+name: Integration test
+on:
+ push:
+ branches:
+ - master
+ pull_request:
+ branches:
+ - master
+ - rhel*-branch
+ release:
+ types: [published, created]
+
+jobs:
+ buildCheck:
+ runs-on: ubuntu-20.04
+ steps:
+ - name: Repository checkout
+ uses: actions/checkout@v2
+ - name: Install dependencies
+ run: sudo apt update && sudo apt install -y libpopt-dev gettext
+ - name: Build & install
+ run: make all && make install DESTDIR=/tmp/initscripts
diff --git a/.ci/script-list.txt b/.github/workflows/script-list.txt
index 053672df..053672df 100644
--- a/.ci/script-list.txt
+++ b/.github/workflows/script-list.txt
diff --git a/.github/workflows/shellcheck_test.yml b/.github/workflows/shellcheck_test.yml
new file mode 100644
index 00000000..1088c264
--- /dev/null
+++ b/.github/workflows/shellcheck_test.yml
@@ -0,0 +1,28 @@
+# https://docs.github.com/en/actions/reference/workflow-syntax-for-github-actions
+name: Shellcheck test
+on:
+ pull_request:
+ branches:
+ - master
+ - rhel*-branch
+
+jobs:
+ shellCheck:
+ runs-on: ubuntu-20.04
+ defaults:
+ run:
+ shell: bash
+ steps:
+ - name: Install dependencies
+ run: sudo apt update && sudo apt-get install -y cmake help2man libboost-dev libboost-filesystem-dev libboost-program-options-dev libboost-python-dev libboost-regex-dev tree
+ - name: Clone csdiff repository
+ run: cd ../ && git clone --depth=1 https://github.com/kdudka/csdiff.git && cd -
+ - name: Build and install csdiff
+ run: cd ../csdiff && sudo make && sudo make install && cd -
+ - name: Repository checkout
+ uses: actions/checkout@v2
+ with:
+ fetch-depth: 0
+ ref: ${{ github.event.pull_request.head.sha }}
+ - name: Run shell-check test
+ run: bash ./.github/workflows/check-shell.sh ${{ github.event.pull_request.base.sha }} ${{ github.event.pull_request.head.sha }}
diff --git a/.travis.yml b/.travis.yml
deleted file mode 100644
index afb755d7..00000000
--- a/.travis.yml
+++ /dev/null
@@ -1,35 +0,0 @@
-os: linux
-dist: trusty
-language: c
-
-git:
- depth: 2
-
-## Source - 01: https://github.com/kdudka/csdiff/blob/master/.travis.yml
-before_install:
- - sudo apt-get update
- - sudo apt-get install apt-transport-https
- - echo "deb https://kdudka.fedorapeople.org/csbuild trusty contrib" | sudo tee -a /etc/apt/sources.list
- - sudo apt-get update
-
-install:
- - sudo apt-get install cmake help2man libboost-dev libboost-filesystem-dev libboost-program-options-dev libboost-python-dev libboost-regex-dev tree
- - sudo apt-get install -y --force-yes csbuild
-## End - 01
-
-# We need to install the libpopt dependency without sudo:
-addons:
- apt:
- packages:
- libpopt-dev
-
-jobs:
- include:
- - language: shell
- script:
- - 'if [ "$TRAVIS_PULL_REQUEST" != "false" ]; then bash ./.ci/check-shell.sh; fi'
- - language: c
- script: make all && make install DESTDIR=/tmp/initscripts
-
-notifications:
- email: false
diff --git a/README.md b/README.md
index 773c59ac..9f7c27ad 100644
--- a/README.md
+++ b/README.md
@@ -1,4 +1,4 @@
-# initscripts | [![Build Status](https://travis-ci.org/fedora-sysv/initscripts.svg?branch=master)](https://travis-ci.org/fedora-sysv/initscripts)
+# initscripts | [![Build Status](https://github.com/fedora-sysv/initscripts/workflows/Integration%20test/badge.svg)](https://github.com/fedora-sysv/initscripts/actions?query=workflow%3AIntegration+test) [![Shellcheck Status](https://github.com/fedora-sysv/initscripts/workflows/Shellcheck%20test/badge.svg)](https://github.com/fedora-sysv/initscripts/actions?query=workflow%3AShellcheck+test)
This repository contains source code for **legacy** *System V [initscripts](https://en.wikipedia.org/wiki/Init)*,
which are primarily used in *[Linux](https://en.wikipedia.org/wiki/Linux) distributions like e.g.*:
* [Fedora](https://en.wikipedia.org/wiki/Fedora_(operating_system))