-
Notifications
You must be signed in to change notification settings - Fork 50
90 lines (77 loc) · 3.14 KB
/
validate_pr.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
---
# Copyright 2024 Cloudera, Inc. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
name: Validate Pull Request
on:
pull_request:
branches:
- 'release/**'
- 'devel'
jobs:
validate:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Setup Python and caching
uses: actions/setup-python@v4
with:
python-version: '3.9'
cache: 'pip'
- name: Set up Ansible and Ansible collections and roles
run: |
sudo update-alternatives --install /usr/bin/python python $(which python3) 1
pip install --upgrade pip
pip install ansible-core~=2.12.0 ansible-builder bindep pycodestyle voluptuous pylint pyyaml ansible-lint
mkdir -p /usr/share/ansible/collections /usr/share/ansible/roles
ansible-galaxy collection install -r builder/requirements.yml -p /usr/share/ansible/collections
ansible-galaxy role install -r builder/requirements.yml -p /usr/share/ansible/roles
- name: Report Ansible version, collections, and roles
run: |
ansible --version
ansible-galaxy collection list
ansible-galaxy role list
- name: Set up Ansible collection dependencies
run: |
ansible-builder introspect --write-pip final_python.txt --write-bindep final_bindep.txt /usr/share/ansible/collections
[[ -f final_python.txt ]] && pip install -r final_python.txt || echo "No Python dependencies found."
[[ -f final_bindep.txt ]] && bindep --file final_bindep.txt || echo "No system dependencies found."
- name: Report installed Python dependencies
run: pip freeze
- name: Validate collection
run: |
pushd /usr/share/ansible/collections/ansible_collections/cloudera/cluster
#ansible-lint
#ansible-test sanity --test pep8
#ansible-test sanity --test validate-modules
#ansible-test units --requirements --color yes --redact
popd
# See https://securitylab.github.com/research/github-actions-preventing-pwn-requests/
- name: Save PR number
env:
PR_NUMBER: ${{ github.event.number }}
run: |
mkdir -p ./pr
echo $PR_NUMBER > ./pr/pr_number
- name: Upload the PR number
uses: actions/upload-artifact@v3
with:
name: pr_number
path: pr/
import-galaxy:
needs: validate
permissions:
contents: read
name: Import collection with Galaxy importer
uses: ansible-community/github-action-test-galaxy-import/.github/workflows/test-galaxy-import.yml@main