@@ -13,24 +13,69 @@ concurrency:
1313
1414env :
1515 GITHUB_PR_NUMBER : ${{ github.event.pull_request.number }}
16+ VALE_VERSION : " 3.7.1"
1617
1718jobs :
1819 files-changed :
1920 name : Detect which file has changed
2021 runs-on : ubuntu-latest
2122 timeout-minutes : 5
2223 outputs :
24+ documentation : ${{ steps.changes.outputs.documentation_all }}
25+ python : ${{ steps.changes.outputs.python_all }}
2326 yaml : ${{ steps.changes.outputs.yaml_all }}
2427 steps :
2528 - name : " Check out repository code"
2629 uses : " actions/checkout@v4"
2730 - name : Check for file changes
28- uses : dorny /paths-filter@v3
31+ uses : opsmill /paths-filter@v3.0.2
2932 id : changes
3033 with :
3134 token : ${{ github.token }}
3235 filters : .github/file-filters.yml
3336
37+ python-lint :
38+ if : needs.files-changed.outputs.python == 'true'
39+ needs : ["files-changed"]
40+ runs-on : " ubuntu-latest"
41+ strategy :
42+ matrix :
43+ python-version :
44+ - " 3.12"
45+ poetry-version :
46+ - " 1.8.5"
47+ timeout-minutes : 5
48+ steps :
49+ - name : " Check out repository code"
50+ uses : " actions/checkout@v4"
51+
52+ - name : " Set up Python ${{ matrix.python-version }}"
53+ uses : " actions/setup-python@v5"
54+ with :
55+ python-version : ${{ matrix.python-version }}
56+ - name : " Install Poetry ${{ matrix.poetry-version }}"
57+ uses : " snok/install-poetry@v1"
58+ with :
59+ version : ${{ matrix.poetry-version }}
60+ virtualenvs-create : true
61+ virtualenvs-in-project : true
62+ installer-parallel : true
63+ - name : " Setup Python environment"
64+ run : |
65+ poetry config virtualenvs.create true --local
66+ poetry env use ${{ matrix.python-version }}
67+ - name : " Install dependencies"
68+ run : " poetry install --no-interaction --no-ansi --with dev"
69+
70+ - name : " Linting: ruff check"
71+ run : " poetry run ruff check ."
72+ - name : " Linting: ruff format"
73+ run : " poetry run ruff format --check --diff ."
74+ - name : " Mypy Tests"
75+ run : " poetry run mypy --show-error-codes emma pages"
76+ - name : " Pylint Tests"
77+ run : " poetry run pylint . *.py"
78+
3479 yaml-lint :
3580 name : Run yaml lint
3681 if : needs.files-changed.outputs.yaml == 'true'
4590 - name : " Linting: yamllint"
4691 run : " yamllint -s ."
4792
48- # FIXME: This should be triggered only when some YAML schema changes...
4993 schema-test :
5094 name : Test all schema files
5195 needs :
5498 if : |
5599 always() && !cancelled() &&
56100 !contains(needs.*.result, 'failure') &&
57- !contains(needs.*.result, 'cancelled')
101+ !contains(needs.*.result, 'cancelled') &&
102+ needs.files-changed.outputs.yaml == 'true'
103+
58104 runs-on :
59105 group : huge-runners
60106 env :
81127 run : echo INFRAHUB_BUILD_NAME=infrahub-${{ runner.name }} >> $GITHUB_ENV
82128
83129 - name : Initialize Infrahub
84- run : invoke start
130+ run : invoke schemas. start
85131
86132 - name : Set infrahub address
87133 run : |
@@ -92,11 +138,67 @@ jobs:
92138 run : echo TEST_START_TIME=$(date +%s)000 >> $GITHUB_ENV
93139
94140 - name : Test base schema files
95- run : invoke load-schema-base
141+ run : invoke schemas. load-schema-base
96142
97143 - name : Test extensions schema files
98- run : invoke load-schema-extensions
144+ run : invoke schemas. load-schema-extensions
99145
100146 - name : " Clear docker environment and force vmagent to stop"
101147 if : always()
102148 run : docker compose -p $INFRAHUB_BUILD_NAME down -v --remove-orphans --rmi local
149+
150+ documentation :
151+ defaults :
152+ run :
153+ working-directory : ./docs
154+ if : |
155+ always() && !cancelled() &&
156+ !contains(needs.*.result, 'failure') &&
157+ !contains(needs.*.result, 'cancelled') &&
158+ needs.files-changed.outputs.documentation == 'true'
159+ needs : ["files-changed", "yaml-lint", "python-lint"]
160+ runs-on : " ubuntu-22.04"
161+ timeout-minutes : 5
162+ steps :
163+ - name : " Check out repository code"
164+ uses : " actions/checkout@v4"
165+ with :
166+ submodules : true
167+ - name : Install NodeJS
168+ uses : actions/setup-node@v4
169+ with :
170+ node-version : 20
171+ cache : ' npm'
172+ cache-dependency-path : docs/package-lock.json
173+ - name : " Install dependencies"
174+ run : npm install
175+ - name : " Setup Python environment"
176+ run : " pip install invoke toml"
177+ - name : " Build docs website"
178+ run : " invoke docusaurus.docs"
179+
180+ validate-documentation-style :
181+ if : |
182+ always() && !cancelled() &&
183+ !contains(needs.*.result, 'failure') &&
184+ !contains(needs.*.result, 'cancelled') &&
185+ needs.files-changed.outputs.documentation == 'true'
186+ needs : ["files-changed", "yaml-lint", "python-lint"]
187+ runs-on : " ubuntu-22.04"
188+ timeout-minutes : 5
189+ steps :
190+ - name : " Check out repository code"
191+ uses : " actions/checkout@v4"
192+ with :
193+ submodules : true
194+
195+ # The official GitHub Action for Vale doesn't work, installing manually instead:
196+ # https://github.com/errata-ai/vale-action/issues/103
197+ - name : Download Vale
198+ run : |
199+ 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
200+ tar -xzf vale.tar.gz
201+ env :
202+ VALE_VERSION : ${{ env.VALE_VERSION }}
203+ - name : " Validate documentation style"
204+ run : ./vale $(find ./docs -type f \( -name "*.mdx" -o -name "*.md" \) )
0 commit comments