|
| 1 | +--- |
| 2 | +# Copyright 2023 Cloudera, Inc. All Rights Reserved. |
| 3 | +# |
| 4 | +# Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | +# you may not use this file except in compliance with the License. |
| 6 | +# You may obtain a copy of the License at |
| 7 | +# |
| 8 | +# http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | +# |
| 10 | +# Unless required by applicable law or agreed to in writing, software |
| 11 | +# distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | +# See the License for the specific language governing permissions and |
| 14 | +# limitations under the License. |
| 15 | + |
| 16 | +name: Validate Pull Request |
| 17 | + |
| 18 | +on: |
| 19 | + pull_request: |
| 20 | + branches: |
| 21 | + - 'release/**' |
| 22 | + - 'devel' |
| 23 | + - 'devel-pvc-base' |
| 24 | + |
| 25 | +jobs: |
| 26 | + validate: |
| 27 | + runs-on: ubuntu-latest |
| 28 | + steps: |
| 29 | + - name: Checkout repository |
| 30 | + uses: actions/checkout@v3 |
| 31 | + |
| 32 | + - name: Setup Python and caching |
| 33 | + uses: actions/setup-python@v4 |
| 34 | + with: |
| 35 | + python-version: '3.9' |
| 36 | + cache: 'pip' |
| 37 | + |
| 38 | + - name: Set up Ansible collections |
| 39 | + run: | |
| 40 | + sudo update-alternatives --install /usr/bin/python python $(which python3) 1 |
| 41 | + pip install ansible-core==2.12 ansible-builder pycodestyle voluptuous pylint pyyaml ansible-lint |
| 42 | + ansible-galaxy collection install -r builder/requirements.yml -p /usr/share/ansible/collections |
| 43 | + ansible-galaxy role install -r builder/requirements.yml -p /usr/share/ansible/roles |
| 44 | +
|
| 45 | + - name: Report Ansible version, collections, and roles |
| 46 | + run: | |
| 47 | + ansible --version |
| 48 | + ansible-galaxy collection list |
| 49 | + ansible-galaxy role list |
| 50 | + |
| 51 | + - name: Set up Ansible collection dependencies |
| 52 | + run: | |
| 53 | + ansible-builder introspect \ |
| 54 | + --write-pip final_python.txt --write-bindep final_bindep.txt \ |
| 55 | + /usr/share/ansible/collections |
| 56 | + pip install -r final_python.txt |
| 57 | + sudo apt-get -y install $(cat final_bindep.txt) |
| 58 | + |
| 59 | + - name: Report installed Python dependencies |
| 60 | + run: pip freeze |
| 61 | + |
| 62 | + - name: Validate collection |
| 63 | + run: | |
| 64 | + pushd /usr/share/ansible/collections/ansible_collections/cloudera/exe |
| 65 | + #ansible-lint |
| 66 | + #ansible-test sanity --test pep8 |
| 67 | + #ansible-test sanity --test validate-modules |
| 68 | + #ansible-test units --requirements --color yes --redact |
| 69 | + popd |
| 70 | +
|
| 71 | + # See https://securitylab.github.com/research/github-actions-preventing-pwn-requests/ |
| 72 | + - name: Save PR number |
| 73 | + env: |
| 74 | + PR_NUMBER: ${{ github.event.number }} |
| 75 | + run: | |
| 76 | + mkdir -p ./pr |
| 77 | + echo $PR_NUMBER > ./pr/pr_number |
| 78 | + |
| 79 | + - name: Upload the PR number |
| 80 | + uses: actions/upload-artifact@v3 |
| 81 | + with: |
| 82 | + name: pr_number |
| 83 | + path: pr/ |
0 commit comments