mirror of
https://github.com/prometheus-community/ansible
synced 2024-11-26 05:40:18 +00:00
Merge pull request #112 from gardar/ci/role-labels
skip_changelog: unify automatic and manual ansible role tests with labels
This commit is contained in:
commit
41f8926fe0
2 changed files with 46 additions and 15 deletions
23
.github/workflows/ansible-ci.yml
vendored
23
.github/workflows/ansible-ci.yml
vendored
|
@ -10,6 +10,10 @@ on:
|
|||
- labeled
|
||||
workflow_dispatch:
|
||||
|
||||
concurrency:
|
||||
group: ansible-${{ github.event.pull_request.number || github.ref }}
|
||||
cancel-in-progress: true
|
||||
|
||||
env:
|
||||
ANSIBLE_FORCE_COLOR: true
|
||||
ANSIBLE_GALAXY_SERVER_GALAXY_URL: "https://galaxy.ansible.com"
|
||||
|
@ -50,7 +54,8 @@ jobs:
|
|||
|
||||
discover-ansible-tests:
|
||||
runs-on: ubuntu-latest
|
||||
needs: ansible-lint
|
||||
needs:
|
||||
- ansible-lint
|
||||
outputs:
|
||||
molecule-tests: ${{ steps.set-molecule-tests.outputs.tests }}
|
||||
integration-tests: ${{ steps.set-integration-tests.outputs.tests }}
|
||||
|
@ -59,22 +64,12 @@ jobs:
|
|||
with:
|
||||
fetch-depth: 0
|
||||
|
||||
- name: Get changed roles
|
||||
id: changed-roles
|
||||
uses: tj-actions/changed-files@v35
|
||||
with:
|
||||
path: "roles"
|
||||
diff_relative: "true"
|
||||
files: "**"
|
||||
dir_names: "true"
|
||||
dir_names_max_depth: "1"
|
||||
since_last_remote_commit: "true"
|
||||
|
||||
- name: Discover role tests
|
||||
id: set-molecule-tests
|
||||
env:
|
||||
LABELS: ${{ toJson(github.event.pull_request.labels.*.name) }}
|
||||
run: |
|
||||
roles=${{ steps.changed-roles.outputs.all_changed_and_modified_files }}
|
||||
roles+=${{ github.event.label.name }}
|
||||
roles=$(echo $LABELS | jq -r '.[]')
|
||||
echo tests="[`for role in $roles; do
|
||||
for test in $(find tests/integration/targets -maxdepth 1 -mindepth 1 -type d -iname "molecule-${role}-*" -printf "%f\n"); do
|
||||
echo '{"test":\"'"${test}"'\","name":\"'"${test#*-}\"'"}';
|
||||
|
|
38
.github/workflows/conventional-label.yml
vendored
38
.github/workflows/conventional-label.yml
vendored
|
@ -6,8 +6,12 @@ permissions:
|
|||
pull-requests: write
|
||||
name: Auto label pull request
|
||||
jobs:
|
||||
label:
|
||||
pr-label:
|
||||
runs-on: ubuntu-latest
|
||||
permissions:
|
||||
contents: read
|
||||
issues: write
|
||||
pull-requests: write
|
||||
steps:
|
||||
- name: "Confirm correct pull request title"
|
||||
uses: mmubeen/action-pr-title@master # until PR gets merged https://github.com/deepakputhraya/action-pr-title/pull/29
|
||||
|
@ -40,3 +44,35 @@ jobs:
|
|||
"skip-release": "skip_changelog",
|
||||
"skip_changelog": "skip_changelog"
|
||||
}
|
||||
|
||||
role-label:
|
||||
runs-on: ubuntu-latest
|
||||
needs: pr-label
|
||||
if: github.event.pull_request.labels.length == 0
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
|
||||
- name: Get changed roles
|
||||
id: changed-roles
|
||||
uses: tj-actions/changed-files@v35
|
||||
with:
|
||||
path: "roles"
|
||||
diff_relative: "true"
|
||||
files: "**"
|
||||
dir_names: "true"
|
||||
dir_names_max_depth: "1"
|
||||
sha: ${{ github.event.pull_request.head.sha }}
|
||||
|
||||
- name: Add changed roles labels
|
||||
uses: actions/github-script@v6
|
||||
if: |
|
||||
steps.changed-roles.outputs.all_changed_and_modified_files
|
||||
with:
|
||||
script: |
|
||||
const labels = '${{ steps.changed-roles.outputs.all_changed_and_modified_files }}'.split(' ');
|
||||
github.rest.issues.addLabels({
|
||||
issue_number: context.issue.number,
|
||||
owner: context.repo.owner,
|
||||
repo: context.repo.repo,
|
||||
labels: labels
|
||||
})
|
||||
|
|
Loading…
Reference in a new issue