Skip to content

Commit adb9900

Browse files
committed
Refactoring GH-actions with workflows. (#415)
making a more readable test workflow avoiding tests in double during merges Also using reusable workflows to further reduce code duplication Signed-off-by: Marc Crébassa <[email protected]>
1 parent 0eb9f2e commit adb9900

File tree

13 files changed

+282
-307
lines changed

13 files changed

+282
-307
lines changed

.github/workflows/ansible-tests.yml

Lines changed: 0 additions & 59 deletions
This file was deleted.
Lines changed: 122 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,122 @@
1+
---
2+
name: collection-tests
3+
"on":
4+
workflow_call:
5+
inputs:
6+
distros:
7+
required: false
8+
description: a list of debian based distribution
9+
type: string
10+
default: "['debian12', 'ubuntu2404']"
11+
nc_versions:
12+
required: false
13+
description: a list of nextcloud server version
14+
type: string
15+
default: "['latest']"
16+
env:
17+
PYTHON_VERSION: '3.12'
18+
jobs:
19+
lint:
20+
name: linters
21+
runs-on: ubuntu-latest
22+
steps:
23+
- uses: actions/checkout@v4
24+
with:
25+
fetch-depth: 0
26+
- name: Run ansible-lint
27+
uses: ansible/ansible-lint@v25
28+
29+
- name: Set up Python 3.
30+
uses: actions/setup-python@v5
31+
with:
32+
python-version: ${{ env.PYTHON_VERSION }}
33+
34+
- name: Upgrade pip
35+
run: |
36+
pip install --constraint=.github/workflows/constraints.txt pip
37+
pip --version
38+
39+
- name: Upgrade yamllint
40+
run: |
41+
pip install --constraint=.github/workflows/constraints.txt yamllint
42+
43+
- name: Lint code.
44+
run: |
45+
yamllint -c .yamllint.yml .
46+
47+
ansible-tests:
48+
name: ansible-tests
49+
needs:
50+
- lint
51+
runs-on: ubuntu-latest
52+
defaults:
53+
run:
54+
working-directory: ./code/ansible_collections/nextcloud/admin/
55+
steps:
56+
- name: Checkout repository
57+
uses: actions/checkout@v4
58+
with:
59+
path: ./code/ansible_collections/nextcloud/admin/
60+
fetch-depth: 0
61+
- name: Set up Python
62+
uses: actions/setup-python@v5
63+
with:
64+
python-version: ${{ env.PYTHON_VERSION }}
65+
66+
- name: Install dependencies
67+
run: |
68+
python -m pip install --constraint=.github/workflows/constraints.txt --upgrade pip
69+
pip install --constraint=.github/workflows/constraints.txt ansible pytest
70+
71+
- name: Run units tests
72+
run: |
73+
ansible-test units --requirements --docker
74+
75+
- name: Run sanity tests
76+
run: |
77+
ansible-test sanity --requirements --docker
78+
79+
molecule_test:
80+
defaults:
81+
run:
82+
working-directory: "nextcloud.ansible-collection-nextcloud-admin"
83+
name: molecule-test
84+
runs-on: ubuntu-latest
85+
strategy:
86+
fail-fast: false
87+
matrix:
88+
distros: ${{ fromJson(inputs.distros)}}
89+
nc_versions: ${{ fromJson(inputs.nc_versions)}}
90+
steps:
91+
- name: Check out the repository
92+
uses: actions/checkout@v4
93+
with:
94+
path: "nextcloud.ansible-collection-nextcloud-admin"
95+
96+
- name: Set up Python
97+
uses: actions/setup-python@v5
98+
with:
99+
python-version: ${{ env.PYTHON_VERSION }}
100+
101+
- name: Upgrade pip
102+
run: |
103+
python3 -m pip install --constraint=.github/workflows/constraints.txt pip
104+
python3 -m pip --version
105+
106+
- name: Install test dependencies
107+
run: |
108+
python3 -m pip install --constraint=.github/workflows/constraints.txt ansible 'molecule-plugins[docker]' docker netaddr PyMySQL
109+
110+
- name: precreate mysql database
111+
run: |
112+
sudo systemctl start mysql.service
113+
ansible localhost -m community.mysql.mysql_db -a "name=nc login_user=root login_password=root state=present"
114+
ansible localhost -m community.mysql.mysql_user -a "name=nc password=nc priv=nc.*:ALL login_user=root login_password=root state=present"
115+
116+
- name: Run Molecule tests
117+
run: molecule test
118+
env:
119+
PY_COLORS: "1"
120+
ANSIBLE_FORCE_COLOR: "1"
121+
MOLECULE_DISTRO: ${{ matrix.distros }}
122+
MOLECULE_NC: ${{ matrix.nc_versions }}

.github/workflows/labeler.yml

Lines changed: 0 additions & 19 deletions
This file was deleted.

.github/workflows/lint.yml

Lines changed: 0 additions & 40 deletions
This file was deleted.

.github/workflows/release-drafter.yml

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,23 @@
11
---
2-
name: Release Drafter
2+
name: Release Draft
33

44
"on":
55
push:
66
branches:
77
- main
88

99
jobs:
10+
labeler:
11+
runs-on: ubuntu-latest
12+
steps:
13+
- name: Check out the repository
14+
uses: actions/checkout@v4
15+
16+
- name: Run Labeler
17+
uses: crazy-max/ghaction-github-labeler@v5
18+
with:
19+
skip-delete: true
20+
1021
draft_release:
1122
runs-on: ubuntu-latest
1223
steps:

.github/workflows/release.yml

Lines changed: 0 additions & 64 deletions
This file was deleted.

.github/workflows/tests.yml

Lines changed: 0 additions & 57 deletions
This file was deleted.

0 commit comments

Comments
 (0)