-
Notifications
You must be signed in to change notification settings - Fork 0
176 lines (145 loc) · 4.68 KB
/
build.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
---
name: Build
on:
pull_request: {}
push:
branches:
- master
jobs:
commitlint:
name: Commit Lint
runs-on: ubuntu-22.04
steps:
- name: Check out the codebase
uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Install Node.js
uses: actions/setup-node@v4
with:
node-version: 21
- name: Install Node modules
run: npm install
- name: Check program versions
run: |
node --version
npm --version
npm run commitlint -- --version
- name: Validate last commit
if: github.event_name == 'push'
run: npm run commitlint -- --from=HEAD~1 --to=HEAD --verbose
- name: Validate commits in pull request
if: github.event_name == 'pull_request'
run: >-
npm run commitlint --
--from=${{ github.event.pull_request.head.sha }}~${{ github.event.pull_request.commits }}
--to=${{ github.event.pull_request.head.sha }}
--verbose
createrole:
name: Create role
needs: commitlint
runs-on: ubuntu-22.04
steps:
- name: Check out the codebase
uses: actions/checkout@v2
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: "3.x"
- name: Install Cookiecutter
run: pip install cookiecutter
- name: Fill in template values
run: |
sudo apt install --yes jq
jq '.namespace |= "acme"' cookiecutter.json > namespace.json
jq '.role_name |= "widgets_service_installer"' namespace.json > widgets_service_installer.json
jq '.description |= "Installs web service"' widgets_service_installer.json > description.json
jq '.author |= "John Doe"' description.json > author.json
jq '.author_website |= "https://www.example.com"' author.json > author_website.json
cat author_website.json
rm cookiecutter.json
mv author_website.json cookiecutter.json
rm namespace.json widgets_service_installer.json description.json author.json
- name: Create role
run: |
cd ..
pwd
ls
cookiecutter cookiecutter-ansible-role --no-input
ls
sudo apt install --yes tree
tree -L 2 widgets_service_installer
cat widgets_service_installer/meta/main.yml
mv widgets_service_installer cookiecutter-ansible-role
- name: Upload role artifact
uses: actions/upload-artifact@v4
with:
name: ansible-role-widgets_service_installer
path: widgets_service_installer
retention-days: 1
yamllint:
name: YAML Lint
needs: createrole
runs-on: ubuntu-22.04
steps:
- name: Download artifact
uses: actions/download-artifact@v4
with:
name: ansible-role-widgets_service_installer
path: ansible-role-widgets_service_installer
- name: Set up Python 3
uses: actions/setup-python@v2
with:
python-version: "3.x"
- name: Install test dependencies
run: |
cd ansible-role-widgets_service_installer
pip3 install --requirement requirements.txt
- name: Lint code
run: |
cd ansible-role-widgets_service_installer
yamllint .
ansiblelint:
name: Ansible Lint
needs: yamllint
runs-on: ubuntu-22.04
steps:
- name: Download artifact
uses: actions/download-artifact@v4
with:
name: ansible-role-widgets_service_installer
path: ansible-role-widgets_service_installer
- name: Set up Python 3
uses: actions/setup-python@v2
with:
python-version: "3.x"
- name: Install test dependencies
run: |
cd ansible-role-widgets_service_installer
pip3 install --requirement requirements.txt
- name: Lint code
run: |
cd ansible-role-widgets_service_installer
ansible-lint .
molecule:
name: Molecule Test
needs: ansiblelint
runs-on: ubuntu-22.04
steps:
- name: Download artifact
uses: actions/download-artifact@v4
with:
name: ansible-role-widgets_service_installer
path: ansible-role-widgets_service_installer
- name: Set up Python 3.
uses: actions/setup-python@v2
with:
python-version: "3.x"
- name: Install test dependencies
run: |
cd ansible-role-widgets_service_installer
pip3 install --requirement requirements.txt
- name: Run Molecule tests
run: |
cd ansible-role-widgets_service_installer
molecule test