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

Automation fixes/improvements #32

Merged
merged 5 commits into from
Aug 18, 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
10 changes: 10 additions & 0 deletions project/.pre-commit-config.yaml.j2
Original file line number Diff line number Diff line change
Expand Up @@ -136,4 +136,14 @@ repos:
- -e
- lint-tests-pre-commit
- --

{%- if "github.com" in source_url %}

- repo: https://github.com/Mateusz-Grzelinski/actionlint-py
rev: 1ca29a1b5d949b3586800190ad6cc98317cb43b8 # v1.7.1.15
hooks:
- id: actionlint
additional_dependencies:
- shellcheck-py>=0.9.0.5
{%- endif %}
# <---- Code Analysis --------------------------------------------------------------------------
22 changes: 14 additions & 8 deletions project/noxfile.py.j2
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
import datetime
import json
import os
import pathlib
import shutil
import sys
import tempfile
Expand Down Expand Up @@ -37,7 +36,7 @@ if SALT_REQUIREMENT == "salt==master":
os.environ["PYTHONDONTWRITEBYTECODE"] = "1"

# Global Path Definitions
REPO_ROOT = pathlib.Path(__file__).resolve().parent
REPO_ROOT = Path(__file__).resolve().parent
# Change current directory to REPO_ROOT
os.chdir(str(REPO_ROOT))

Expand Down Expand Up @@ -183,7 +182,7 @@ def tests(session):
if arg.startswith(f"tests{os.sep}"):
break
try:
pathlib.Path(arg).resolve().relative_to(REPO_ROOT / "tests")
Path(arg).resolve().relative_to(REPO_ROOT / "tests")
break
except ValueError:
continue
Expand Down Expand Up @@ -449,8 +448,7 @@ def docs_html(session, clean, include_api_docs):


@nox.session(name="docs-dev", python="3")
@nox.parametrize("clean", [False, True])
def docs_dev(session, clean) -> None:
def docs_dev(session):
"""
Build and serve the Sphinx HTML documentation, with live reloading on file changes, via sphinx-autobuild.

Expand All @@ -465,10 +463,18 @@ def docs_dev(session, clean) -> None:
install_extras=["docs", "docsauto"],
)

# Launching LIVE reloading Sphinx session
build_dir = Path("docs", "_build", "html")
args = ["--watch", ".", "--open-browser", "docs", str(build_dir)]
if clean and build_dir.exists():

# Allow specifying sphinx-autobuild options, like --host.
args = ["--watch", "."] + session.posargs
if not any(arg.startswith("--host") for arg in args):
# If the user is overriding the host to something other than localhost,
# it's likely they are rendering on a remote/headless system and don't
# want the browser to open.
args.append("--open-browser")
args += ["docs", str(build_dir)]

if build_dir.exists():
shutil.rmtree(build_dir)

session.run("sphinx-autobuild", *args)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
---
name: CI

on:
Expand Down Expand Up @@ -59,12 +60,11 @@ jobs:
deploy-docs:
name: Deploy Docs
uses: ./.github/workflows/deploy-docs-action.yml
# Only build doc deployments from the main branch of the org repo and never for PRs.
if: >
${{ inputs.deploy-docs &&
github.ref == 'refs/heads/main' &&
github.event_name != 'pull_request'
}}
# Only build doc deployments from the default branch of the repo and never for PRs.
if: >-
github.event_name != 'pull_request' &&
inputs.deploy-docs &&
github.ref == format('refs/heads/{0}', github.event.repository.default_branch)
needs:
- docs
- test
Expand Down Expand Up @@ -112,32 +112,33 @@ jobs:
needs:
- test
- docs
- deploy-docs
- build-python-package
- deploy-python-package-test-pypi
- deploy-python-package
steps:
- name: Download Exit Status Files
if: always()
uses: actions/download-artifact@v4
with:
path: exitstatus
pattern: exitstatus-*
merge-multiple: true
- name: Download Exit Status Files
if: always()
uses: actions/download-artifact@v4
with:
path: exitstatus
pattern: exitstatus-*
merge-multiple: true

- name: Delete Exit Status Artifacts
if: always()
uses: geekyeggo/delete-artifact@v5
with:
name: exitstatus-*
useGlob: true
failOnError: false
- name: Delete Exit Status Artifacts
if: always()
uses: geekyeggo/delete-artifact@v5
with:
name: exitstatus-*
useGlob: true
failOnError: false

- name: Set Pipeline Exit Status
run: |
tree exitstatus
grep -RE 'failure|cancelled' exitstatus/ && exit 1 || exit 0
- name: Set Pipeline Exit Status
run: |
tree exitstatus
grep -RE 'failure|cancelled' exitstatus/ && exit 1 || exit 0

- name: Done
if: always()
run:
echo "All workflows finished"
- name: Done
if: always()
run:
echo "All workflows finished"
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
---
name: Publish Documentation

on:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
---
name: Deploy Salt Extension Python Package

on:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{%- set pyver = salt_python_support[salt_version | int]["max"][1] -%}

---
name: Build Documentation

on:
Expand All @@ -11,46 +11,46 @@ jobs:
timeout-minutes: 10

steps:
- uses: actions/checkout@v4

- name: Set up Python 3.{{ pyver }} For Nox
uses: actions/setup-python@v5
with:
python-version: "3.{{ pyver }}"

- name: Install Nox
run: |
python -m pip install --upgrade pip
pip install nox

- name: Install Doc Requirements
run: |
nox --force-color -e docs --install-only

- name: Build Docs
env:
SKIP_REQUIREMENTS_INSTALL: true
run: |
nox --force-color -e docs
- uses: actions/checkout@v4

- name: Set up Python 3.{{ pyver }} For Nox
uses: actions/setup-python@v5
with:
python-version: "3.{{ pyver }}"

- name: Install Nox
run: |
python -m pip install --upgrade pip
pip install nox

- name: Install Doc Requirements
run: |
nox --force-color -e docs --install-only

- name: Build Docs
env:
SKIP_REQUIREMENTS_INSTALL: true
run: |
nox --force-color -e docs
{%- raw %}

- name: Upload built docs as artifact
uses: actions/upload-artifact@v4
with:
name: html-docs
path: docs/_build/html

- name: Set Exit Status
if: always()
run: |
mkdir exitstatus
echo "${{ job.status }}" > exitstatus/${{ github.job }}

- name: Upload Exit Status
if: always()
uses: actions/upload-artifact@v4
with:
name: exitstatus-${{ github.job }}
path: exitstatus
if-no-files-found: error
- name: Upload built docs as artifact
uses: actions/upload-artifact@v4
with:
name: html-docs
path: docs/_build/html

- name: Set Exit Status
if: always()
run: |
mkdir exitstatus
echo "${{ job.status }}" > exitstatus/${{ github.job }}

- name: Upload Exit Status
if: always()
uses: actions/upload-artifact@v4
with:
name: exitstatus-${{ github.job }}
path: exitstatus
if-no-files-found: error
{%- endraw %}
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
---
on:
workflow_call:
outputs:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{%- set pyver = salt_python_support[salt_version | int]["max"][1] -%}

---
name: Salt Extension Python Package

on:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
---
name: Pre-Commit

on:
Expand Down
Loading