Switch to Github Actions

This commit is contained in:
Pedro Algarvio 2020-01-28 10:51:36 +00:00
parent fa1f1e9d40
commit e7984fc2e1
No known key found for this signature in database
GPG key ID: BB36BF6584A298FF
5 changed files with 3195 additions and 0 deletions

2991
.github/workflows/main.yml vendored Normal file

File diff suppressed because it is too large Load diff

142
.github/workflows/templates/generate.py vendored Normal file
View file

@ -0,0 +1,142 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import os
import datetime
os.chdir(os.path.abspath(os.path.dirname(__file__)))
LINUX_DISTROS = [
'amazon-1',
'amazon-2',
'arch',
'centos-6',
'centos-7',
'centos-8',
'debian-10',
'debian-8',
'debian-9',
'fedora-30',
#'fedora-31',
'opensuse-15',
'ubuntu-1604',
'ubuntu-1804'
]
OSX = WINDOWS = []
STABLE_DISTROS = [
'amazon-1',
'amazon-2',
'centos-6',
'centos-7',
'centos-8',
'debian-10',
'debian-8',
'debian-9',
'fedora-30',
'fedora-31',
'ubuntu-1604',
'ubuntu-1804',
]
PY2_BLACKLIST = [
'centos-8',
'debian-10',
'fedora-31',
]
PY3_BLACKLIST = [
'amazon-1',
'centos-6',
'debian-8',
'opensuse-15'
]
BLACKLIST_2018 = [
'amazon-2',
'centos-8',
'debian-10',
]
SALT_BRANCHES = [
'2018-3',
'2019-2',
]
DISTRO_DISPLAY_NAMES = {
'amazon-1': 'Amazon 1',
'amazon-2': 'Amazon 2',
'arch': 'Arch',
'centos-6': 'CentOS 6',
'centos-7': 'CentOS 7',
'centos-8': 'CentOS 8',
'debian-10': 'Debian 10',
'debian-8': 'Debian 8',
'debian-9': 'Debian 9',
'fedora-30': 'Fedora 30',
'fedora-31': 'Fedora 31',
'opensuse-15': 'Opensuse 15',
'ubuntu-1604': 'Ubuntu 16.04',
'ubuntu-1804': 'Ubuntu 18.04'
}
def generate_test_jobs():
test_jobs = ''
for distro in LINUX_DISTROS + OSX + WINDOWS:
for branch in SALT_BRANCHES:
for python_version in ('py2', 'py3'):
for bootstrap_type in ('stable', 'git'):
if bootstrap_type == 'stable' and distro not in STABLE_DISTROS:
continue
if branch == '2018-3' and distro in BLACKLIST_2018:
continue
if python_version == 'py2' and distro in PY2_BLACKLIST:
continue
if python_version == 'py3' and distro in PY3_BLACKLIST:
continue
if distro in LINUX_DISTROS:
template = 'linux.yml'
elif distro in OSX:
template = 'osx.yml'
elif distro in WINDOWS:
template = 'windows.yml'
else:
print("Don't know how to handle {}".format(distro))
with open(template) as rfh:
test_jobs += '\n{}\n'.format(
rfh.read().format(
distro=distro,
branch=branch,
python_version=python_version,
bootstrap_type=bootstrap_type,
display_name='{} {} {} {}'.format(
DISTRO_DISPLAY_NAMES[distro],
branch.replace('-', '.'),
python_version.capitalize(),
bootstrap_type.capitalize()
)
)
)
with open('lint.yml') as rfh:
lint_job = '\n{}\n'.format(rfh.read())
with open('../main.yml', 'w') as wfh:
with open('main.yml') as rfh:
wfh.write(
rfh.read().format(
lint_job=lint_job,
test_jobs=test_jobs,
)
)
if __name__ == '__main__':
generate_test_jobs()

8
.github/workflows/templates/lint.yml vendored Normal file
View file

@ -0,0 +1,8 @@
Lint:
runs-on: ubuntu-latest
container: koalaman/shellcheck-alpine:v0.6.0
steps:
- uses: actions/checkout@v1
- name: ShellCheck
run: |
shellcheck -s sh -f checkstyle bootstrap-salt.sh

43
.github/workflows/templates/linux.yml vendored Normal file
View file

@ -0,0 +1,43 @@
{distro}-{branch}-{python_version}-{bootstrap_type}:
name: {display_name}
runs-on: ubuntu-latest
needs: Lint
steps:
- uses: actions/checkout@v1
- name: Setup Ruby
uses: actions/setup-ruby@v1
with:
ruby-version: 2.6.x
- name: Install Bundler
run: |
gem install bundler
- name: Setup Bundle
run: |
bundle install --with docker --without opennebula ec2 windows vagrant
- name: Set up Python 3.7
uses: actions/setup-python@v1
with:
python-version: 3.7
- name: Install Python Dependencies
run: |
pip install -U pip
pip install -r tests/requirements.txt
- name: Create Test Container
run: |
bundle exec kitchen create {python_version}-{bootstrap_type}-{branch}-{distro} || bundle exec kitchen create {python_version}-{bootstrap_type}-{branch}-{distro}
- name: Test Bootstrap In Test Container
run: |
bundle exec kitchen verify {python_version}-{bootstrap_type}-{branch}-{distro}
- name: Destroy Test Container
if: always()
run: |
bundle exec kitchen destroy {python_version}-{bootstrap_type}-{branch}-{distro}

11
.github/workflows/templates/main.yml vendored Normal file
View file

@ -0,0 +1,11 @@
# DO NOT EDIT THIS FILE DIRECTLY!
#
# This file was generated by .github/workflows/templates/generate.py
name: Testing
on: [push, pull_request]
jobs:
{lint_job}
{test_jobs}