Skip to content

Commit

Permalink
Merge pull request #162 from MonolithProjects/feat/macos_support
Browse files Browse the repository at this point in the history
Feat/macos support
  • Loading branch information
MonolithProjects authored May 14, 2023
2 parents 6f2b964 + 901cc72 commit dc13c70
Show file tree
Hide file tree
Showing 14 changed files with 210 additions and 140 deletions.
34 changes: 19 additions & 15 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
@@ -1,25 +1,29 @@
name: molecule lint

on:
push:
branches:
- develop
- feature/*
pull_request:
branches:
- develop
types: [opened, synchronize, reopened]
pull_request:
push:
branches:
- master

jobs:
lint:
runs-on: ubuntu-18.04
strategy:
fail-fast: true
name: Lint
runs-on: ubuntu-latest
steps:
- name: checkout
- name: Check out the codebase.
uses: actions/checkout@v3
with:
path: "${{ github.repository }}"
- name: Molecule for Ansible - lint
uses: MonolithProjects/action-molecule@v1.4.5

- name: Set up Python 3.
uses: actions/setup-python@v4
with:
molecule_command: lint
python-version: '3.x'

- name: Install test dependencies.
run: pip3 install ansible-lint yamllint

- name: Lint code.
run: |
ansible-lint --exclude molecule/ --exclude .github/
88 changes: 59 additions & 29 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,72 +2,102 @@ name: molecule test

on:
pull_request:
types:
- opened
- reopened
- synchronize
branches:
- 'master'
- master
types: [opened, synchronize, reopened]
paths:
- 'defaults/**'
- 'handlers/**'
- 'molecule/**'
- 'tasks/**'
- 'templates/**'
- 'vars/**'
schedule:
- cron: '0 6 * * 0'
- cron: '0 6 * * 0'
workflow_dispatch:

env:
MOLECULE_DOCKER_VOLUMES: ro
MOLECULE_DOCKER_CGROUPS_MODE: private
MOLECULE_DOCKER_VOLUMES: rw
MOLECULE_DOCKER_CGROUPS_MODE: host

jobs:
repo:
name: Test Repo Runner
name: Test GHA Runner Role
environment:
name: test
runs-on: ubuntu-20.04
runs-on: ubuntu-22.04
strategy:
fail-fast: false
max-parallel: 3
max-parallel: 5
matrix:
config:
- os: "debian11"
tag: "latest"
- os: "fedora37"
tag: "latest"
- os: "ubuntu20"
tag: "latest"
- os: "ubuntu22"
tag: "latest"
- os: "rockylinux8"
tag: "latest"
steps:
- name: checkout
uses: actions/checkout@v3
with:
path: "${{ github.repository }}"
- name: Molecule for Ansible - GHR Repository
uses: MonolithProjects/action-molecule@v1.4.5

- name: Set up Python 3
uses: actions/setup-python@v4
with:
python-version: '3.x'

- name: Install test dependencies
run: pip3 install ansible docker molecule molecule-plugins[docker] "requests<2.29.2" jmespath

- name: Run Molecule test - repo
run: molecule test --scenario-name repo
working-directory: "${{ github.repository }}"
env:
PY_COLORS: '1'
ANSIBLE_FORCE_COLOR: '1'
MOLECULE_IMAGE: ${{ matrix.config.os }}
MOLECULE_DOCKER_CGROUPS_MODE: ${{ matrix.config.cgroup_mode }}
MOLECULE_DOCKER_VOLUMES: ${{ matrix.config.volumes }}
PERSONAL_ACCESS_TOKEN: ${{ secrets.PERSONAL_ACCESS_TOKEN }}
with:
os: ${{ matrix.config.os }}
tag: ${{ matrix.config.tag }}
molecule_command: test
scenario: repo

org:
name: Test Org Runner
needs: repo
environment:
name: test
runs-on: ubuntu-20.04
runs-on: ubuntu-22.04
strategy:
fail-fast: false
max-parallel: 5
matrix:
config:
- os: "debian11"
- os: "fedora37"
- os: "ubuntu20"
- os: "ubuntu22"
- os: "rockylinux8"
steps:
- name: checkout
uses: actions/checkout@v3
with:
path: "${{ github.repository }}"
- name: Molecule for Ansible - GHR Organization
uses: MonolithProjects/action-molecule@v1.4.5

- name: Set up Python 3
uses: actions/setup-python@v4
with:
python-version: '3.x'

- name: Install test dependencies
run: pip3 install ansible docker molecule molecule-plugins[docker] "requests<2.29.2" jmespath

- name: Run Molecule tests -
run: molecule test --scenario-name org
working-directory: "${{ github.repository }}"
env:
PY_COLORS: '1'
ANSIBLE_FORCE_COLOR: '1'
MOLECULE_IMAGE: ${{ matrix.config.os }}
MOLECULE_DOCKER_CGROUPS_MODE: ${{ matrix.config.cgroup_mode }}
MOLECULE_DOCKER_VOLUMES: ${{ matrix.config.volumes }}
PERSONAL_ACCESS_TOKEN: ${{ secrets.PERSONAL_ACCESS_TOKEN }}
with:
molecule_command: test
scenario: org
21 changes: 14 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,14 @@
[![License](https://img.shields.io/github/license/MonolithProjects/ansible-github_actions_runner)](https://github.com/MonolithProjects/ansible-github_actions_runner/blob/main/LICENSE)


This role will deploy/redeploy/uninstall and register/unregister local GitHub Actions Runner.
This role will deploy/redeploy/uninstall and register/unregister local GitHub Actions Runner on Linux and macOS Systems (see [compatibility list](#supported-operating-systems) ).
It supports both, Organization and Repository Runners.

## Requirements

* System must have access to the GitHub.
* System must have access to the GitHub API.

* The role require Personal Access Token to access the GitHub. The token has to be a value of `PERSONAL_ACCESS_TOKEN` variable.
Export the token to the local host environment.
* The role require Personal Access Token to access the GitHub. The token can be set as `PERSONAL_ACCESS_TOKEN` environment variable.

> **Note**
> The token must have the `repo` scope (when creating a repo runner) or the `admin:org` scope (when creating a runner for an organization).
Expand All @@ -31,19 +30,27 @@ Personal Access Token for GitHub account can be created [here](https://github.co
* CentOS systems require EPEL repository.
Recommended role: `robertdebock.epel`

## Supported CPU architecture:
## Supported CPU architecture

* ARM, ARM64 (dependencies installation is not covered by this role)
* AMD64, x86_64

## Supported Operating Systems

* Red Hat Enterprise Linux 7
* CentOS 7
* Rocky Linux 8+
* Fedora 29+
* Debian 9+
* Ubuntu 16.04+
* macOS High Sierra +
## Weekly tested on:

* Debian 11
* Fedora 37
* Rocky Linux 8
* Ubuntu 20,22

**Note:** Fedora 32+ and Ubuntu 20 must use Ansible 2.9.8+. Other distros/releases will work also with older 2.8.0+ Ansible.

## Role Variables

This is a copy from `defaults/main.yml`
Expand Down
2 changes: 1 addition & 1 deletion defaults/main.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
# Runner user - user under which is the local runner service running
runner_user: "{{ lookup('env','USER') }}"
runner_user: "{{ lookup('env', 'USER') }}"

# Directory where the local runner will be installed
runner_dir: /opt/actions-runner
Expand Down
16 changes: 7 additions & 9 deletions molecule/custom_env/molecule.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,18 +10,15 @@ provisioner:
verify: verify.yml
dependency:
name: galaxy
lint: |
yamllint .
ansible-lint .
driver:
name: docker
platforms:
- name: "${os:-ubuntu20}-${tag:-latest}"
image: "${namespace:-monolithprojects}/systemd-${os:-ubuntu20}:${tag:-latest}"
command: /sbin/init
- name: "${MOLECULE_IMAGE:-ubuntu22}-latest"
image: "${namespace:-monolithprojects}/systemd-${MOLECULE_IMAGE:-ubuntu22}:latest"
volumes:
- "/sys/fs/cgroup:/sys/fs/cgroup:${MOLECULE_DOCKER_VOLUMES:-ro}" # Use "ro" for cgroup v1 and "rw" for cgroup v2
cgroupns_mode: ${MOLECULE_DOCKER_CGROUPS_MODE:-"private"} # Use "private" for cgroup v1 and "host" for cgroup v2
- "/sys/fs/cgroup:/sys/fs/cgroup:${MOLECULE_DOCKER_VOLUMES:-rw}" # Use "ro" for cgroup v1 and "rw" for cgroup v2
cgroupns_mode: ${MOLECULE_DOCKER_CGROUPS_MODE:-"host"} # Use "private" for cgroup v1 and "host" for cgroup v2
command: ${MOLECULE_DOCKER_COMMAND:-""}
privileged: true
pre_build_image: true
verifier:
Expand All @@ -30,12 +27,13 @@ scenario:
name: custom_env
test_sequence:
- dependency
- lint
- destroy
- syntax
- create
- prepare
- converge
- idempotence
- side_effect
- verify
- cleanup
- destroy
16 changes: 7 additions & 9 deletions molecule/default/molecule.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,18 +10,15 @@ provisioner:
verify: verify.yml
dependency:
name: galaxy
lint: |
yamllint .
ansible-lint .
driver:
name: docker
platforms:
- name: "${os:-ubuntu20}-${tag:-latest}"
image: "${namespace:-monolithprojects}/systemd-${os:-ubuntu20}:${tag:-latest}"
command: /sbin/init
- name: "${MOLECULE_IMAGE:-ubuntu22}-latest"
image: "${namespace:-monolithprojects}/systemd-${MOLECULE_IMAGE:-ubuntu22}:latest"
volumes:
- "/sys/fs/cgroup:/sys/fs/cgroup:${MOLECULE_DOCKER_VOLUMES:-ro}" # Use "ro" for cgroup v1 and "rw" for cgroup v2
cgroups_mode: ${MOLECULE_DOCKER_CGROUPS_MODE:-"private"} # Use "private" for cgroup v1 and "host" for cgroup v2
- "/sys/fs/cgroup:/sys/fs/cgroup:${MOLECULE_DOCKER_VOLUMES:-rw}" # Use "ro" for cgroup v1 and "rw" for cgroup v2
cgroupns_mode: ${MOLECULE_DOCKER_CGROUPS_MODE:-"host"} # Use "private" for cgroup v1 and "host" for cgroup v2
command: ${MOLECULE_DOCKER_COMMAND:-""}
privileged: true
pre_build_image: true
verifier:
Expand All @@ -30,12 +27,13 @@ scenario:
name: default
test_sequence:
- dependency
- lint
- destroy
- syntax
- create
- prepare
- converge
- idempotence
- side_effect
- verify
- cleanup
- destroy
2 changes: 1 addition & 1 deletion molecule/org/converge.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
- github_account: monolithprojects-testorg
- runner_org: yes
- runner_state: "stopped"
- runner_version: "2.287.0"
- runner_version: "2.303.0"
roles:
- robertdebock.epel
- ansible-github_actions_runner
15 changes: 8 additions & 7 deletions molecule/org/molecule.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,12 @@ lint: |
driver:
name: docker
platforms:
- name: "${os:-ubuntu20}-${tag:-latest}"
image: "${namespace:-monolithprojects}/systemd-${os:-ubuntu20}:${tag:-latest}"
command: /sbin/init
- name: "${MOLECULE_IMAGE:-ubuntu22}-latest"
image: "${namespace:-monolithprojects}/systemd-${MOLECULE_IMAGE:-ubuntu22}:latest"
volumes:
- "/sys/fs/cgroup:/sys/fs/cgroup:${MOLECULE_DOCKER_VOLUMES:-ro}" # Use "ro" for cgroup v1 and "rw" for cgroup v2
cgroupns_mode: ${MOLECULE_DOCKER_CGROUPS_MODE:-"private"} # Use "private" for cgroup v1 and "host" for cgroup v2
- "/sys/fs/cgroup:/sys/fs/cgroup:${MOLECULE_DOCKER_VOLUMES:-rw}" # Use "ro" for cgroup v1 and "rw" for cgroup v2
cgroupns_mode: ${MOLECULE_DOCKER_CGROUPS_MODE:-"host"} # Use "private" for cgroup v1 and "host" for cgroup v2
command: ${MOLECULE_DOCKER_COMMAND:-""}
privileged: true
pre_build_image: true
verifier:
Expand All @@ -27,12 +27,13 @@ scenario:
name: org
test_sequence:
- dependency
- lint
- destroy
- syntax
- create
- prepare
- converge
- idempotence
# - idempotence
- side_effect
- verify
- cleanup
- destroy
7 changes: 0 additions & 7 deletions molecule/org/verify.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,4 @@
assert:
that:
- runner_name in registered_runners.json.runners|map(attribute='name')|list
- registered_runners.json.runners|map(attribute='status') == ["offline"]
quiet: true

- debug:
var: registered_runners.json.runners|map(attribute='name')

- debug:
var: registered_runners.json.runners|map(attribute='status')
Loading

0 comments on commit dc13c70

Please sign in to comment.