Skip to content

Commit 6e3b47d

Browse files
authored
Pull Request workflow and ansible-builder support (#104)
* Add PR validation workflows * Add support to ansible-builder * Increment collection to 3.4.1 and clean up Signed-off-by: Webster Mudge <wmudge@cloudera.com>
1 parent c42a806 commit 6e3b47d

File tree

7 files changed

+256
-44
lines changed

7 files changed

+256
-44
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/cluster
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: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
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.
14+
15+
# ansible.posix.patch
16+
patch [platform:rpm]
17+
18+
# community.general.ipa_user
19+
hashlib [platform:rpm]
20+
base64 [platform:rpm]

builder/requirements.yml

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
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+
collections:
17+
- source: .
18+
type: dir
19+
20+
roles:
21+
- name: geerlingguy.postgresql
22+
version: 2.2.0
23+
24+
# geerlingguy.mysql with fix for issue #332
25+
- src: https://github.com/dbeech/ansible-role-mysql
26+
version: master

galaxy.yml

Lines changed: 4 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Copyright 2022 Cloudera, Inc.
1+
# Copyright 2023 Cloudera, Inc.
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.
@@ -12,49 +12,16 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15-
### REQUIRED
16-
17-
# The namespace of the collection. This can be a company/brand/organization or product namespace under which all
18-
# content lives. May only contain alphanumeric characters and underscores. Additionally namespaces cannot start with
19-
# underscores or numbers and cannot contain consecutive underscores
2015
namespace: cloudera
21-
22-
# The name of the collection. Has the same character restrictions as 'namespace'
2316
name: cluster
17+
version: 3.4.1
2418

25-
# The version of the collection. Must be compatible with semantic versioning
26-
version: 3.4.0
27-
28-
# The path to the Markdown (.md) readme file. This path is relative to the root of the collection
29-
readme: README.md
30-
31-
# A list of the collection's content authors. Can be just the name or in the format 'Full Name <email> (url)
32-
# @nicks:irc/im.site#channel'
3319
authors: []
34-
35-
36-
### OPTIONAL but strongly recommended
37-
38-
# A short summary description of the collection
39-
description: Cloudera assets for managing Cloudera Clusters
40-
41-
# Either a single license or a list of licenses for content inside of a collection. Ansible Galaxy currently only
42-
# accepts L(SPDX,https://spdx.org/licenses/) licenses. This key is mutually exclusive with 'license_file'
43-
#license:
44-
#- GPL-2.0-or-later
45-
46-
# The path to the license file for the collection. This path is relative to the root of the collection. This key is
47-
# mutually exclusive with 'license'
20+
readme: README.md
21+
description: Cloudera assets for managing Cloudera clusters
4822
license_file: 'LICENSE'
49-
50-
# A list of tags you want to associate with the collection for indexing/searching. A tag name has the same character
51-
# requirements as 'namespace' and 'name'
5223
tags: []
5324

54-
# Collections that this collection requires to be installed for it to be usable. The key of the dict is the
55-
# collection label 'namespace.name'. The value is a version range
56-
# L(specifiers,https://python-semanticversion.readthedocs.io/en/latest/#requirement-specification). Multiple version
57-
# range specifiers can be set and are separated by ','
5825
dependencies:
5926
'ansible.posix': '1.3.0'
6027
'community.crypto': '2.2.1'
@@ -63,14 +30,7 @@ dependencies:
6330
'community.postgresql': '1.6.1'
6431
'freeipa.ansible_freeipa': '1.6.2'
6532

66-
# The URL of the originating SCM repository
6733
repository: https://github.com/cloudera-labs/cloudera.cluster
68-
69-
# The URL to any online docs
7034
documentation: https://github.com/cloudera-labs/cloudera.cluster
71-
72-
# The URL to the homepage of the collection/project
7335
homepage: https://github.com/cloudera-labs/cloudera.cluster
74-
75-
# The URL to the collection issue tracker
7636
issues: https://github.com/cloudera-labs/cloudera.cluster/issues

requirements.txt

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
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.
14+
15+
# For community.general.json_query filter
16+
jmespath

0 commit comments

Comments
 (0)