-
Notifications
You must be signed in to change notification settings - Fork 50
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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 <[email protected]>
- Loading branch information
Showing
7 changed files
with
256 additions
and
44 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
--- | ||
# Copyright 2023 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. | ||
|
||
# See https://securitylab.github.com/research/github-actions-preventing-pwn-requests/ | ||
|
||
name: Label validated Pull Request | ||
|
||
on: | ||
workflow_run: | ||
workflows: ["Validate Pull Request"] | ||
types: | ||
- completed | ||
|
||
jobs: | ||
label: | ||
permissions: | ||
contents: read | ||
pull-requests: write | ||
runs-on: ubuntu-latest | ||
if: > | ||
github.event.workflow_run.event == 'pull_request' && | ||
github.event.workflow_run.conclusion == 'success' | ||
steps: | ||
- name: Download the PR number artifact | ||
uses: actions/github-script@v6 | ||
with: | ||
script: | | ||
let allArtifacts = await github.rest.actions.listWorkflowRunArtifacts({ | ||
owner: context.repo.owner, | ||
repo: context.repo.repo, | ||
run_id: context.payload.workflow_run.id, | ||
}); | ||
let matchArtifact = allArtifacts.data.artifacts.filter((artifact) => { | ||
return artifact.name == "pr_number" | ||
})[0]; | ||
let download = await github.rest.actions.downloadArtifact({ | ||
owner: context.repo.owner, | ||
repo: context.repo.repo, | ||
artifact_id: matchArtifact.id, | ||
archive_format: 'zip', | ||
}); | ||
let fs = require('fs'); | ||
fs.writeFileSync(`${process.env.GITHUB_WORKSPACE}/pr_number.zip`, Buffer.from(download.data)); | ||
- name: 'Unzip artifact' | ||
run: unzip pr_number.zip | ||
|
||
- name: Read the PR number | ||
id: read | ||
run: echo "pr_number=$(cat pr_number)" >> $GITHUB_OUTPUT | ||
|
||
- name: Label the PR | ||
uses: actions-ecosystem/action-add-labels@v1 | ||
with: | ||
labels: validated | ||
number: ${{ steps.read.outputs.pr_number }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
--- | ||
# Copyright 2023 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: Reset Pull Request validation label | ||
|
||
on: | ||
pull_request_target: | ||
types: | ||
- reopened | ||
- synchronize | ||
- ready_for_review | ||
branches: | ||
- 'release/**' | ||
- 'devel' | ||
- 'devel-pvc-base' | ||
|
||
jobs: | ||
reset: | ||
permissions: | ||
contents: read | ||
pull-requests: write | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Reset the PR label | ||
uses: actions-ecosystem/action-remove-labels@v1 | ||
with: | ||
labels: validated |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
--- | ||
# Copyright 2023 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' | ||
- 'devel-pvc-base' | ||
|
||
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 collections | ||
run: | | ||
sudo update-alternatives --install /usr/bin/python python $(which python3) 1 | ||
pip install ansible-core==2.12 ansible-builder pycodestyle voluptuous pylint pyyaml ansible-lint | ||
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 | ||
pip install -r final_python.txt | ||
sudo apt-get -y install $(cat final_bindep.txt) | ||
- 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/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
# Copyright 2023 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. | ||
|
||
# ansible.posix.patch | ||
patch [platform:rpm] | ||
|
||
# community.general.ipa_user | ||
hashlib [platform:rpm] | ||
base64 [platform:rpm] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
--- | ||
# Copyright 2023 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. | ||
|
||
collections: | ||
- source: . | ||
type: dir | ||
|
||
roles: | ||
- name: geerlingguy.postgresql | ||
version: 2.2.0 | ||
|
||
# geerlingguy.mysql with fix for issue #332 | ||
- src: https://github.com/dbeech/ansible-role-mysql | ||
version: master |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
# Copyright 2023 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. | ||
|
||
# For community.general.json_query filter | ||
jmespath |