Skip to content

Commit

Permalink
Merge pull request os-autoinst#11545 from rwx788/githubactions
Browse files Browse the repository at this point in the history
Switch CI checks to github actions from travis
  • Loading branch information
foursixnine authored Dec 8, 2020
2 parents 8f3abf0 + add1dbd commit 5f0a932
Show file tree
Hide file tree
Showing 6 changed files with 107 additions and 110 deletions.
19 changes: 19 additions & 0 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
name: Deploy

on:
push:
branches:
- master

jobs:
documentation:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Generate documentation
run: script/generateLibDocs.sh
- name: Deploy documentation
uses: peaceiris/actions-gh-pages@v3
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: ./docs
37 changes: 37 additions & 0 deletions .github/workflows/static.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
name: PR CI

on: pull_request

jobs:
static:
runs-on: ubuntu-latest
name: "Running ${{ matrix.test }} tests with perl v${{ matrix.perl-version }}"
strategy:
matrix:
include:
- test: static
perl-version: 5.32
- test: unit
perl-version: 5.32
- test: compile
perl-version: 5.26
container:
image: perldocker/perl-tester:${{ matrix.perl-version }}
steps:
- uses: actions/checkout@v2
- name: Install dependencies
run: apt-get -y install yamllint libdbus-1-dev libssh2-1-dev parallel
- name: Setup perl
run: |
echo "requires 'Code::DRY';" >> cpanfile
echo "requires 'Date::Parse';" >> cpanfile
echo "requires 'Regexp::Common';" >> cpanfile
echo "requires 'Perl::Tidy', '== 20201001';" >> cpanfile
make prepare
- name: Run ${{ matrix.test }} tests
env:
TESTS: ${{ matrix.test }}
run: |
git fetch origin master
git checkout cpanfile
make test
46 changes: 0 additions & 46 deletions .travis.yml

This file was deleted.

19 changes: 9 additions & 10 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -60,10 +60,9 @@ test-compile-changed: os-autoinst/
test-yaml-valid:
@# Get list of changed yaml files. We only want to lint changed files for
@# now because yamllint complains about a lot of existing files
$(eval YAMLS=$(shell sh -c "git ls-files schedule/ test_data/ | grep '/.*\.y.\?ml$$'"))
export PERL5LIB=${PERL5LIB_} ; tools/test_yaml_valid $(YAMLS);\
$(eval CHANGED_YAMLS=$(shell sh -c "git --no-pager diff --diff-filter=dr --name-only master | grep '\(schedule\|test_data\)/.*\.y.\?ml$$'"))
$(eval CHANGED_YAMLS=$(shell sh -c "git --no-pager diff --diff-filter=dr --name-only origin/master | grep '\(schedule\|test_data\)/.*\.y.\?ml$$'"))
if test -n "$(CHANGED_YAMLS)"; then \
export PERL5LIB=${PERL5LIB_} ; tools/test_yaml_valid $(CHANGED_YAMLS);\
which yamllint >/dev/null 2>&1 || echo "Command 'yamllint' not found, can not execute YAML syntax checks";\
yamllint -c .yamllint $(CHANGED_YAMLS);\
else \
Expand All @@ -72,7 +71,7 @@ test-yaml-valid:

.PHONY: test-modules-in-yaml-schedule
test-modules-in-yaml-schedule:
export PERL5LIB=${PERL5LIB_} ; tools/detect_nonexistent_modules_in_yaml_schedule `git diff --diff-filter=d --name-only --exit-code $$(git merge-base master HEAD) | grep '^schedule/*'`
export PERL5LIB=${PERL5LIB_} ; tools/detect_nonexistent_modules_in_yaml_schedule `git diff --diff-filter=d --name-only --exit-code origin/master | grep '^schedule/*'`

.PHONY: test-metadata
test-metadata:
Expand All @@ -84,9 +83,9 @@ test-metadata-changed:

.PHONY: test-merge
test-merge:
@REV=$$(git merge-base FETCH_HEAD master 2>/dev/null) ;\
@REV=$$(git merge-base origin/master 2>/dev/null) ;\
if test -n "$$REV"; then \
FILES=$$(git diff --name-only FETCH_HEAD `git merge-base FETCH_HEAD master 2>/dev/null` | grep 'tests.*pm') ;\
FILES=$$(git diff --name-only origin/master | grep 'tests.*pm') ;\
for file in $$FILES; do if test -f $$file; then \
tools/check_metadata $$file || touch failed; \
git --no-pager grep wait_idle $$file && touch failed; \
Expand Down Expand Up @@ -130,17 +129,17 @@ perlcritic: tools/lib/
.PHONY: test-unused-modules-changed
test-unused-modules-changed:
@echo "[make] Unused modules check called over modified/new files only. For a full run use make test-unused-modules-full"
tools/detect_unused_modules -m `git --no-pager diff --name-only --diff-filter=d $$(git merge-base master HEAD) | grep '^tests/*' | grep -v '^tests/test_pods/'`
tools/detect_unused_modules -m `git --no-pager diff --unified=0 $$(git merge-base master HEAD) products/* | grep -oP "^-.*loadtest.*[\"']\K[^\"'].+(?=[\"'])"`
tools/detect_unused_modules -m `git --no-pager diff --unified=0 $$(git merge-base master HEAD) schedule/* | grep -oP "^-\s+- [\"']?\K.*(?=[\"']?)" | grep -v '{{'`
tools/detect_unused_modules -m `git --no-pager diff --name-only --diff-filter=d origin/master | grep '^tests/*' | grep -v '^tests/test_pods/'`
tools/detect_unused_modules -m `git --no-pager diff --unified=0 origin/master products/* | grep -oP "^-.*loadtest.*[\"']\K[^\"'].+(?=[\"'])"`
tools/detect_unused_modules -m `git --no-pager diff --unified=0 origin/master schedule/* | grep -oP "^-\s+- [\"']?\K.*(?=[\"']?)" | grep -v '{{'`

.PHONY: test-unused-modules
test-unused-modules:
tools/detect_unused_modules -a

.PHONY: test-deleted-renamed-referenced-files
test-deleted-renamed-referenced-files:
tools/test_deleted_renamed_referenced_files `git diff --name-only --exit-code --diff-filter=DR $$(git merge-base master HEAD) | grep '^test*'`
tools/test_deleted_renamed_referenced_files `git diff --name-only --exit-code --diff-filter=DR origin/master | grep '^test*'`

.PHONY: test-soft_failure-no-reference
test-soft_failure-no-reference:
Expand Down
16 changes: 8 additions & 8 deletions os-autoinst-distri-opensuse-deps.spec
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ Url: https://github.com/os-autoinst/os-autoinst-distri-opensuse
Requires: perl(Carp)
Requires: perl(Code::DRY)
Requires: perl(Config::Tiny)
Requires: perl(constant)
Requires: perl(Cwd)
Requires: perl(Data::Dump)
Requires: perl(Data::Dumper)
Expand All @@ -41,35 +40,36 @@ Requires: perl(File::Path)
Requires: perl(File::Temp)
Requires: perl(IO::File)
Requires: perl(IO::Socket::INET)
Requires: perl(LWP::Simple)
Requires: perl(List::MoreUtils)
Requires: perl(List::Util)
Requires: perl(LWP::Simple)
Requires: perl(Mojo::Base)
Requires: perl(Mojo::File)
Requires: perl(Mojo::JSON)
Requires: perl(Mojo::UserAgent)
Requires: perl(Mojo::Util)
Requires: perl(parent)
Requires: perl(Perl::Critic::Freenode)
Requires: perl(POSIX)
Requires: perl(Perl::Critic::Freenode)
Requires: perl(Regexp::Common)
Requires: perl(Selenium::Chrome)
Requires: perl(Selenium::Remote::Driver)
Requires: perl(Selenium::Remote::WDKeys)
Requires: perl(Selenium::Waiter)
Requires: perl(Storable)
Requires: perl(strict)
Requires: perl(Term::ANSIColor)
Requires: perl(Test::Assert)
Requires: perl(Tie::IxHash)
Requires: perl(Time::HiRes)
Requires: perl(utf8)
Requires: perl(version)
Requires: perl(warnings)
Requires: perl(XML::LibXML)
Requires: perl(XML::Simple)
Requires: perl(XML::Writer)
Requires: perl(YAML::PP)
Requires: perl(constant)
Requires: perl(parent)
Requires: perl(strict)
Requires: perl(utf8)
Requires: perl(version)
Requires: perl(warnings)
# END AUTOGENERATED DEPENDENCY LIST
Recommends: os-autoinst

Expand Down
80 changes: 34 additions & 46 deletions script/generateLibDocs.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,50 +15,38 @@
# You should have received a copy of the GNU General Public License along
# with this program; if not, see <http://www.gnu.org/licenses/>.

NEW_DEPLOY_NEEDED=0

if [ -z $GITHUB_TOKEN ] ; then
NEW_DEPLOY_NEEDED=0
else
cd $TRAVIS_BUILD_DIR

git fetch origin gh-pages:gh-pages

echo "Documentation of libs" > docs/index.html
echo "<ul><li>libs/</li><ul>" >> docs/index.html

for docfile in $(cd lib ; grep -rs ^=head * | grep .pm | cut -d. -f1 | sort -u) ; do
echo "Generating docs for lib/${docfile}.pm"
echo "<li><a href="${docfile}.html">${docfile}.pm</a></li>" >> docs/index.html
mkdir -p docs/$(dirname ${docfile})
touch docs/${docfile}.html
pod2html --infile=lib/${docfile}.pm --outfile=docs/${docfile}.html
# remove line that contains perl version and breaks diff
sed -i '/^<link rev="made" href="mailto:/d' docs/${docfile}.html
stylepath=$(dirname ${docfile} | sed 's|[^/.][^/.]*|..|g')
sed -i "s|^</head>|<link rel='stylesheet' href='${stylepath}/style.css' />\n</head>|" docs/${docfile}.html
sed -i "s|></title>|>lib/${docfile}.pm</title>|" docs/${docfile}.html
sed -i "s|<ul id=\"index\">|<ul id=\"index\"><li><a href=\"${stylepath}/index.html\"><i>\&lt;= Back to file list</i></a></li>|" docs/${docfile}.html
# only replace first occurance
awk "NR==1,/^<\/ul>/{sub(/^<\/ul>/, \"</ul><h1>lib/${docfile}.pm</h1>\")} 1" docs/${docfile}.html > docs/${docfile}.html.tmp
mv docs/${docfile}.html.tmp docs/${docfile}.html

#checkout old docs and compare to new ones, then toggle flag accordingly
git checkout gh-pages ${docfile}.html 2>/dev/null || touch ${docfile}.html
diff -u ${docfile}.html docs/${docfile}.html
diff_ret_val=$?
if [ "${ret_val}" = "0" ] ; then
ret_val="$diff_ret_val"
fi
git reset HEAD ${docfile}.html
rm ${docfile}.html
done

echo "</ul></ul>" >> docs/index.html

if [ "${ret_val}" != "0" ] ; then
NEW_DEPLOY_NEEDED=1
else
NEW_DEPLOY_NEEDED=0
git fetch origin gh-pages:gh-pages

echo "Documentation of libs" > docs/index.html
echo "<ul><li>libs/</li><ul>" >> docs/index.html

ret_val=0

for docfile in $(cd lib ; grep -rs ^=head * | grep .pm | cut -d. -f1 | sort -u) ; do
echo "Generating docs for lib/${docfile}.pm"
echo "<li><a href="${docfile}.html">${docfile}.pm</a></li>" >> docs/index.html
mkdir -p docs/$(dirname ${docfile})
touch docs/${docfile}.html
pod2html --infile=lib/${docfile}.pm --outfile=docs/${docfile}.html
# remove line that contains perl version and breaks diff
sed -i '/^<link rev="made" href="mailto:/d' docs/${docfile}.html
stylepath=$(dirname ${docfile} | sed 's|[^/.][^/.]*|..|g')
sed -i "s|^</head>|<link rel='stylesheet' href='${stylepath}/style.css' />\n</head>|" docs/${docfile}.html
sed -i "s|></title>|>lib/${docfile}.pm</title>|" docs/${docfile}.html
sed -i "s|<ul id=\"index\">|<ul id=\"index\"><li><a href=\"${stylepath}/index.html\"><i>\&lt;= Back to file list</i></a></li>|" docs/${docfile}.html
# only replace first occurance
awk "NR==1,/^<\/ul>/{sub(/^<\/ul>/, \"</ul><h1>lib/${docfile}.pm</h1>\")} 1" docs/${docfile}.html > docs/${docfile}.html.tmp
mv docs/${docfile}.html.tmp docs/${docfile}.html

#checkout old docs and compare to new ones, then toggle flag accordingly
git checkout gh-pages ${docfile}.html 2>/dev/null || touch ${docfile}.html
diff -u ${docfile}.html docs/${docfile}.html
diff_ret_val=$?
if [ "${ret_val}" = "0" ] ; then
ret_val="$diff_ret_val"
fi
fi
git reset HEAD ${docfile}.html
rm ${docfile}.html
done

echo "</ul></ul>" >> docs/index.html

0 comments on commit 5f0a932

Please sign in to comment.