Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ci: setup semantic release GHA #154

Merged
merged 3 commits into from
Feb 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 23 additions & 13 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -1,23 +1,18 @@
# This GitHub action can publish assets for release when a tag is created.
# Currently its setup to run on any tag that matches the pattern "v*" (ie. v0.1.0).
# This GitHub action creates new release and uploads new collection version to
# Ansible Galaxy

name: release
name: Semantic Release to GitHub and Ansible Galaxy
on:
workflow_dispatch: null
release:
types: [ published ]

jobs:
galaxyrelease:
build:
runs-on: ubuntu-latest
defaults:
run:
working-directory: .ansible/collections/ansible_collections/equinix/cloud
environment: 'METAL_API_TOKEN'
steps:
- name: checkout repo
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
path: .ansible/collections/ansible_collections/equinix/cloud
fetch-depth: 0

- name: update packages
run: sudo apt-get update -y
Expand All @@ -28,11 +23,26 @@ jobs:
- name: setup python 3
uses: actions/setup-python@v4
with:
python-version: '3.x'
python-version: '3.10'

- name: install dependencies
run: pip3 install -r requirements-dev.txt -r requirements.txt

- name: Do GitHub release
uses: cycjimmy/semantic-release-action@v4
with:
semantic_version: 19.0.5
extra_plugins: |
@semantic-release/[email protected]
@semantic-release/[email protected]
[email protected]
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GIT_AUTHOR_NAME: equinix-labs@auto-commit-workflow
GIT_AUTHOR_EMAIL: [email protected]
GIT_COMMITTER_NAME: equinix-labs@auto-commit-workflow
GIT_COMMITTER_EMAIL: [email protected]

- name: publish the collection
run: make publish
env:
Expand Down
42 changes: 42 additions & 0 deletions .releaserc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
{
"branches": [
"main"
],
"ci": false,
"plugins": [
[
"@semantic-release/commit-analyzer",
{
"preset": "conventionalcommits"
}
],
[
"@semantic-release/release-notes-generator",
{
"preset": "conventionalcommits"
}
],
[
"@semantic-release/github",
{
"successComment": "This ${issue.pull_request ? 'PR is included' : 'issue has been resolved'} in version ${nextRelease.version} :tada:",
"labels": false,
"releasedLabels": false
}
],
[
"@semantic-release/exec",
{
"prepareCmd": "echo -n '${nextRelease.version}' > version"
}
],
[
"@semantic-release/git",
{
"message": "ci: regenerate code for version ${nextRelease.version} triggered by ${process.env.RELEASE_REQUESTER}",
"assets": ["."]
}
]
]
}

3 changes: 2 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
SHELL := /bin/bash
COLLECTIONS_PATH ?= ~/.ansible/collections
DOCS_PATH ?= docs
COLLECTION_VERSION ?=
VERSION_FILE=version
COLLECTION_VERSION := $(shell cat ${VERSION_FILE})

TEST_ARGS := -v ${test_target}
INTEGRATION_CONFIG := tests/integration/integration_config.yml
Expand Down
2 changes: 1 addition & 1 deletion requirements-dev.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ botocore==1.20.23
pylint==2.15.5
ansible-doc-extractor==0.1.8
mypy==0.991
ansible==6.7.0
ansible>=7.5.0
Jinja2==3.0.1
black>=23.1.0
isort>=5.12.0
Expand Down
2 changes: 1 addition & 1 deletion template/galaxy.template.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ tags:
- equinix
- cloud
repository: https://github.com/equinix-labs/ansible-collection-equinix
documentation: https://github.com/equinix-labs/ansible-collection-metal/blob/v{{ collection_version }}/README.md
documentation: https://github.com/equinix-labs/ansible-collection-equinix/blob/v{{ collection_version }}/README.md
homepage: https://github.com/equinix-labs/ansible-collection-equinix
issues: https://github.com/equinix-labs/ansible-collection-equinix/issues
build_ignore:
Expand Down
8 changes: 4 additions & 4 deletions tests/integration/targets/metal_connection/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -96,9 +96,9 @@

- assert:
that:
- test_connection.name == "{{ test_name }}"
- test_connection.id == "{{ test_connection_fetched.id }}"
- test_connection.id == "{{ test_connection_fetched_with_id.id }}"
- test_connection.name == test_name
- test_connection.id == test_connection_fetched.id
- test_connection.id == test_connection_fetched_with_id.id

- name: list test connections
equinix.cloud.metal_connection_info:
Expand All @@ -108,7 +108,7 @@
- assert:
that:
- "test_connections_list.resources | length >= 1"
- "test_connection.id in {{ test_connections_list.resources | map(attribute='id') | list }} "
- "test_connection.id in test_connections_list.resources | map(attribute='id') | list"

- name: delete connection
equinix.cloud.metal_connection:
Expand Down
2 changes: 1 addition & 1 deletion tests/integration/targets/metal_gateway/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@

- assert:
that:
- fetched_gateway.id == "{{ gateway.id }}"
- fetched_gateway.id == gateway.id

- name: list gateways
equinix.cloud.metal_gateway_info:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@

- assert:
that:
- gateway_again.id == "{{ gateway.id }}"
- gateway_again.id == gateway.id
- gateway_again.changed == false

- name: fetch gateway by id
Expand All @@ -69,9 +69,9 @@

- assert:
that:
- fetched_gateway.id == "{{ gateway.id }}"
- fetched_gateway.ip_reservation_id == "{{ ip_reservation.id }}"
- fetched_gateway.virtual_network_id == "{{ vlan.id }}"
- fetched_gateway.id == gateway.id
- fetched_gateway.ip_reservation_id == ip_reservation.id
- fetched_gateway.virtual_network_id == vlan.id

- name: delete gateway
equinix.cloud.metal_gateway:
Expand Down
8 changes: 2 additions & 6 deletions tests/integration/targets/metal_ip_assignment/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,6 @@
name: "{{ test_prefix }}-project"
register: project

- assert:
that:
- project.name == '{{ test_prefix }}-project'

- name: request ip reservation
equinix.cloud.metal_reserved_ip_block:
type: "public_ipv4"
Expand Down Expand Up @@ -77,8 +73,8 @@

- assert:
that:
- assignment.device_id == "{{ device.id }}"
- assignment.address == "{{ available_ips.available[0] }}"
- assignment.device_id == device.id
- assignment.address == available_ips.available[0]

- name: assignment info test
equinix.cloud.metal_ip_assignment_info:
Expand Down
21 changes: 14 additions & 7 deletions tests/integration/targets/metal_project/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,29 +13,36 @@
unique_id: "{{ lookup('password', '/dev/null chars=ascii_lowercase,digits length=8') }}"
- set_fact:
test_prefix: "{{ test_resource_name_prefix }}-{{ unique_id }}"
- set_fact:
test_project_name1: '{{ test_prefix }}-project1'
- set_fact:
test_project_renamed: '{{ test_prefix }}-project1_renamed'
- set_fact:
test_project_name2: '{{ test_prefix }}-project2'


- name: create first project for test
equinix.cloud.metal_project:
name: "{{ test_prefix }}-project1"
name: "{{ test_project_name1 }}"
backend_transfer_enabled: true
register: first_project

- name: create first project for test again, to check idempotence
equinix.cloud.metal_project:
name: "{{ test_prefix }}-project1"
name: "{{ test_project_name1 }}"
backend_transfer_enabled: true
register: first_project_2

- assert:
that:
- first_project.name == '{{ test_prefix }}-project1'
- first_project.name == test_project_name1
- first_project.backend_transfer_enabled == true
- first_project_2.changed == false

- name: update project name
equinix.cloud.metal_project:
id: "{{ first_project.id }}"
name: "{{ test_prefix }}-project1_renamed"
name: "{{ test_project_renamed }}"
backend_transfer_enabled: false

- name: fetch updated project
Expand All @@ -45,17 +52,17 @@

- assert:
that:
- first_project_updated.name == '{{ test_prefix }}-project1_renamed'
- first_project_updated.name == test_project_renamed
- first_project_updated.backend_transfer_enabled == false

- name: create second project for test
equinix.cloud.metal_project:
name: "{{ test_prefix }}-project2"
name: "{{ test_project_name2 }}"
register: second_project

- name: list second project
equinix.cloud.metal_project_info:
name: "{{ test_prefix }}-project2"
name: "{{ test_project_name2 }}"
register: second_project_listed

- assert:
Expand Down
29 changes: 16 additions & 13 deletions tests/integration/targets/metal_project_ssh_key/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,34 +22,37 @@
test_key: "ssh-dss AAAAB3NzaC1kc3MAAACBAOpXVtmc0Bla98bt0o5/Zj7sb4mHIukgVFZu7F32R3VK1cEKB4rEE8uS0oLS/qMRLue45TWVJwRMYGlPjt3p/VyraelxoyJZLuITIsqa5hBc9w0oTlB5Bmbkn16umW96WCaWEoq/aitpocbRChTiP5biI6FyQTQlIHDaYzBDOi11AAAAFQDUXy7cmuzphDpJSYYTiudiUhVokwAAAIEAyUQ9m8qL/1HPkFe6jbXAvtSSmW27F4c+G2xR5HizaHQzXgBOxPcsOsY17KTU+Ddbg+OF9soWNwSpm9pyVjVmNGqH3S8R1pwvuJF/O2Asy1m6wpWhbPw8JdEBW7WHoptBpfuzJoS2LOzJUEmUu4Eb+xS237KG1d1BVny/49KAoH0AAACBAJKBSsm9Xey0fUN6vYtTQgoYeGxxj/LqAIAOs/TpCxZDntly860y/SzHYai8x48k4t7whENY1CJ41fpMcPlz8xIsrNP3326Wbr0ExwOIvJKAVN1YLYqF8NXWzaVrjo5WbSeI8PiWTYemvLAujVxZssIrApTZBhp55nnwge6K1zTG tomk@air"
- set_fact:
test_key2: "ssh-dss AAAAB3NzaC1kc3MAAACBAPWcHWkA06LxBQ67WmNsp1+aZMwNNz9v67pftePlQg94Z1cU4s/5j5S/Fknj7gapWw/ouiOYqXhC2p/hC9/1ARY15t0aHYqLjRhWzs3j8miL1YyXYjqLPLDtgNpX9E09We5ogjbYCB8CCtZrujm/MB6NWvX+T4uG8C/g66I4/bGdAAAAFQDa4SS+q9aQK/XwiqnWpFpAEY74TQAAAIEAklEfXCf1qbUvTquHhtNVKTiKm+qGRsqxnLnu7aduzU81JDFzveF/agkE5x30olTvKECb1PAziDmt63z/obO3Da8TUz0QVdqv81pNWU5JUNiTB8d3rDJU3B66DA6GI305W8qyt0AGUNGR3rDIzNpZY958faBg+TaILRg8ZFNh0PAAAACAdUhJS6bl5M5sQr6XNilHa0nOTk/PB54faGWWMq7zQvxUKJKsDklNTc0MCPjRppyuokbQ6297tq8pEEFqUAyllMvAf75X7DsBQivLzbNuzp41NqFdS/Oka+T1ypRD7mT6g0Kg8yCVYD2ti874wyTpV9riUUaoItveEF3AdC9AzmI= tomk@air"
- set_fact:
test_key_label: "{{ test_prefix }}-ssh_key1"
- set_fact:
test_key_renamed: "{{ test_prefix }}-ssh_key1_renamed"
- set_fact:
test_key_label2: "{{ test_prefix }}-ssh_key2"

- name: create project for test
equinix.cloud.metal_project:
name: "{{ test_prefix }}-project"
register: project

- assert:
that:
- project.name == '{{ test_prefix }}-project'

- name: create first project ssh_key for test
equinix.cloud.metal_project_ssh_key:
label: "{{ test_prefix }}-ssh_key1"
key: "{{ test_key }}"
project_id: "{{ project.id }}"
register: first_ssh_key


- name: create first ssh_key for test again, to check idempotence
equinix.cloud.metal_project_ssh_key:
label: "{{ test_prefix }}-ssh_key1"
label: "{{ test_key_label }}"
key: "{{ test_key }}"
project_id: "{{ project.id }}"
register: first_ssh_key_2

- assert:
that:
- first_ssh_key.label == '{{ test_prefix }}-ssh_key1'
- first_ssh_key.key == "{{ test_key }}"
- first_ssh_key.label == test_key_label
- first_ssh_key.key == test_key
- first_ssh_key_2.changed == false

- name: update ssh_key label
Expand All @@ -65,12 +68,12 @@

- assert:
that:
- first_ssh_key_updated.label == '{{ test_prefix }}-ssh_key1_renamed'
- first_ssh_key.key == "{{ test_key }}"
- first_ssh_key_updated.label == test_key_renamed
- first_ssh_key.key == test_key

- name: create second ssh_key for test
equinix.cloud.metal_project_ssh_key:
label: "{{ test_prefix }}-ssh_key2"
label: "{{ test_key_label2 }}"
key: "{{ test_key2 }}"
project_id: "{{ project.id }}"
register: second_ssh_key
Expand All @@ -84,11 +87,11 @@
msg: "{{ ssh_keys_listed.resources }}"

- debug:
msg: 'ssh_keys_listed.resources | selectattr("label", "equalto", "{{ test_prefix }}-ssh_key2")'
msg: 'ssh_keys_listed.resources | selectattr("label", "equalto", test_key_label2)'

- assert:
that:
- 'ssh_keys_listed.resources | selectattr("label", "equalto", "{{ test_prefix }}-ssh_key2") | length == 1'
- 'ssh_keys_listed.resources | selectattr("label", "equalto", test_key_label2) | length == 1'

- name: list test ssh keys
set_fact:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,6 @@
name: "{{ test_prefix }}-project"
register: project

- assert:
that:
- project.name == '{{ test_prefix }}-project'

- name: request ip reservation
equinix.cloud.metal_reserved_ip_block:
type: "public_ipv4"
Expand Down
Loading
Loading