Skip to content
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
3 changes: 3 additions & 0 deletions .github/build-docs.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/bin/sh

cd docs && npm install && npm run build
12 changes: 12 additions & 0 deletions .github/file-filters.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,20 @@ ci_config: &ci_config
github_workflows: &github_workflows
- ".github/workflows/*.yml"

doc_files: &doc_files
- "docs/**"
- package.json
- package-lock.json

python_all: &python_all
- "**/*.py"

yaml_all: &yaml_all
- "**/*.{yml,yaml}"

markdown_all: &markdown_all
- "**/*.{md,mdx}"

documentation_all:
- *doc_files
- *markdown_all
8 changes: 8 additions & 0 deletions .github/labeler.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---
"group/ci":
- changed-files:
- any-glob-to-any-file: [".github/**"]

"type/documentation":
- changed-files:
- any-glob-to-any-file: ["docs/**"]
140 changes: 140 additions & 0 deletions .github/labels.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,140 @@
---
# Labels names are important as they are used by Release Drafter to decide
# regarding where to record them in changelog or if to skip them.
#
# The repository labels will be automatically configured using this file and
# the GitHub Action https://github.com/marketplace/actions/github-labeler.

# ----------------------------------
# GROUP
# ----------------------------------
- name: "group/ci"
description: "Issue related to the CI pipeline"
color: "f25009"

# ----------------------------------
# TYPE (default)
# ----------------------------------
- name: "type/feature"
description: "New feature or request"
color: "a2eeef"

- name: "type/bug"
description: "Something isn't working as expected"
color: "d73a4a"

- name: "type/housekeeping"
description: "Maintenance task"
color: "fef2c0"

- name: "type/tech-debt"
description: "Item we know we need to improve way it is implemented"
color: "73FA20"

# ----------------------------------
# TYPE ALL
# ----------------------------------
- name: "type/question"
description: "Question or discussion"
color: "d876e3"

- name: "type/documentation"
description: "Improvements or additions to documentation"
color: "0075ca"

- name: "type/duplicate"
description: "This issue or pull request already exists"
color: "cfd3d7"

- name: "type/epic"
description: "Large body of work composed of multiple tasks and/or features"
color: "fbd39c"

- name: "type/task"
description: "Body of work related to an epic"
color: "0b8e92"

- name: "type/brainstorming"
description: "Topic for brainstorming, discussions"
color: "e19e0f"

- name: "type/user-centric"
description: "Issue that would improve the overall experience of our users"
color: "ff8c00"

- name: "type/newcomers"
description: "Good for newcomers"
color: "309c56"

# ----------------------------------
# EFFORT
# ----------------------------------
- name: "effort/high"
description: "This issue should be completed in more than a day"
color: "b60205"

- name: "effort/medium"
description: "This issue should be completed in a less than a day"
color: "ff9f1c"

- name: "effort/low"
description: "This issue should be completed in a couple of hours"
color: "ffcc00"

# ----------------------------------
# SEVERITY
# ----------------------------------
- name: "priority/1"
description: "This issue must be fixed/implemented ASAP, it's a blocker for a release"
color: "b60205"

- name: "priority/2"
description: "This issue stalls work on the project or its dependents, it's a blocker for a release"
color: "ff9f1c"

- name: "priority/3"
description: "Not blocking but should be fixed soon"
color: "ffcc00"

- name: "priority/4"
description: "Low priority and doesn't need to be rushed"
color: "cfda2c"

# ----------------------------------
# STATUS
# ----------------------------------
- name: "state/blocked"
description: "The issue is currently blocked and cannot be resolved."
color: "e34918"

- name: "state/draft"
description: "The redaction of the issue is still a work in progress"
color: "dcb518"

- name: "state/need-triage"
description: "This issue needs to be triaged"
color: "333333"

- name: "state/need-more-info"
description: "This issue needs more information"
color: "cccccc"

- name: "state/need-testing"
description: "This issue is ready and needs to be tested."
color: "cccccc"

- name: "state/backlog"
description: "This issue is part of the backlog"
color: "eeeeee"

- name: "state/planned"
description: "This issue is planned to be worked on in an upcoming release."
color: "eeeeee"

- name: "state/not-reproducible"
description: "Unable to reproduce this issue."
color: "eeeeee"

- name: "state/wont-fix"
description: "Issue has been closed and won't be fix/implemented."
color: "eeeeee"
116 changes: 110 additions & 6 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,24 +13,69 @@ concurrency:

env:
GITHUB_PR_NUMBER: ${{ github.event.pull_request.number }}
VALE_VERSION: "3.7.1"

jobs:
files-changed:
name: Detect which file has changed
runs-on: ubuntu-latest
timeout-minutes: 5
outputs:
documentation: ${{ steps.changes.outputs.documentation_all }}
python: ${{ steps.changes.outputs.python_all }}
yaml: ${{ steps.changes.outputs.yaml_all }}
steps:
- name: "Check out repository code"
uses: "actions/checkout@v4"
- name: Check for file changes
uses: dorny/paths-filter@v3
uses: opsmill/paths-filter@v3.0.2
id: changes
with:
token: ${{ github.token }}
filters: .github/file-filters.yml

python-lint:
if: needs.files-changed.outputs.python == 'true'
needs: ["files-changed"]
runs-on: "ubuntu-latest"
strategy:
matrix:
python-version:
- "3.12"
poetry-version:
- "1.8.5"
timeout-minutes: 5
steps:
- name: "Check out repository code"
uses: "actions/checkout@v4"

- name: "Set up Python ${{ matrix.python-version }}"
uses: "actions/setup-python@v5"
with:
python-version: ${{ matrix.python-version }}
- name: "Install Poetry ${{ matrix.poetry-version }}"
uses: "snok/install-poetry@v1"
with:
version: ${{ matrix.poetry-version }}
virtualenvs-create: true
virtualenvs-in-project: true
installer-parallel: true
- name: "Setup Python environment"
run: |
poetry config virtualenvs.create true --local
poetry env use ${{ matrix.python-version }}
- name: "Install dependencies"
run: "poetry install --no-interaction --no-ansi --with dev"

- name: "Linting: ruff check"
run: "poetry run ruff check ."
- name: "Linting: ruff format"
run: "poetry run ruff format --check --diff ."
- name: "Mypy Tests"
run: "poetry run mypy --show-error-codes ."
- name: "Pylint Tests"
run: "poetry run pylint --ignore .venv ."

yaml-lint:
name: Run yaml lint
if: needs.files-changed.outputs.yaml == 'true'
Expand All @@ -45,7 +90,6 @@ jobs:
- name: "Linting: yamllint"
run: "yamllint -s ."

# FIXME: This should be triggered only when some YAML schema changes...
schema-test:
name: Test all schema files
needs:
Expand All @@ -54,7 +98,9 @@ jobs:
if: |
always() && !cancelled() &&
!contains(needs.*.result, 'failure') &&
!contains(needs.*.result, 'cancelled')
!contains(needs.*.result, 'cancelled') &&
needs.files-changed.outputs.yaml == 'true'

runs-on:
group: huge-runners
env:
Expand All @@ -81,7 +127,7 @@ jobs:
run: echo INFRAHUB_BUILD_NAME=infrahub-${{ runner.name }} >> $GITHUB_ENV

- name: Initialize Infrahub
run: invoke start
run: invoke schemas.start

- name: Set infrahub address
run: |
Expand All @@ -92,11 +138,69 @@ jobs:
run: echo TEST_START_TIME=$(date +%s)000 >> $GITHUB_ENV

- name: Test base schema files
run: invoke load-schema-base
run: invoke schemas.load-schema-base

- name: Test extensions schema files
run: invoke load-schema-extensions
run: invoke schemas.load-schema-extensions

- name: "Clear docker environment and force vmagent to stop"
if: always()
run: docker compose -p $INFRAHUB_BUILD_NAME down -v --remove-orphans --rmi local

documentation:
defaults:
run:
working-directory: ./docs
if: |
always() && !cancelled() &&
!contains(needs.*.result, 'failure') &&
!contains(needs.*.result, 'cancelled') &&
needs.files-changed.outputs.documentation == 'true'
needs: ["files-changed", "yaml-lint", "python-lint"]
runs-on: "ubuntu-22.04"
timeout-minutes: 5
steps:
- name: "Check out repository code"
uses: "actions/checkout@v4"
with:
submodules: true
- name: Install NodeJS
uses: actions/setup-node@v4
with:
node-version: 20
cache: 'npm'
cache-dependency-path: docs/package-lock.json
- name: "Install dependencies"
run: npm install
- name: "Setup Python environment"
run: "pip install invoke toml"
- name: "Build docs website"
run: "invoke docusaurus.docs"

validate-documentation-style:
if: |
always() && !cancelled() &&
!contains(needs.*.result, 'failure') &&
!contains(needs.*.result, 'cancelled') &&
needs.files-changed.outputs.documentation == 'true'
needs: ["files-changed", "yaml-lint", "python-lint"]
runs-on: "ubuntu-22.04"
timeout-minutes: 5
steps:
- name: "Check out repository code"
uses: "actions/checkout@v4"
with:
submodules: true

# The official GitHub Action for Vale doesn't work, installing manually instead:
# https://github.com/errata-ai/vale-action/issues/103
- name: Download Vale
run: |
curl -sL "https://github.com/errata-ai/vale/releases/download/v${VALE_VERSION}/vale_${VALE_VERSION}_Linux_64-bit.tar.gz" -o vale.tar.gz
tar -xzf vale.tar.gz
env:
VALE_VERSION: ${{ env.VALE_VERSION }}
- name: "Validate documentation style"
# run: ./vale --config='./.vale.ini' $(find ./docs -type f \( -name "*.mdx" -o -name "*.md" \) )
run: ./vale ./docs/docs/readme.mdx

37 changes: 37 additions & 0 deletions .github/workflows/sync-docs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
name: Sync Folders

on:
push:
branches:
- main
paths:
- 'docs/docs/**'
- 'docs/sidebars.ts'

jobs:
sync:
runs-on: ubuntu-latest
steps:
- name: Checkout source repository
uses: actions/checkout@v4
with:
path: source-repo

- name: Checkout target repository
uses: actions/checkout@v4
with:
repository: opsmill/infrahub-docs
token: ${{ secrets.PAT_TOKEN }}
path: target-repo

- name: Sync folders
run: |
rm -rf target-repo/docs/docs-schema-library/*
rm -f target-repo/docs/sidebars-schema.ts
cp -r source-repo/docs/docs/* target-repo/docs/docs-schema-library/
cp source-repo/docs/sidebars.ts target-repo/docs/sidebars-schema.ts
cd target-repo
git config user.name github-actions
git config user.email github-actions@github.com
git add .
if ! (git diff --quiet && git diff --staged --quiet); then git commit -m "Sync docs from schema-library repo" && git push; fi
Loading