[GHA] Update reference for GitHub actions (#318)
* Update reference for GitHub actions * tox lint file update * Make names consistent * ack - check_label * check source * fix utils ref * update lint workflow * test * test again * fix assert statement * update workflows * test change * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * add back token refresh --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>pull/328/head
parent
8dc11de0a9
commit
786fa9891d
|
@ -1,15 +1,11 @@
|
||||||
---
|
---
|
||||||
# See https://github.com/ansible-community/devtools/blob/main/.github/workflows/ack.yml
|
name: "Check label"
|
||||||
name: ack
|
|
||||||
|
|
||||||
concurrency:
|
concurrency:
|
||||||
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
|
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
|
||||||
cancel-in-progress: true
|
cancel-in-progress: true
|
||||||
|
|
||||||
on: # yamllint disable-line rule:truthy
|
on: # yamllint disable-line rule:truthy
|
||||||
pull_request_target:
|
pull_request_target:
|
||||||
types: [opened, labeled, unlabeled, synchronize]
|
types: [opened, labeled, unlabeled, synchronize]
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
ack:
|
check_label:
|
||||||
uses: ansible/devtools/.github/workflows/ack.yml@main
|
uses: ansible/ansible-content-actions/.github/workflows/check_label.yaml@main
|
|
@ -1,5 +1,5 @@
|
||||||
---
|
---
|
||||||
name: code_coverage
|
name: "Code converage"
|
||||||
|
|
||||||
on: # yamllint disable-line rule:truthy
|
on: # yamllint disable-line rule:truthy
|
||||||
push:
|
push:
|
||||||
|
|
|
@ -0,0 +1,18 @@
|
||||||
|
---
|
||||||
|
name: "Draft release"
|
||||||
|
concurrency:
|
||||||
|
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
|
||||||
|
cancel-in-progress: true
|
||||||
|
on: # yamllint disable-line rule:truthy
|
||||||
|
workflow_dispatch:
|
||||||
|
env:
|
||||||
|
NAMESPACE: ${{ github.repository_owner }}
|
||||||
|
COLLECTION_NAME: utils
|
||||||
|
ANSIBLE_COLLECTIONS_PATHS: ./
|
||||||
|
jobs:
|
||||||
|
update_release_draft:
|
||||||
|
uses: ansible/ansible-content-actions/.github/workflows/draft_release.yaml@main
|
||||||
|
with:
|
||||||
|
repo: ${{ github.event.pull_request.head.repo.full_name }}
|
||||||
|
secrets:
|
||||||
|
BOT_PAT: ${{ secrets.BOT_PAT }}
|
|
@ -1,13 +0,0 @@
|
||||||
---
|
|
||||||
name: ansible-lint
|
|
||||||
on: # yamllint disable-line rule:truthy
|
|
||||||
pull_request:
|
|
||||||
branches: ["main"]
|
|
||||||
jobs:
|
|
||||||
build:
|
|
||||||
name: Ansible Lint # Naming the build is important to use it as a status check
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
steps:
|
|
||||||
- uses: actions/checkout@v4
|
|
||||||
- name: Run ansible-lint
|
|
||||||
uses: ansible/ansible-lint@main # or version tag instead of 'main'
|
|
|
@ -1,28 +0,0 @@
|
||||||
---
|
|
||||||
# push workflow is shared and expected to perform actions after a merge happens
|
|
||||||
# on a maintenance branch (default or release). For example updating the
|
|
||||||
# draft release-notes.
|
|
||||||
# based on great work from
|
|
||||||
# https://github.com/T-Systems-MMS/ansible-collection-icinga-director
|
|
||||||
name: push
|
|
||||||
|
|
||||||
concurrency:
|
|
||||||
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
|
|
||||||
cancel-in-progress: true
|
|
||||||
|
|
||||||
|
|
||||||
on:
|
|
||||||
workflow_dispatch:
|
|
||||||
|
|
||||||
env:
|
|
||||||
NAMESPACE: ansible
|
|
||||||
COLLECTION_NAME: utils
|
|
||||||
ANSIBLE_COLLECTIONS_PATHS: ./
|
|
||||||
|
|
||||||
jobs:
|
|
||||||
update_release_draft:
|
|
||||||
uses: ansible/devtools/.github/workflows/push_network.yml@main
|
|
||||||
with:
|
|
||||||
repo: ansible-collections/ansible.utils
|
|
||||||
secrets:
|
|
||||||
BOT_PAT: ${{ secrets.BOT_PAT }}
|
|
|
@ -1,12 +1,12 @@
|
||||||
---
|
---
|
||||||
name: release
|
name: "Release collection"
|
||||||
on: # yamllint disable-line rule:truthy
|
on: # yamllint disable-line rule:truthy
|
||||||
release:
|
release:
|
||||||
types: [published]
|
types: [published]
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
release:
|
release:
|
||||||
uses: ansible/devtools/.github/workflows/release_collection.yml@main
|
uses: ansible/ansible-content-actions/.github/workflows/release.yaml@main
|
||||||
with:
|
with:
|
||||||
environment: release
|
environment: release
|
||||||
secrets:
|
secrets:
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
---
|
---
|
||||||
name: CI
|
name: "CI"
|
||||||
|
|
||||||
concurrency:
|
concurrency:
|
||||||
group: ${{ github.head_ref || github.run_id }}
|
group: ${{ github.head_ref || github.run_id }}
|
||||||
|
@ -14,22 +14,24 @@ on: # yamllint disable-line rule:truthy
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
changelog:
|
changelog:
|
||||||
uses: ansible-network/github_actions/.github/workflows/changelog.yml@main
|
uses: ansible/ansible-content-actions/.github/workflows/changelog.yaml@main
|
||||||
if: github.event_name == 'pull_request'
|
if: github.event_name == 'pull_request'
|
||||||
integration:
|
ansible-lint:
|
||||||
uses: ansible-network/github_actions/.github/workflows/integration_simple.yml@main
|
uses: ansible/ansible-content-actions/.github/workflows/ansible_lint.yaml@main
|
||||||
sanity:
|
sanity:
|
||||||
uses: ansible-network/github_actions/.github/workflows/sanity.yml@main
|
uses: ansible/ansible-content-actions/.github/workflows/sanity.yaml@main
|
||||||
unit-galaxy:
|
unit-galaxy:
|
||||||
uses: ansible-network/github_actions/.github/workflows/unit_galaxy.yml@main
|
uses: ansible/ansible-content-actions/.github/workflows/unit.yaml@main
|
||||||
|
integration:
|
||||||
|
uses: ansible/ansible-content-actions/.github/workflows/integration.yaml@main
|
||||||
all_green:
|
all_green:
|
||||||
if: ${{ always() }}
|
if: ${{ always() }}
|
||||||
needs:
|
needs:
|
||||||
- changelog
|
- changelog
|
||||||
- integration
|
|
||||||
- sanity
|
- sanity
|
||||||
- unit-galaxy
|
- unit-galaxy
|
||||||
|
- ansible-lint
|
||||||
|
- integration
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- run: >-
|
- run: >-
|
||||||
|
@ -38,5 +40,6 @@ jobs:
|
||||||
'${{ needs.changelog.result }}',
|
'${{ needs.changelog.result }}',
|
||||||
'${{ needs.integration.result }}',
|
'${{ needs.integration.result }}',
|
||||||
'${{ needs.sanity.result }}',
|
'${{ needs.sanity.result }}',
|
||||||
'${{ needs.unit-galaxy.result }}'
|
'${{ needs.unit-galaxy.result }}',
|
||||||
|
'${{ needs.ansible-lint.result }}'
|
||||||
])"
|
])"
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
---
|
---
|
||||||
name: refresh_automation_hub_token
|
name: "Refresh Automation Hub Token"
|
||||||
on: # yamllint disable-line rule:truthy
|
on: # yamllint disable-line rule:truthy
|
||||||
schedule:
|
schedule:
|
||||||
- cron: '0 0 * * *'
|
- cron: '0 0 * * *'
|
||||||
|
@ -7,7 +7,7 @@ on: # yamllint disable-line rule:truthy
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
refresh:
|
refresh:
|
||||||
uses: ansible/devtools/.github/workflows/ah_token_refresh.yml@main
|
uses: ansible/ansible-content-actions/.github/workflows/refresh_ah_token.yaml@main
|
||||||
with:
|
with:
|
||||||
environment: release
|
environment: release
|
||||||
secrets:
|
secrets:
|
||||||
|
|
|
@ -38,10 +38,16 @@ netaddr = pytest.importorskip("netaddr")
|
||||||
|
|
||||||
class TestIpFilter(unittest.TestCase):
|
class TestIpFilter(unittest.TestCase):
|
||||||
def test_cidr_merge(self):
|
def test_cidr_merge(self):
|
||||||
with pytest.raises(AnsibleFilterError, match="cidr_merge: expected iterable, got None"):
|
with pytest.raises(
|
||||||
|
AnsibleFilterError,
|
||||||
|
match="cidr_merge: expected iterable, got None",
|
||||||
|
):
|
||||||
cidr_merge(None)
|
cidr_merge(None)
|
||||||
|
|
||||||
with pytest.raises(AnsibleFilterError, match="cidr_merge: invalid action 'floop'"):
|
with pytest.raises(
|
||||||
|
AnsibleFilterError,
|
||||||
|
match="cidr_merge: invalid action 'floop'",
|
||||||
|
):
|
||||||
cidr_merge([], "floop")
|
cidr_merge([], "floop")
|
||||||
|
|
||||||
self.assertEqual(cidr_merge([]), [])
|
self.assertEqual(cidr_merge([]), [])
|
||||||
|
@ -389,15 +395,30 @@ class TestIpFilter(unittest.TestCase):
|
||||||
address = "1.12.1.0/25"
|
address = "1.12.1.0/25"
|
||||||
self.assertEqual(ipaddr(address, "network_netmask"), "1.12.1.0 255.255.255.128")
|
self.assertEqual(ipaddr(address, "network_netmask"), "1.12.1.0 255.255.255.128")
|
||||||
address = "1.12.1.36/28"
|
address = "1.12.1.36/28"
|
||||||
self.assertEqual(ipaddr(address, "network_netmask"), "1.12.1.32 255.255.255.240")
|
self.assertEqual(
|
||||||
|
ipaddr(address, "network_netmask"),
|
||||||
|
"1.12.1.32 255.255.255.240",
|
||||||
|
)
|
||||||
address = "1.12.1.36/255.255.255.240"
|
address = "1.12.1.36/255.255.255.240"
|
||||||
self.assertEqual(ipaddr(address, "network_netmask"), "1.12.1.32 255.255.255.240")
|
self.assertEqual(
|
||||||
|
ipaddr(address, "network_netmask"),
|
||||||
|
"1.12.1.32 255.255.255.240",
|
||||||
|
)
|
||||||
address = "1.12.1.36/31"
|
address = "1.12.1.36/31"
|
||||||
self.assertEqual(ipaddr(address, "network_netmask"), "1.12.1.36 255.255.255.254")
|
self.assertEqual(
|
||||||
|
ipaddr(address, "network_netmask"),
|
||||||
|
"1.12.1.36 255.255.255.254",
|
||||||
|
)
|
||||||
address = "1.12.1.37/31"
|
address = "1.12.1.37/31"
|
||||||
self.assertEqual(ipaddr(address, "network_netmask"), "1.12.1.36 255.255.255.254")
|
self.assertEqual(
|
||||||
|
ipaddr(address, "network_netmask"),
|
||||||
|
"1.12.1.36 255.255.255.254",
|
||||||
|
)
|
||||||
address = "1.12.1.36/32"
|
address = "1.12.1.36/32"
|
||||||
self.assertEqual(ipaddr(address, "network_netmask"), "1.12.1.36 255.255.255.255")
|
self.assertEqual(
|
||||||
|
ipaddr(address, "network_netmask"),
|
||||||
|
"1.12.1.36 255.255.255.255",
|
||||||
|
)
|
||||||
address = "1.12.1.254/24"
|
address = "1.12.1.254/24"
|
||||||
self.assertEqual(ipaddr(address, "network_netmask"), "1.12.1.0 255.255.255.0")
|
self.assertEqual(ipaddr(address, "network_netmask"), "1.12.1.0 255.255.255.0")
|
||||||
|
|
||||||
|
@ -493,7 +514,10 @@ class TestIpFilter(unittest.TestCase):
|
||||||
self.assertEqual(ipmath("2001::1", 9), "2001::a")
|
self.assertEqual(ipmath("2001::1", 9), "2001::a")
|
||||||
self.assertEqual(ipmath("2001::1", 10), "2001::b")
|
self.assertEqual(ipmath("2001::1", 10), "2001::b")
|
||||||
self.assertEqual(ipmath("2001::5", -3), "2001::2")
|
self.assertEqual(ipmath("2001::5", -3), "2001::2")
|
||||||
self.assertEqual(ipmath("2001::5", -10), "2000:ffff:ffff:ffff:ffff:ffff:ffff:fffb")
|
self.assertEqual(
|
||||||
|
ipmath("2001::5", -10),
|
||||||
|
"2000:ffff:ffff:ffff:ffff:ffff:ffff:fffb",
|
||||||
|
)
|
||||||
|
|
||||||
expected = "You must pass a valid IP address; invalid_ip is invalid"
|
expected = "You must pass a valid IP address; invalid_ip is invalid"
|
||||||
with self.assertRaises(AnsibleFilterError) as exc:
|
with self.assertRaises(AnsibleFilterError) as exc:
|
||||||
|
@ -544,13 +568,13 @@ class TestIpFilter(unittest.TestCase):
|
||||||
ipsubnet("1.1.1.1/25", "24")
|
ipsubnet("1.1.1.1/25", "24")
|
||||||
self.assertEqual(exc.exception.message, expected)
|
self.assertEqual(exc.exception.message, expected)
|
||||||
|
|
||||||
with self.assertRaisesRegexp(
|
with self.assertRaisesRegex(
|
||||||
AnsibleFilterError,
|
AnsibleFilterError,
|
||||||
"You must pass a valid subnet or IP address; invalid_subnet is invalid",
|
"You must pass a valid subnet or IP address; invalid_subnet is invalid",
|
||||||
):
|
):
|
||||||
ipsubnet("192.168.144.5", "invalid_subnet")
|
ipsubnet("192.168.144.5", "invalid_subnet")
|
||||||
|
|
||||||
with self.assertRaisesRegexp(
|
with self.assertRaisesRegex(
|
||||||
AnsibleFilterError,
|
AnsibleFilterError,
|
||||||
"192.168.144.0/30 is not in the subnet 192.168.144.4/30",
|
"192.168.144.0/30 is not in the subnet 192.168.144.4/30",
|
||||||
):
|
):
|
||||||
|
|
|
@ -0,0 +1,9 @@
|
||||||
|
[ansible]
|
||||||
|
skip =
|
||||||
|
py3.7
|
||||||
|
py3.8
|
||||||
|
2.9
|
||||||
|
2.10
|
||||||
|
2.11
|
||||||
|
2.12
|
||||||
|
2.13
|
Loading…
Reference in New Issue