From 25ef6143abbd820cf4c55b3533fe975555de473b Mon Sep 17 00:00:00 2001 From: Rich Megginson Date: Wed, 29 Jan 2025 14:44:55 -0700 Subject: [PATCH 1/9] ci: use latest version of ansible-lint Signed-off-by: Rich Megginson --- .github/workflows/ansible-lint.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ansible-lint.yml b/.github/workflows/ansible-lint.yml index d0ee41bc..7cb634fb 100644 --- a/.github/workflows/ansible-lint.yml +++ b/.github/workflows/ansible-lint.yml @@ -44,6 +44,6 @@ jobs: mkdir -p "$coll_dir/.git" - name: Run ansible-lint - uses: ansible/ansible-lint@v24 + uses: ansible/ansible-lint@main with: working_directory: ${{ github.workspace }}/.tox/ansible_collections/${{ env.LSR_ROLE2COLL_NAMESPACE }}/${{ env.LSR_ROLE2COLL_NAME }} From 2097439e0ff0041509722826c759b2a995195f4a Mon Sep 17 00:00:00 2001 From: Rich Megginson Date: Wed, 29 Jan 2025 14:56:21 -0700 Subject: [PATCH 2/9] v25 --- .github/workflows/ansible-lint.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ansible-lint.yml b/.github/workflows/ansible-lint.yml index 7cb634fb..5327054f 100644 --- a/.github/workflows/ansible-lint.yml +++ b/.github/workflows/ansible-lint.yml @@ -44,6 +44,6 @@ jobs: mkdir -p "$coll_dir/.git" - name: Run ansible-lint - uses: ansible/ansible-lint@main + uses: ansible/ansible-lint@v25 with: working_directory: ${{ github.workspace }}/.tox/ansible_collections/${{ env.LSR_ROLE2COLL_NAMESPACE }}/${{ env.LSR_ROLE2COLL_NAME }} From 40c3550f5e06e89f2d589f10fd0291d75a69a375 Mon Sep 17 00:00:00 2001 From: Rich Megginson Date: Wed, 29 Jan 2025 15:04:35 -0700 Subject: [PATCH 3/9] try using requirements_file --- .github/workflows/ansible-lint.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/ansible-lint.yml b/.github/workflows/ansible-lint.yml index 5327054f..a259e566 100644 --- a/.github/workflows/ansible-lint.yml +++ b/.github/workflows/ansible-lint.yml @@ -47,3 +47,4 @@ jobs: uses: ansible/ansible-lint@v25 with: working_directory: ${{ github.workspace }}/.tox/ansible_collections/${{ env.LSR_ROLE2COLL_NAMESPACE }}/${{ env.LSR_ROLE2COLL_NAME }} + requirements_file: ${{ github.workspace }}/meta/collection-requirements.yml From e6918337998de16df5f3a998f76b87ee1444ba4f Mon Sep 17 00:00:00 2001 From: Rich Megginson Date: Wed, 29 Jan 2025 15:20:03 -0700 Subject: [PATCH 4/9] more --- .github/workflows/ansible-lint.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ansible-lint.yml b/.github/workflows/ansible-lint.yml index a259e566..05303d3c 100644 --- a/.github/workflows/ansible-lint.yml +++ b/.github/workflows/ansible-lint.yml @@ -35,6 +35,7 @@ jobs: pip3 install "git+https://github.com/linux-system-roles/tox-lsr@3.4.0" - name: Convert role to collection format + id: collection run: | set -euxo pipefail TOXENV=collection lsr_ci_runtox @@ -42,9 +43,10 @@ jobs: # ansible-lint action requires a .git directory??? # https://github.com/ansible/ansible-lint/blob/main/action.yml#L45 mkdir -p "$coll_dir/.git" + echo "coll_req_file=" >> $GITHUB_OUTPUT - name: Run ansible-lint uses: ansible/ansible-lint@v25 with: working_directory: ${{ github.workspace }}/.tox/ansible_collections/${{ env.LSR_ROLE2COLL_NAMESPACE }}/${{ env.LSR_ROLE2COLL_NAME }} - requirements_file: ${{ github.workspace }}/meta/collection-requirements.yml + requirements_file: ${{ steps.collection.outputs.coll_req_file }} From 70f502615eaf0436e360be10ef5547943cc9662c Mon Sep 17 00:00:00 2001 From: Rich Megginson Date: Wed, 29 Jan 2025 15:50:28 -0700 Subject: [PATCH 5/9] conditional code --- .github/workflows/ansible-lint.yml | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/.github/workflows/ansible-lint.yml b/.github/workflows/ansible-lint.yml index 05303d3c..49a95409 100644 --- a/.github/workflows/ansible-lint.yml +++ b/.github/workflows/ansible-lint.yml @@ -43,6 +43,23 @@ jobs: # ansible-lint action requires a .git directory??? # https://github.com/ansible/ansible-lint/blob/main/action.yml#L45 mkdir -p "$coll_dir/.git" + meta_req_file="${{ github.workspace }}/meta/collection-requirements.yml" + test_req_file="${{ github.workspace }}/tests/collection-requirements.yml" + if [ -f "$meta_req_file" ] && [ -f "$test_req_file" ]; then + coll_req_file="${{ github.workspace }}/req.yml" + python -c 'import sys; import yaml + hsh1 = yaml.safe_load(open(sys.argv[0]) + hsh2 = yaml.safe_load(open(sys.argv[1]) + coll = list(set(hsh1["collections"]).union(hsh2["collections"]) + hsh1["collections"] = coll + yaml.safe_dump(hsh1, open(sys.argv[2], "w"))' "$meta_req_file" "$test_req_file" "$coll_req_file" + elif [ -f "$meta_req_file" ]; then + coll_req_file="$meta_req_file" + elif [ -f "$test_req_file" ]; then + coll_req_file="$test_req_file" + else + coll_req_file="" + fi echo "coll_req_file=" >> $GITHUB_OUTPUT - name: Run ansible-lint From 6167a210fa08958b7bfff4f715e6834edf42c946 Mon Sep 17 00:00:00 2001 From: Rich Megginson Date: Wed, 29 Jan 2025 15:55:26 -0700 Subject: [PATCH 6/9] conditional code --- .github/workflows/ansible-lint.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ansible-lint.yml b/.github/workflows/ansible-lint.yml index 49a95409..8f76334d 100644 --- a/.github/workflows/ansible-lint.yml +++ b/.github/workflows/ansible-lint.yml @@ -50,7 +50,7 @@ jobs: python -c 'import sys; import yaml hsh1 = yaml.safe_load(open(sys.argv[0]) hsh2 = yaml.safe_load(open(sys.argv[1]) - coll = list(set(hsh1["collections"]).union(hsh2["collections"]) + coll = list(set(hsh1["collections"]).union(hsh2["collections"])) hsh1["collections"] = coll yaml.safe_dump(hsh1, open(sys.argv[2], "w"))' "$meta_req_file" "$test_req_file" "$coll_req_file" elif [ -f "$meta_req_file" ]; then From 7c60c17ccedfa180e931dc6566070e8c3cf84c5c Mon Sep 17 00:00:00 2001 From: Rich Megginson Date: Wed, 29 Jan 2025 15:58:06 -0700 Subject: [PATCH 7/9] conditional code --- .github/workflows/ansible-lint.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ansible-lint.yml b/.github/workflows/ansible-lint.yml index 8f76334d..bda06cd5 100644 --- a/.github/workflows/ansible-lint.yml +++ b/.github/workflows/ansible-lint.yml @@ -48,8 +48,8 @@ jobs: if [ -f "$meta_req_file" ] && [ -f "$test_req_file" ]; then coll_req_file="${{ github.workspace }}/req.yml" python -c 'import sys; import yaml - hsh1 = yaml.safe_load(open(sys.argv[0]) - hsh2 = yaml.safe_load(open(sys.argv[1]) + hsh1 = yaml.safe_load(open(sys.argv[0])) + hsh2 = yaml.safe_load(open(sys.argv[1])) coll = list(set(hsh1["collections"]).union(hsh2["collections"])) hsh1["collections"] = coll yaml.safe_dump(hsh1, open(sys.argv[2], "w"))' "$meta_req_file" "$test_req_file" "$coll_req_file" From 3051dfb460100de1ff152886500c997bd776a4fa Mon Sep 17 00:00:00 2001 From: Rich Megginson Date: Wed, 29 Jan 2025 16:04:07 -0700 Subject: [PATCH 8/9] conditional code --- .github/workflows/ansible-lint.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ansible-lint.yml b/.github/workflows/ansible-lint.yml index bda06cd5..ea6ae4d8 100644 --- a/.github/workflows/ansible-lint.yml +++ b/.github/workflows/ansible-lint.yml @@ -48,11 +48,11 @@ jobs: if [ -f "$meta_req_file" ] && [ -f "$test_req_file" ]; then coll_req_file="${{ github.workspace }}/req.yml" python -c 'import sys; import yaml - hsh1 = yaml.safe_load(open(sys.argv[0])) - hsh2 = yaml.safe_load(open(sys.argv[1])) + hsh1 = yaml.safe_load(open(sys.argv[1])) + hsh2 = yaml.safe_load(open(sys.argv[2])) coll = list(set(hsh1["collections"]).union(hsh2["collections"])) hsh1["collections"] = coll - yaml.safe_dump(hsh1, open(sys.argv[2], "w"))' "$meta_req_file" "$test_req_file" "$coll_req_file" + yaml.safe_dump(hsh1, open(sys.argv[3], "w"))' "$meta_req_file" "$test_req_file" "$coll_req_file" elif [ -f "$meta_req_file" ]; then coll_req_file="$meta_req_file" elif [ -f "$test_req_file" ]; then From 88d8ac958a40cc19b42ec92a5aeaaa4b9e52a60c Mon Sep 17 00:00:00 2001 From: Rich Megginson Date: Wed, 29 Jan 2025 17:13:18 -0700 Subject: [PATCH 9/9] conditional code --- .github/workflows/ansible-lint.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ansible-lint.yml b/.github/workflows/ansible-lint.yml index ea6ae4d8..9fcc978e 100644 --- a/.github/workflows/ansible-lint.yml +++ b/.github/workflows/ansible-lint.yml @@ -60,7 +60,7 @@ jobs: else coll_req_file="" fi - echo "coll_req_file=" >> $GITHUB_OUTPUT + echo "coll_req_file=$coll_req_file" >> $GITHUB_OUTPUT - name: Run ansible-lint uses: ansible/ansible-lint@v25