mirror of
https://github.com/prometheus-community/ansible
synced 2025-02-18 05:38:26 +00:00
skip_changelog: unify automatic and manual ansible role tests with labels
Signed-off-by: gardar <gardar@users.noreply.github.com>
This commit is contained in:
parent
fbe8339343
commit
6d6cf8ebaf
1 changed files with 41 additions and 14 deletions
55
.github/workflows/ansible-ci.yml
vendored
55
.github/workflows/ansible-ci.yml
vendored
|
@ -58,8 +58,41 @@ jobs:
|
||||||
"skip_changelog": "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"
|
||||||
|
since_last_remote_commit: "true"
|
||||||
|
|
||||||
|
- 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
|
||||||
|
})
|
||||||
|
|
||||||
ansible-lint:
|
ansible-lint:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
needs: pr-label
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v3
|
- uses: actions/checkout@v3
|
||||||
|
|
||||||
|
@ -68,6 +101,7 @@ jobs:
|
||||||
|
|
||||||
discover-ansible-versions:
|
discover-ansible-versions:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
needs: pr-label
|
||||||
outputs:
|
outputs:
|
||||||
versions: ${{ steps.supported-ansible-versions.outputs.result }}
|
versions: ${{ steps.supported-ansible-versions.outputs.result }}
|
||||||
steps:
|
steps:
|
||||||
|
@ -91,7 +125,10 @@ jobs:
|
||||||
|
|
||||||
discover-ansible-tests:
|
discover-ansible-tests:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
needs: ansible-lint
|
needs:
|
||||||
|
- pr-label
|
||||||
|
- role-label
|
||||||
|
- ansible-lint
|
||||||
outputs:
|
outputs:
|
||||||
molecule-tests: ${{ steps.set-molecule-tests.outputs.tests }}
|
molecule-tests: ${{ steps.set-molecule-tests.outputs.tests }}
|
||||||
integration-tests: ${{ steps.set-integration-tests.outputs.tests }}
|
integration-tests: ${{ steps.set-integration-tests.outputs.tests }}
|
||||||
|
@ -100,22 +137,12 @@ jobs:
|
||||||
with:
|
with:
|
||||||
fetch-depth: 0
|
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
|
- name: Discover role tests
|
||||||
id: set-molecule-tests
|
id: set-molecule-tests
|
||||||
|
env:
|
||||||
|
LABELS: ${{ toJson(github.event.pull_request.labels.*.name) }}
|
||||||
run: |
|
run: |
|
||||||
roles=${{ steps.changed-roles.outputs.all_changed_and_modified_files }}
|
roles=$(echo $LABELS | jq -r '.[]')
|
||||||
roles+=${{ github.event.label.name }}
|
|
||||||
echo tests="[`for role in $roles; do
|
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
|
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#*-}\"'"}';
|
echo '{"test":\"'"${test}"'\","name":\"'"${test#*-}\"'"}';
|
||||||
|
|
Loading…
Add table
Reference in a new issue