From 1c1ca9d3566f60b5666cd383927f7cc33330b38d Mon Sep 17 00:00:00 2001 From: gardar Date: Sun, 21 May 2023 02:49:18 +0000 Subject: [PATCH 1/5] skip_changelog: avoid concurrent ansible ci tests Signed-off-by: gardar --- .github/workflows/ansible-ci.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.github/workflows/ansible-ci.yml b/.github/workflows/ansible-ci.yml index 79cea668..900e69fa 100644 --- a/.github/workflows/ansible-ci.yml +++ b/.github/workflows/ansible-ci.yml @@ -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" From fbe8339343e4ea4c3bd964d2b96da6a74d8edc6a Mon Sep 17 00:00:00 2001 From: gardar Date: Sun, 21 May 2023 02:54:20 +0000 Subject: [PATCH 2/5] skip_changelog: move label jobs into main workflow Signed-off-by: gardar --- .github/workflows/ansible-ci.yml | 37 +++++++++++++++++++++ .github/workflows/conventional-label.yml | 42 ------------------------ 2 files changed, 37 insertions(+), 42 deletions(-) delete mode 100644 .github/workflows/conventional-label.yml diff --git a/.github/workflows/ansible-ci.yml b/.github/workflows/ansible-ci.yml index 900e69fa..790259e5 100644 --- a/.github/workflows/ansible-ci.yml +++ b/.github/workflows/ansible-ci.yml @@ -21,6 +21,43 @@ env: ANSIBLE_GALAXY_SERVER_LIST: "galaxy" jobs: + pr-label: + runs-on: ubuntu-latest + permissions: + pull-requests: write + steps: + - name: "Confirm correct pull request title" + uses: deepakputhraya/action-pr-title@master + with: + allowed_prefixes: 'feat,feature,fix,major,breaking,minor,enhancement,deprecated,removed,security,bug,bugfix,docs,packaging,test,refactor,refactoring,skip-release,skip_changelog' + + - name: "Apply label" + if: github.event.pull_request.labels.length == 0 + uses: bcoe/conventional-release-labels@v1 + with: + type_labels: | + { + "feature": "enhancement", + "feat": "enhancement", + "fix": "bugfix", + "major": "major", + "breaking": "breaking", + "minor": "minor", + "enhancement": "enhancement", + "deprecated": "deprecated", + "removed": "removed", + "security": "security", + "bug": "bug", + "bugfix": "bugfix", + "docs": "trivial", + "packaging": "trivial", + "test": "trivial", + "refactor": "trivial", + "refactoring": "trivial", + "skip-release": "skip_changelog", + "skip_changelog": "skip_changelog" + } + ansible-lint: runs-on: ubuntu-latest steps: diff --git a/.github/workflows/conventional-label.yml b/.github/workflows/conventional-label.yml deleted file mode 100644 index 54799fa0..00000000 --- a/.github/workflows/conventional-label.yml +++ /dev/null @@ -1,42 +0,0 @@ ---- -on: - pull_request_target: - types: [opened, edited, synchronize, reopened] -permissions: - pull-requests: write -name: Auto label pull request -jobs: - label: - runs-on: ubuntu-latest - 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 - with: - allowed_prefixes: 'feat,feature,fix,major,breaking,minor,enhancement,deprecated,removed,security,bug,bugfix,docs,packaging,test,refactor,refactoring,skip-release,skip_changelog' - - - name: "Apply label" - if: github.event.pull_request.labels.length == 0 - uses: bcoe/conventional-release-labels@v1 - with: - type_labels: | - { - "feature": "enhancement", - "feat": "enhancement", - "fix": "bugfix", - "major": "major", - "breaking": "breaking", - "minor": "minor", - "enhancement": "enhancement", - "deprecated": "deprecated", - "removed": "removed", - "security": "security", - "bug": "bug", - "bugfix": "bugfix", - "docs": "trivial", - "packaging": "trivial", - "test": "trivial", - "refactor": "trivial", - "refactoring": "trivial", - "skip-release": "skip_changelog", - "skip_changelog": "skip_changelog" - } From 6d6cf8ebaf4e74152ccd5c60f5f09af3de0fd01f Mon Sep 17 00:00:00 2001 From: gardar Date: Sun, 21 May 2023 03:00:17 +0000 Subject: [PATCH 3/5] skip_changelog: unify automatic and manual ansible role tests with labels Signed-off-by: gardar --- .github/workflows/ansible-ci.yml | 55 ++++++++++++++++++++++++-------- 1 file changed, 41 insertions(+), 14 deletions(-) diff --git a/.github/workflows/ansible-ci.yml b/.github/workflows/ansible-ci.yml index 790259e5..d9435751 100644 --- a/.github/workflows/ansible-ci.yml +++ b/.github/workflows/ansible-ci.yml @@ -58,8 +58,41 @@ jobs: "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: runs-on: ubuntu-latest + needs: pr-label steps: - uses: actions/checkout@v3 @@ -68,6 +101,7 @@ jobs: discover-ansible-versions: runs-on: ubuntu-latest + needs: pr-label outputs: versions: ${{ steps.supported-ansible-versions.outputs.result }} steps: @@ -91,7 +125,10 @@ jobs: discover-ansible-tests: runs-on: ubuntu-latest - needs: ansible-lint + needs: + - pr-label + - role-label + - ansible-lint outputs: molecule-tests: ${{ steps.set-molecule-tests.outputs.tests }} integration-tests: ${{ steps.set-integration-tests.outputs.tests }} @@ -100,22 +137,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#*-}\"'"}'; From 13f813ab5d6e792cb7e11cfd914bbe328923ba6c Mon Sep 17 00:00:00 2001 From: gardar Date: Sun, 21 May 2023 03:12:19 +0000 Subject: [PATCH 4/5] fix: labeler permissions Signed-off-by: gardar --- .github/workflows/ansible-ci.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/ansible-ci.yml b/.github/workflows/ansible-ci.yml index d9435751..a8bad853 100644 --- a/.github/workflows/ansible-ci.yml +++ b/.github/workflows/ansible-ci.yml @@ -24,6 +24,8 @@ jobs: pr-label: runs-on: ubuntu-latest permissions: + contents: read + issues: write pull-requests: write steps: - name: "Confirm correct pull request title" From 4d0c4eea4aa9f5360d1a40b82e2ab46f280fec46 Mon Sep 17 00:00:00 2001 From: gardar Date: Fri, 26 May 2023 19:51:43 +0000 Subject: [PATCH 5/5] fix: labeler needs pull_request_target permissions Signed-off-by: gardar --- .github/workflows/ansible-ci.yml | 75 ----------------------- .github/workflows/conventional-label.yml | 78 ++++++++++++++++++++++++ 2 files changed, 78 insertions(+), 75 deletions(-) create mode 100644 .github/workflows/conventional-label.yml diff --git a/.github/workflows/ansible-ci.yml b/.github/workflows/ansible-ci.yml index a8bad853..14aad912 100644 --- a/.github/workflows/ansible-ci.yml +++ b/.github/workflows/ansible-ci.yml @@ -21,80 +21,8 @@ env: ANSIBLE_GALAXY_SERVER_LIST: "galaxy" jobs: - pr-label: - runs-on: ubuntu-latest - permissions: - contents: read - issues: write - pull-requests: write - steps: - - name: "Confirm correct pull request title" - uses: deepakputhraya/action-pr-title@master - with: - allowed_prefixes: 'feat,feature,fix,major,breaking,minor,enhancement,deprecated,removed,security,bug,bugfix,docs,packaging,test,refactor,refactoring,skip-release,skip_changelog' - - - name: "Apply label" - if: github.event.pull_request.labels.length == 0 - uses: bcoe/conventional-release-labels@v1 - with: - type_labels: | - { - "feature": "enhancement", - "feat": "enhancement", - "fix": "bugfix", - "major": "major", - "breaking": "breaking", - "minor": "minor", - "enhancement": "enhancement", - "deprecated": "deprecated", - "removed": "removed", - "security": "security", - "bug": "bug", - "bugfix": "bugfix", - "docs": "trivial", - "packaging": "trivial", - "test": "trivial", - "refactor": "trivial", - "refactoring": "trivial", - "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" - 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: runs-on: ubuntu-latest - needs: pr-label steps: - uses: actions/checkout@v3 @@ -103,7 +31,6 @@ jobs: discover-ansible-versions: runs-on: ubuntu-latest - needs: pr-label outputs: versions: ${{ steps.supported-ansible-versions.outputs.result }} steps: @@ -128,8 +55,6 @@ jobs: discover-ansible-tests: runs-on: ubuntu-latest needs: - - pr-label - - role-label - ansible-lint outputs: molecule-tests: ${{ steps.set-molecule-tests.outputs.tests }} diff --git a/.github/workflows/conventional-label.yml b/.github/workflows/conventional-label.yml new file mode 100644 index 00000000..fc5134ef --- /dev/null +++ b/.github/workflows/conventional-label.yml @@ -0,0 +1,78 @@ +--- +on: + pull_request_target: + types: [opened, edited, synchronize, reopened] +permissions: + pull-requests: write +name: Auto label pull request +jobs: + 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 + with: + allowed_prefixes: 'feat,feature,fix,major,breaking,minor,enhancement,deprecated,removed,security,bug,bugfix,docs,packaging,test,refactor,refactoring,skip-release,skip_changelog' + + - name: "Apply label" + if: github.event.pull_request.labels.length == 0 + uses: bcoe/conventional-release-labels@v1 + with: + type_labels: | + { + "feature": "enhancement", + "feat": "enhancement", + "fix": "bugfix", + "major": "major", + "breaking": "breaking", + "minor": "minor", + "enhancement": "enhancement", + "deprecated": "deprecated", + "removed": "removed", + "security": "security", + "bug": "bug", + "bugfix": "bugfix", + "docs": "trivial", + "packaging": "trivial", + "test": "trivial", + "refactor": "trivial", + "refactoring": "trivial", + "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 + })