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

Pre-release #50

Merged
merged 9 commits into from
Apr 24, 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
2 changes: 1 addition & 1 deletion .github/labels.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
color: "bfd4f2"

- name: "changes/minor"
description: "Breaking Changes"
description: "Feature Enhancements"
color: "fef2c0"

- name: "changes/patch"
Expand Down
92 changes: 91 additions & 1 deletion .github/workflows/trigger-push-stable.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,103 @@ on:
push:
branches:
- stable
paths-ignore:
- 'docs/**'
- 'CHANGELOG.rst'
- 'changelogs/**'

jobs:
check_commit:
runs-on: ubuntu-latest
outputs:
skip: ${{ steps.filter.outputs.skip }}
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 2 # Fetches the commit history for the last 2 commits
- id: filter
run: |
commit_author=$(git log -1 --pretty=format:'%an')
commit_message=$(git log -1 --pretty=format:'%s')
if [[ "$commit_author" == "opsmill-bot" && \
"$commit_message" == "chore: update pyproject.toml & galaxy.yml" ]]; then
echo "skip=true" >> $GITHUB_OUTPUT
else
echo "skip=false" >> $GITHUB_OUTPUT
fi

prepare_release:
needs: check_commit
if: needs.check_commit.outputs.skip == 'false'
runs-on: ubuntu-22.04
outputs:
next_version: ${{ steps.version.outputs.next-version }}
steps:
- name: "Set up Python"
uses: "actions/setup-python@v5"
with:
python-version: "3.11"

- name: "Install Poetry"
uses: "snok/install-poetry@v1"
with:
virtualenvs-create: true
virtualenvs-in-project: true
installer-parallel: true

- uses: actions/checkout@v4
with:
token: ${{ secrets.GH_INFRAHUB_BOT_TOKEN }}
fetch-depth: 0

- name: Get Previous tag
id: previoustag
uses: "WyriHaximus/github-action-get-previous-tag@master"
env:
GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"

- name: Calculate next version
id: version
uses: patrickjahns/version-drafter-action@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Update pyproject.toml and galaxy.yml versions
run: |
VERSION=${{ steps.version.outputs.next-version }}
python -c "\
import toml; \
with open('pyproject.toml', 'r') as file: \
data = toml.load(file); \
data['tool']['poetry']['version'] = '$VERSION'; \
with open('pyproject.toml', 'w') as file: \
toml.dump(data, file)"
sed -i "s/^version:.*/version: $VERSION/" galaxy.yml

- name: Update lock file
run: poetry lock --no-update

- name: commit pyproject.toml and galaxy.yml
uses: github-actions-x/[email protected]
with:
github-token: ${{ secrets.GH_INFRAHUB_BOT_TOKEN }}
push-branch: 'stable'
commit-message: 'chore: update pyproject.toml & galaxy.yml'
files: pyproject.toml galaxy.yml
name: opsmill-bot
email: [email protected]
rebase: true

changelog_and_docs:
needs: ["prepare_release"]
uses: ./.github/workflows/workflow-changelog-and-docs.yml
with:
version: ${{ needs.prepare_release.outputs.next_version }}
secrets: inherit

release:
needs: ["changelog_and_docs"]
needs: ["prepare_release"]
uses: ./.github/workflows/workflow-release-drafter.yml
with:
version: ${{ needs.prepare_release.outputs.next_version }}
secrets: inherit
20 changes: 6 additions & 14 deletions .github/workflows/workflow-changelog-and-docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,17 @@ name: "Update Changelog & Documentation"

on:
workflow_call:
inputs:
version:
required: true
type: string

jobs:
generate_changelog:
runs-on: "ubuntu-22.04"
name: "Create Changelog and Docs"
steps:
- uses: actions/checkout@v4.1.1
- uses: actions/checkout@v4
with:
token: ${{ secrets.GH_INFRAHUB_BOT_TOKEN }}
fetch-depth: 0
Expand All @@ -26,23 +30,11 @@ jobs:
- name: Install pandoc
run: sudo apt-get install pandoc

- name: 'Get Previous tag'
id: previoustag
uses: "WyriHaximus/github-action-get-previous-tag@master"
env:
GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"

- name: calculate next version
id: version
uses: patrickjahns/version-drafter-action@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: "Generate Docs"
run: "invoke generate-doc"

- name: Generate new version in changelog.yaml
run: antsibull-changelog release -v --version "${{ steps.version.outputs.next-version }}"
run: antsibull-changelog release -v --version "${{ inputs.version }}"

- name: Generate changelog.yaml
run: antsichaut
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/workflow-linter.yml
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ jobs:
- name: "Check out repository code"
uses: "actions/checkout@v4"
- name: "Setup environment"
run: "pip install ruff==0.1.5"
run: "pip install ruff==0.4.1"
- name: "Linting: ruff check"
run: "ruff check --diff ."
- name: "Linting: ruff format"
Expand Down
28 changes: 14 additions & 14 deletions .github/workflows/workflow-release-drafter.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,15 @@ name: "Drafts your next Release notes"

on:
workflow_call:
inputs:
publish:
type: boolean
description: Wether to publish Release note
required: false
default: false
version:
required: true
type: string

permissions:
contents: read
Expand All @@ -20,24 +29,15 @@ jobs:
with:
fetch-depth: 2

- name: Check if there is a parent commit
id: check-parent-commit
- name: Tag new version
run: |
echo "name=sha::$(git rev-parse --verify --quiet HEAD^)" >> $GITHUB_OUTPUT

- name: Detect and tag new version
id: check-version
if: steps.check-parent-commit.outputs.sha
uses: salsify/action-detect-and-tag-new-version@v2
with:
tag-template: "{VERSION}"
version-command: |
cat galaxy.yml | grep version: | cut -d' ' -f2
git tag ${{ inputs.version }}
git push --tags

- uses: release-drafter/release-drafter@v6
with:
config-name: release-drafter.yml
publish: ${{ steps.check-version.outputs.tag != '' }}
tag: ${{ steps.check-version.outputs.tag }}
publish: ${{ inputs.publish }}
tag: ${{ inputs.version }}
env:
GITHUB_TOKEN: ${{ secrets.GH_INFRAHUB_BOT_TOKEN }}
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ To keep the code simple, we only officially support the two latest releases of I
Requirements

- The two latest Infrahub releases
- Python >=3.9, <3.12
- Python >=3.9, <3.13
- Python modules:
- infrahub-sdk >= 0.2.0
- infrahub-sdk >= 0.9.0
- Ansible 2.12+
- Infrahub write-enabled token when using modules or read-only token for `lookup/inventory`

Expand Down
1 change: 0 additions & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ services:
networks:
- integration_network

# Attach these services to the infrahub network that gets spun up from invoke start
networks:
integration_network:
name: infrahub_ansible_default
2 changes: 1 addition & 1 deletion galaxy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ namespace: opsmill
name: infrahub

# The version of the collection. Must be compatible with semantic versioning
version: 1.0.3
version: 1.0.4

# The path to the Markdown (.md) readme file. This path is relative to the root of the collection
readme: README.md
Expand Down
2 changes: 1 addition & 1 deletion plugins/action/query_graphql.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ def run(self, tmp=None, task_vars=None):
update_hostvars = args.get("update_hostvars", False)
if query is None:
raise AnsibleError("Query parameter was not passed")
if isinstance(query, str) or isinstance(query, Dict):
if isinstance(query, (Dict, str)):
graphql_query = query
if graph_variables is not None and not isinstance(graph_variables, Dict):
raise AnsibleError("graph_variables parameter must be a list of Dict")
Expand Down
2 changes: 1 addition & 1 deletion plugins/lookup/lookup.py
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ def run(self, terms, variables=None, query=None, graph_variables=None, **kwargs)

if query is None:
raise AnsibleLookupError("Query parameter was not passed")
if isinstance(query, str) or isinstance(query, Dict):
if isinstance(query, (Dict, str)):
graphql_query = query
else:
raise AnsibleLookupError("Query parameter must be either a string or a Dictionary")
Expand Down
3 changes: 1 addition & 2 deletions plugins/module_utils/infrahub_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -498,8 +498,7 @@ def fetch_and_process(
if variables:
# TODO Need a rendering
raise Exception("query need to be a dict if your are using variables")
else:
query_str = query
query_str = query
else:
raise Exception("query is neither a string nor a Dict")

Expand Down
2 changes: 1 addition & 1 deletion plugins/modules/artifact_fetch.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
#!/usr/bin/python
# -*- coding: utf-8 -*-
# Copyright (c) 2023 Damien Garros
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
"""Ansible plugin definition for artifact_fetch action plugin."""

from __future__ import absolute_import, division, print_function

__metaclass__ = type
Expand Down
2 changes: 1 addition & 1 deletion plugins/modules/query_graphql.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
#!/usr/bin/python
# -*- coding: utf-8 -*-
# Copyright (c) 2023 Benoit Kohler
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
"""Ansible plugin definition for query_graphql action plugin."""

from __future__ import absolute_import, division, print_function

__metaclass__ = type
Expand Down
Loading
Loading