Lint #113
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- | |
name: validate | |
concurrency: | |
group: validate | |
cancel-in-progress: true | |
on: | |
push: | |
branches: | |
- '**' | |
- '!main' | |
permissions: | |
contents: read | |
jobs: | |
# This job detects which parts of the repo have been changed, setting future jobs up for conditional behavior. | |
detect-changes: | |
runs-on: ubuntu-latest | |
outputs: | |
docs: ${{ steps.check.outputs.docs }} | |
tb_pulumi: ${{ steps.check.outputs.tb_pulumi }} | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: dorny/paths-filter@v3 | |
id: check | |
with: | |
filters: | | |
tb_pulumi: | |
- 'tb_pulumi/**' | |
- 'pyproject.toml' | |
docs: | |
- 'tb_pulumi/**.py' | |
- 'docs/**' | |
# Run Ruff against tb_pulumi. Fail on format errors or failed sanity checks. | |
lint: | |
needs: detect-changes | |
runs-on: ubuntu-latest | |
if: needs.detect-changes.outputs.tb_pulumi == 'true' | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Run Ruff syntax checks | |
uses: chartboost/ruff-action@v1 | |
with: | |
src: './tb_pulumi' | |
- name: Run Ruff linter | |
uses: chartboost/ruff-action@v1 | |
with: | |
src: './tb_pulumi' | |
args: 'format --check' | |
# Attempt to build the documentation. Fail if there are errors or warnings. | |
build_docs: | |
needs: detect-changes | |
runs-on: ubuntu-latest | |
if: needs.detect-changes.outputs.docs == 'true' | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Install Python 3.12 | |
uses: actions/setup-python@v5 | |
with: | |
python-version: '3.12' | |
- name: Build docs | |
shell: bash | |
run: | | |
# GHA does `set -e` for us, but we expect the grep below to fail. Thus, we must `set +e` here. | |
set +e | |
pip install .[dev] | |
cd docs | |
make clean html |& tee make.log | |
grep '\(ERROR\|WARNING\)' make.log | |
if [ $? -eq 0 ]; then | |
echo "Problems found in docs build" | |
exit 1 | |
else | |
exit 0 | |
fi |