Cherry pick migration from Travis-CI to GitHub actions

This commit is contained in:
Xan Manning 2020-12-12 16:21:17 +00:00
parent e71ed70bdf
commit 082b1de830
6 changed files with 97 additions and 69 deletions

58
.github/workflows/ci.yml vendored Normal file
View file

@ -0,0 +1,58 @@
---
name: CI
'on':
pull_request:
push:
branches:
- master
- main
- v1_release
schedule:
- cron: "0 1 1 * *"
defaults:
run:
working-directory: "xanmanning.k3s"
jobs:
molecule:
name: Molecule
runs-on: ubuntu-latest
strategy:
matrix:
distro:
- centos7
- centos8
- debian9
- debian10
- ubuntu1804
- ubuntu2004
- amazonlinux2
- fedora31
- fedora30
- fedora29
scenario:
- default
- highavailability
steps:
- name: Checkout codebase
uses: actions/checkout@v2
with:
path: "xanmanning.k3s"
- name: Set up Python 3
uses: actions/setup-python@v2
with:
python-version: "3.x"
- name: Install test dependencies
run: pip3 install ansible molecule[docker] docker yamllint ansible-lint jmespath
- name: Run Molecule tests
run: molecule test --scenario-name "${{ matrix.scenario }}"
env:
PY_COLORS: '1'
ANSIBLE_FORCE_COLOR: '1'
MOLECULE_DISTRO: ${{ matrix.distro }}

32
.github/workflows/release.yml vendored Normal file
View file

@ -0,0 +1,32 @@
---
name: Release
'on':
push:
tags:
- '*'
defaults:
run:
working-directory: "xanmanning.k3s"
jobs:
release:
name: Release
runs-on: ubuntu-latest
steps:
- name: Checkout codebase
uses: actions/checkout@v2
with:
path: "xanmanning.k3s"
- name: Set up Python 3
uses: actions/setup-python@v2
with:
python-version: "3.x"
- name: Install Ansible
run: pip3 install ansible-base
- name: Trigger a new import on Galaxy
run: ansible-galaxy role import --api-key ${{ secrets.GALAXY_API_KEY }} $(echo ${{ github.repository }} | cut -d/ -f1) $(echo ${{ github.repository }} | cut -d/ -f2)

View file

@ -1,62 +0,0 @@
---
# Thanks to geerlingguy!
language: python
services: docker
env:
global:
- ROLE_NAME: k3s
- ROLE_OWNER: xanmanning
- REPO_OWNER: PyratLabs
- MOLECULE_SCENARIO: default
matrix:
- MOLECULE_DISTRO: geerlingguy/docker-debian10-ansible:latest
# Test installing docker
- MOLECULE_DISTRO: geerlingguy/docker-centos7-ansible:latest
MOLECULE_PLAYBOOK: playbook-docker.yml
- MOLECULE_DISTRO: geerlingguy/docker-ubuntu1804-ansible:latest
MOLECULE_PLAYBOOK: playbook-docker.yml
- MOLECULE_DISTRO: geerlingguy/docker-amazonlinux2-ansible:latest
MOLECULE_PLAYBOOK: playbook-docker.yml
# Test using alternate port and using wireguard as the flannel backend
- MOLECULE_DISTRO: geerlingguy/docker-centos7-ansible:latest
MOLECULE_PLAYBOOK: playbook-docker-altport-wireguard.yml
# Test disabling all deployments
- MOLECULE_DISTRO: geerlingguy/docker-fedora31-ansible:latest
MOLECULE_PLAYBOOK: playbook-no-deploy.yml
# Test multiple controllers in control plane with PostgreSQL
- MOLECULE_DISTRO: geerlingguy/docker-fedora29-ansible:latest
MOLECULE_SCENARIO: highavailability
# Test multiple controllers with auto deploying manifests
- MOLECULE_DISTRO: geerlingguy/docker-fedora30-ansible:latest
MOLECULE_SCENARIO: highavailability
MOLECULE_PLAYBOOK: playbook-auto-deploying-manifests.yml
# Test multiple controllers in control plane with Etcd
- MOLECULE_DISTRO: geerlingguy/docker-centos8-ansible:latest
MOLECULE_SCENARIO: highavailability
MOLECULE_PLAYBOOK: playbook-etcd.yml
install:
# Install test dependencies.
- pip install molecule[docker] docker jmespath ansible-lint
before_script:
# Use actual Ansible Galaxy role name for the project directory.
- cd ../
- mv ansible-role-${ROLE_NAME} ${ROLE_OWNER}.${ROLE_NAME}
- cd ${ROLE_OWNER}.${ROLE_NAME}
script:
# Run tests.
- molecule test --scenario-name "${MOLECULE_SCENARIO}"
notifications:
webhooks: https://galaxy.ansible.com/api/v1/notifications/

View file

@ -3,7 +3,7 @@
Ansible role for installing [Rancher Labs k3s](https://k3s.io/) ("Lightweight
Kubernetes") as either a standalone server or cluster.
[![Build Status](https://www.travis-ci.org/PyratLabs/ansible-role-k3s.svg?branch=master)](https://www.travis-ci.org/PyratLabs/ansible-role-k3s)
[![CI](https://github.com/PyratLabs/ansible-role-k3s/workflows/CI/badge.svg?event=push)](https://github.com/PyratLabs/ansible-role-k3s/actions?query=workflow%3ACI)
## Requirements

View file

@ -10,7 +10,7 @@ lint: |
ansible-lint
platforms:
- name: node1
image: "${MOLECULE_DISTRO:-geerlingguy/docker-centos8-ansible:latest}"
image: "geerlingguy/docker-${MOLECULE_DISTRO:-centos8}-ansible:latest"
command: ${MOLECULE_DOCKER_COMMAND:-""}
volumes:
- /sys/fs/cgroup:/sys/fs/cgroup:ro
@ -19,7 +19,7 @@ platforms:
networks:
- name: k3snet
- name: node2
image: "${MOLECULE_DISTRO:-geerlingguy/docker-centos8-ansible:latest}"
image: "geerlingguy/docker-${MOLECULE_DISTRO:-centos8}-ansible:latest"
command: ${MOLECULE_DOCKER_COMMAND:-""}
volumes:
- /sys/fs/cgroup:/sys/fs/cgroup:ro
@ -28,7 +28,7 @@ platforms:
networks:
- name: k3snet
- name: node3
image: "${MOLECULE_DISTRO:-geerlingguy/docker-centos8-ansible:latest}"
image: "geerlingguy/docker-${MOLECULE_DISTRO:-centos8}-ansible:latest"
command: ${MOLECULE_DOCKER_COMMAND:-""}
volumes:
- /sys/fs/cgroup:/sys/fs/cgroup:ro

View file

@ -10,7 +10,7 @@ lint: |
ansible-lint
platforms:
- name: node1
image: "${MOLECULE_DISTRO:-geerlingguy/docker-centos8-ansible:latest}"
image: "geerlingguy/docker-${MOLECULE_DISTRO:-centos8}-ansible:latest"
command: ${MOLECULE_DOCKER_COMMAND:-""}
volumes:
- /sys/fs/cgroup:/sys/fs/cgroup:ro
@ -19,7 +19,7 @@ platforms:
networks:
- name: k3snet
- name: node2
image: "${MOLECULE_DISTRO:-geerlingguy/docker-centos8-ansible:latest}"
image: "geerlingguy/docker-${MOLECULE_DISTRO:-centos8}-ansible:latest"
command: ${MOLECULE_DOCKER_COMMAND:-""}
volumes:
- /sys/fs/cgroup:/sys/fs/cgroup:ro
@ -28,7 +28,7 @@ platforms:
networks:
- name: k3snet
- name: node3
image: "${MOLECULE_DISTRO:-geerlingguy/docker-centos8-ansible:latest}"
image: "geerlingguy/docker-${MOLECULE_DISTRO:-centos8}-ansible:latest"
command: ${MOLECULE_DOCKER_COMMAND:-""}
volumes:
- /sys/fs/cgroup:/sys/fs/cgroup:ro