Skip to content

Commit dc13c70

Browse files
Merge pull request #162 from MonolithProjects/feat/macos_support
Feat/macos support
2 parents 6f2b964 + 901cc72 commit dc13c70

14 files changed

+210
-140
lines changed

.github/workflows/lint.yml

+19-15
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,29 @@
11
name: molecule lint
22

33
on:
4-
push:
5-
branches:
6-
- develop
7-
- feature/*
8-
pull_request:
9-
branches:
10-
- develop
11-
types: [opened, synchronize, reopened]
4+
pull_request:
5+
push:
6+
branches:
7+
- master
8+
129
jobs:
1310
lint:
14-
runs-on: ubuntu-18.04
15-
strategy:
16-
fail-fast: true
11+
name: Lint
12+
runs-on: ubuntu-latest
1713
steps:
18-
- name: checkout
14+
- name: Check out the codebase.
1915
uses: actions/checkout@v3
2016
with:
2117
path: "${{ github.repository }}"
22-
- name: Molecule for Ansible - lint
23-
uses: MonolithProjects/[email protected]
18+
19+
- name: Set up Python 3.
20+
uses: actions/setup-python@v4
2421
with:
25-
molecule_command: lint
22+
python-version: '3.x'
23+
24+
- name: Install test dependencies.
25+
run: pip3 install ansible-lint yamllint
26+
27+
- name: Lint code.
28+
run: |
29+
ansible-lint --exclude molecule/ --exclude .github/

.github/workflows/tests.yml

+59-29
Original file line numberDiff line numberDiff line change
@@ -2,72 +2,102 @@ name: molecule test
22

33
on:
44
pull_request:
5-
types:
6-
- opened
7-
- reopened
8-
- synchronize
95
branches:
10-
- 'master'
6+
- master
7+
types: [opened, synchronize, reopened]
8+
paths:
9+
- 'defaults/**'
10+
- 'handlers/**'
11+
- 'molecule/**'
12+
- 'tasks/**'
13+
- 'templates/**'
14+
- 'vars/**'
1115
schedule:
12-
- cron: '0 6 * * 0'
16+
- cron: '0 6 * * 0'
1317
workflow_dispatch:
1418

1519
env:
16-
MOLECULE_DOCKER_VOLUMES: ro
17-
MOLECULE_DOCKER_CGROUPS_MODE: private
20+
MOLECULE_DOCKER_VOLUMES: rw
21+
MOLECULE_DOCKER_CGROUPS_MODE: host
1822

1923
jobs:
2024
repo:
21-
name: Test Repo Runner
25+
name: Test GHA Runner Role
2226
environment:
2327
name: test
24-
runs-on: ubuntu-20.04
28+
runs-on: ubuntu-22.04
2529
strategy:
2630
fail-fast: false
27-
max-parallel: 3
31+
max-parallel: 5
2832
matrix:
2933
config:
3034
- os: "debian11"
31-
tag: "latest"
3235
- os: "fedora37"
33-
tag: "latest"
3436
- os: "ubuntu20"
35-
tag: "latest"
3637
- os: "ubuntu22"
37-
tag: "latest"
3838
- os: "rockylinux8"
39-
tag: "latest"
4039
steps:
4140
- name: checkout
4241
uses: actions/checkout@v3
4342
with:
4443
path: "${{ github.repository }}"
45-
- name: Molecule for Ansible - GHR Repository
46-
uses: MonolithProjects/[email protected]
44+
45+
- name: Set up Python 3
46+
uses: actions/setup-python@v4
47+
with:
48+
python-version: '3.x'
49+
50+
- name: Install test dependencies
51+
run: pip3 install ansible docker molecule molecule-plugins[docker] "requests<2.29.2" jmespath
52+
53+
- name: Run Molecule test - repo
54+
run: molecule test --scenario-name repo
55+
working-directory: "${{ github.repository }}"
4756
env:
57+
PY_COLORS: '1'
58+
ANSIBLE_FORCE_COLOR: '1'
59+
MOLECULE_IMAGE: ${{ matrix.config.os }}
60+
MOLECULE_DOCKER_CGROUPS_MODE: ${{ matrix.config.cgroup_mode }}
61+
MOLECULE_DOCKER_VOLUMES: ${{ matrix.config.volumes }}
4862
PERSONAL_ACCESS_TOKEN: ${{ secrets.PERSONAL_ACCESS_TOKEN }}
49-
with:
50-
os: ${{ matrix.config.os }}
51-
tag: ${{ matrix.config.tag }}
52-
molecule_command: test
53-
scenario: repo
5463

5564
org:
5665
name: Test Org Runner
66+
needs: repo
5767
environment:
5868
name: test
59-
runs-on: ubuntu-20.04
69+
runs-on: ubuntu-22.04
6070
strategy:
6171
fail-fast: false
72+
max-parallel: 5
73+
matrix:
74+
config:
75+
- os: "debian11"
76+
- os: "fedora37"
77+
- os: "ubuntu20"
78+
- os: "ubuntu22"
79+
- os: "rockylinux8"
6280
steps:
6381
- name: checkout
6482
uses: actions/checkout@v3
6583
with:
6684
path: "${{ github.repository }}"
67-
- name: Molecule for Ansible - GHR Organization
68-
uses: MonolithProjects/[email protected]
85+
86+
- name: Set up Python 3
87+
uses: actions/setup-python@v4
88+
with:
89+
python-version: '3.x'
90+
91+
- name: Install test dependencies
92+
run: pip3 install ansible docker molecule molecule-plugins[docker] "requests<2.29.2" jmespath
93+
94+
- name: Run Molecule tests -
95+
run: molecule test --scenario-name org
96+
working-directory: "${{ github.repository }}"
6997
env:
98+
PY_COLORS: '1'
99+
ANSIBLE_FORCE_COLOR: '1'
100+
MOLECULE_IMAGE: ${{ matrix.config.os }}
101+
MOLECULE_DOCKER_CGROUPS_MODE: ${{ matrix.config.cgroup_mode }}
102+
MOLECULE_DOCKER_VOLUMES: ${{ matrix.config.volumes }}
70103
PERSONAL_ACCESS_TOKEN: ${{ secrets.PERSONAL_ACCESS_TOKEN }}
71-
with:
72-
molecule_command: test
73-
scenario: org

README.md

+14-7
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,14 @@
88
[![License](https://img.shields.io/github/license/MonolithProjects/ansible-github_actions_runner)](https://github.com/MonolithProjects/ansible-github_actions_runner/blob/main/LICENSE)
99

1010

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

1414
## Requirements
1515

16-
* System must have access to the GitHub.
16+
* System must have access to the GitHub API.
1717

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

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

34-
## Supported CPU architecture:
33+
## Supported CPU architecture
3534

3635
* ARM, ARM64 (dependencies installation is not covered by this role)
3736
* AMD64, x86_64
37+
38+
## Supported Operating Systems
39+
40+
* Red Hat Enterprise Linux 7
41+
* CentOS 7
42+
* Rocky Linux 8+
43+
* Fedora 29+
44+
* Debian 9+
45+
* Ubuntu 16.04+
46+
* macOS High Sierra +
3847
## Weekly tested on:
3948

4049
* Debian 11
4150
* Fedora 37
4251
* Rocky Linux 8
4352
* Ubuntu 20,22
4453

45-
**Note:** Fedora 32+ and Ubuntu 20 must use Ansible 2.9.8+. Other distros/releases will work also with older 2.8.0+ Ansible.
46-
4754
## Role Variables
4855

4956
This is a copy from `defaults/main.yml`

defaults/main.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
22
# Runner user - user under which is the local runner service running
3-
runner_user: "{{ lookup('env','USER') }}"
3+
runner_user: "{{ lookup('env', 'USER') }}"
44

55
# Directory where the local runner will be installed
66
runner_dir: /opt/actions-runner

molecule/custom_env/molecule.yml

+7-9
Original file line numberDiff line numberDiff line change
@@ -10,18 +10,15 @@ provisioner:
1010
verify: verify.yml
1111
dependency:
1212
name: galaxy
13-
lint: |
14-
yamllint .
15-
ansible-lint .
1613
driver:
1714
name: docker
1815
platforms:
19-
- name: "${os:-ubuntu20}-${tag:-latest}"
20-
image: "${namespace:-monolithprojects}/systemd-${os:-ubuntu20}:${tag:-latest}"
21-
command: /sbin/init
16+
- name: "${MOLECULE_IMAGE:-ubuntu22}-latest"
17+
image: "${namespace:-monolithprojects}/systemd-${MOLECULE_IMAGE:-ubuntu22}:latest"
2218
volumes:
23-
- "/sys/fs/cgroup:/sys/fs/cgroup:${MOLECULE_DOCKER_VOLUMES:-ro}" # Use "ro" for cgroup v1 and "rw" for cgroup v2
24-
cgroupns_mode: ${MOLECULE_DOCKER_CGROUPS_MODE:-"private"} # Use "private" for cgroup v1 and "host" for cgroup v2
19+
- "/sys/fs/cgroup:/sys/fs/cgroup:${MOLECULE_DOCKER_VOLUMES:-rw}" # Use "ro" for cgroup v1 and "rw" for cgroup v2
20+
cgroupns_mode: ${MOLECULE_DOCKER_CGROUPS_MODE:-"host"} # Use "private" for cgroup v1 and "host" for cgroup v2
21+
command: ${MOLECULE_DOCKER_COMMAND:-""}
2522
privileged: true
2623
pre_build_image: true
2724
verifier:
@@ -30,12 +27,13 @@ scenario:
3027
name: custom_env
3128
test_sequence:
3229
- dependency
33-
- lint
3430
- destroy
3531
- syntax
3632
- create
33+
- prepare
3734
- converge
3835
- idempotence
36+
- side_effect
3937
- verify
4038
- cleanup
4139
- destroy

molecule/default/molecule.yml

+7-9
Original file line numberDiff line numberDiff line change
@@ -10,18 +10,15 @@ provisioner:
1010
verify: verify.yml
1111
dependency:
1212
name: galaxy
13-
lint: |
14-
yamllint .
15-
ansible-lint .
1613
driver:
1714
name: docker
1815
platforms:
19-
- name: "${os:-ubuntu20}-${tag:-latest}"
20-
image: "${namespace:-monolithprojects}/systemd-${os:-ubuntu20}:${tag:-latest}"
21-
command: /sbin/init
16+
- name: "${MOLECULE_IMAGE:-ubuntu22}-latest"
17+
image: "${namespace:-monolithprojects}/systemd-${MOLECULE_IMAGE:-ubuntu22}:latest"
2218
volumes:
23-
- "/sys/fs/cgroup:/sys/fs/cgroup:${MOLECULE_DOCKER_VOLUMES:-ro}" # Use "ro" for cgroup v1 and "rw" for cgroup v2
24-
cgroups_mode: ${MOLECULE_DOCKER_CGROUPS_MODE:-"private"} # Use "private" for cgroup v1 and "host" for cgroup v2
19+
- "/sys/fs/cgroup:/sys/fs/cgroup:${MOLECULE_DOCKER_VOLUMES:-rw}" # Use "ro" for cgroup v1 and "rw" for cgroup v2
20+
cgroupns_mode: ${MOLECULE_DOCKER_CGROUPS_MODE:-"host"} # Use "private" for cgroup v1 and "host" for cgroup v2
21+
command: ${MOLECULE_DOCKER_COMMAND:-""}
2522
privileged: true
2623
pre_build_image: true
2724
verifier:
@@ -30,12 +27,13 @@ scenario:
3027
name: default
3128
test_sequence:
3229
- dependency
33-
- lint
3430
- destroy
3531
- syntax
3632
- create
33+
- prepare
3734
- converge
3835
- idempotence
36+
- side_effect
3937
- verify
4038
- cleanup
4139
- destroy

molecule/org/converge.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
- github_account: monolithprojects-testorg
99
- runner_org: yes
1010
- runner_state: "stopped"
11-
- runner_version: "2.287.0"
11+
- runner_version: "2.303.0"
1212
roles:
1313
- robertdebock.epel
1414
- ansible-github_actions_runner

molecule/org/molecule.yml

+8-7
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,12 @@ lint: |
1313
driver:
1414
name: docker
1515
platforms:
16-
- name: "${os:-ubuntu20}-${tag:-latest}"
17-
image: "${namespace:-monolithprojects}/systemd-${os:-ubuntu20}:${tag:-latest}"
18-
command: /sbin/init
16+
- name: "${MOLECULE_IMAGE:-ubuntu22}-latest"
17+
image: "${namespace:-monolithprojects}/systemd-${MOLECULE_IMAGE:-ubuntu22}:latest"
1918
volumes:
20-
- "/sys/fs/cgroup:/sys/fs/cgroup:${MOLECULE_DOCKER_VOLUMES:-ro}" # Use "ro" for cgroup v1 and "rw" for cgroup v2
21-
cgroupns_mode: ${MOLECULE_DOCKER_CGROUPS_MODE:-"private"} # Use "private" for cgroup v1 and "host" for cgroup v2
19+
- "/sys/fs/cgroup:/sys/fs/cgroup:${MOLECULE_DOCKER_VOLUMES:-rw}" # Use "ro" for cgroup v1 and "rw" for cgroup v2
20+
cgroupns_mode: ${MOLECULE_DOCKER_CGROUPS_MODE:-"host"} # Use "private" for cgroup v1 and "host" for cgroup v2
21+
command: ${MOLECULE_DOCKER_COMMAND:-""}
2222
privileged: true
2323
pre_build_image: true
2424
verifier:
@@ -27,12 +27,13 @@ scenario:
2727
name: org
2828
test_sequence:
2929
- dependency
30-
- lint
3130
- destroy
3231
- syntax
3332
- create
33+
- prepare
3434
- converge
35-
- idempotence
35+
# - idempotence
36+
- side_effect
3637
- verify
3738
- cleanup
3839
- destroy

molecule/org/verify.yml

-7
Original file line numberDiff line numberDiff line change
@@ -32,11 +32,4 @@
3232
assert:
3333
that:
3434
- runner_name in registered_runners.json.runners|map(attribute='name')|list
35-
- registered_runners.json.runners|map(attribute='status') == ["offline"]
3635
quiet: true
37-
38-
- debug:
39-
var: registered_runners.json.runners|map(attribute='name')
40-
41-
- debug:
42-
var: registered_runners.json.runners|map(attribute='status')

0 commit comments

Comments
 (0)