Skip to content

Commit 30f38e1

Browse files
authored
PR validation workflows and ansible-builder support (#139)
* Add PR validation workflows * Add support for ansible-builder * Increment collection to 1.7.3 Signed-off-by: Webster Mudge <[email protected]>
1 parent e9539db commit 30f38e1

File tree

7 files changed

+225
-7
lines changed

7 files changed

+225
-7
lines changed

.github/workflows/label_pr.yml

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
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+
# See https://securitylab.github.com/research/github-actions-preventing-pwn-requests/
17+
18+
name: Label validated Pull Request
19+
20+
on:
21+
workflow_run:
22+
workflows: ["Validate Pull Request"]
23+
types:
24+
- completed
25+
26+
jobs:
27+
label:
28+
permissions:
29+
contents: read
30+
pull-requests: write
31+
runs-on: ubuntu-latest
32+
if: >
33+
github.event.workflow_run.event == 'pull_request' &&
34+
github.event.workflow_run.conclusion == 'success'
35+
steps:
36+
- name: Download the PR number artifact
37+
uses: actions/github-script@v6
38+
with:
39+
script: |
40+
let allArtifacts = await github.rest.actions.listWorkflowRunArtifacts({
41+
owner: context.repo.owner,
42+
repo: context.repo.repo,
43+
run_id: context.payload.workflow_run.id,
44+
});
45+
let matchArtifact = allArtifacts.data.artifacts.filter((artifact) => {
46+
return artifact.name == "pr_number"
47+
})[0];
48+
let download = await github.rest.actions.downloadArtifact({
49+
owner: context.repo.owner,
50+
repo: context.repo.repo,
51+
artifact_id: matchArtifact.id,
52+
archive_format: 'zip',
53+
});
54+
let fs = require('fs');
55+
fs.writeFileSync(`${process.env.GITHUB_WORKSPACE}/pr_number.zip`, Buffer.from(download.data));
56+
57+
- name: 'Unzip artifact'
58+
run: unzip pr_number.zip
59+
60+
- name: Read the PR number
61+
id: read
62+
run: echo "pr_number=$(cat pr_number)" >> $GITHUB_OUTPUT
63+
64+
- name: Label the PR
65+
uses: actions-ecosystem/action-add-labels@v1
66+
with:
67+
labels: validated
68+
number: ${{ steps.read.outputs.pr_number }}

.github/workflows/reset_pr.yml

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
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: Reset Pull Request validation label
17+
18+
on:
19+
pull_request_target:
20+
types:
21+
- reopened
22+
- synchronize
23+
- ready_for_review
24+
branches:
25+
- 'release/**'
26+
- 'devel'
27+
- 'devel-pvc-base'
28+
29+
jobs:
30+
reset:
31+
permissions:
32+
contents: read
33+
pull-requests: write
34+
runs-on: ubuntu-latest
35+
steps:
36+
- name: Reset the PR label
37+
uses: actions-ecosystem/action-remove-labels@v1
38+
with:
39+
labels: validated

.github/workflows/validate_pr.yml

Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
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/

bindep.txt

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# Copyright 2023 Cloudera, Inc. All Rights Reserved.
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.

builder/requirements.yml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
---
2+
3+
# Copyright 2023 Cloudera, Inc. All Rights Reserved.
4+
#
5+
# Licensed under the Apache License, Version 2.0 (the "License");
6+
# you may not use this file except in compliance with the License.
7+
# You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing, software
12+
# distributed under the License is distributed on an "AS IS" BASIS,
13+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
# See the License for the specific language governing permissions and
15+
# limitations under the License.
16+
17+
collections:
18+
- source: .
19+
type: dir

galaxy.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
22

3-
# Copyright 2022 Cloudera, Inc. All Rights Reserved.
3+
# Copyright 2023 Cloudera, Inc. All Rights Reserved.
44
#
55
# Licensed under the Apache License, Version 2.0 (the "License");
66
# you may not use this file except in compliance with the License.
@@ -16,7 +16,7 @@
1616

1717
namespace: cloudera
1818
name: exe
19-
version: 1.7.2
19+
version: 1.7.3
2020
readme: README.md
2121
authors:
2222
- Webster Mudge <[email protected]>

requirements.txt

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Copyright 2022 Cloudera, Inc. All Rights Reserved.
1+
# Copyright 2023 Cloudera, Inc. All Rights Reserved.
22
#
33
# Licensed under the Apache License, Version 2.0 (the "License");
44
# you may not use this file except in compliance with the License.
@@ -22,8 +22,4 @@ cryptography>=2.3.1
2222

2323
# Ansible
2424
jmespath # community.general.json_query
25-
netaddr # ansible.netcommon.ipaddr
2625
molecule[lint]==3.4 # Pinned due to https://github.com/ansible-community/molecule/issues/3243
27-
28-
# CDPCLI / cdpy
29-
git+https://github.com/cloudera-labs/cdpy@main#egg=cdpy

0 commit comments

Comments
 (0)