Skip to content

Commit

Permalink
replace yamllint with yamlfix, add sanity check before commit in gh a…
Browse files Browse the repository at this point in the history
…ction

Signed-off-by: Jack Luar <[email protected]>
  • Loading branch information
luarss committed Oct 13, 2024
1 parent a21367c commit b64ab9e
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 55 deletions.
30 changes: 20 additions & 10 deletions .github/workflows/github-actions-yaml-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,15 @@ jobs:
uses: actions/checkout@v4
with:
submodules: 'recursive'
- name: Run YAML script
- name: Run generate-variable-docs.py
run: |
python3 flow/scripts/generate-variable-docs.py
- name: Run YAML Lint
- name: Run yamlfix check
run: |
pip install yamllint==1.35.1
yamllint flow/scripts/variables.yaml
yamlfix -c yamlfix.toml flow/scripts/variables.yaml --check
docs-pr-update:
name: 'Create PR to update ORFS FlowVariables.md'
name: 'Create PR to update ORFS FlowVariables.md and variables.yaml'
needs:
- docs-test-job
runs-on: ubuntu-latest
Expand All @@ -33,8 +32,12 @@ jobs:
- name: Run generate-variable-docs.py
run: |
python3 flow/scripts/generate-variable-docs.py
- name: Run yamlfix
run: |
pip install yamlfix==1.17.0
yamlfix -c yamlfix.toml flow/scripts/variables.yaml
- name: Create branch if diff exists
id: docs-update
id: variables-update
run: |
git config --local user.email "github-actions[bot]@users.noreply.github.com"
git config --local user.name "github-actions[bot]"
Expand All @@ -43,15 +46,22 @@ jobs:
else
echo "has_update=false" >> "$GITHUB_OUTPUT"
fi
git add .
git add flow/scripts/variables.yaml
git add docs/user/FlowVariables.md
git commit --signoff -m "[Docs]: Update ORFS FlowVariables.md"
# Sanity check that no other files are unstaged
if [ -n "$(git status --porcelain)" ]; then
echo "Error: Unstaged changes after commit."
exit 1
fi
- name: Only push if not master
if: "github.event.client_payload.branch != 'master'"
id: remote-update-pr
id: variables-update-pr
run: |
git push origin "HEAD:refs/pull/${{ github.event.client_payload.branch }}/head"
- name: Create docs update PR
if: "steps.remote-update.outputs.has_update == 'true' && github.event.client_payload.branch == 'master'"
- name: Create variables update PR
if: "steps.variables-update.outputs.has_update == 'true' && github.event.client_payload.branch == 'master'"
uses: peter-evans/create-pull-request@v5
with:
token: ${{ github.token }}
Expand Down
37 changes: 0 additions & 37 deletions .yamllint

This file was deleted.

2 changes: 1 addition & 1 deletion etc/DependencyInstaller.sh
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ _installCommon() {
source /opt/rh/rh-python38/enable
set -u
fi
local pkgs="pandas numpy firebase_admin click pyyaml yamllint"
local pkgs="pandas numpy firebase_admin click pyyaml yamlfix"
if [[ $(id -u) == 0 ]]; then
pip3 install --no-cache-dir -U $pkgs
else
Expand Down
8 changes: 1 addition & 7 deletions flow/scripts/variables.yaml
Original file line number Diff line number Diff line change
@@ -1,29 +1,24 @@
---
# Prettified using: https://jsonformatter.org/yaml-formatter
# Run the command: yamlfix -c yamlfix.toml flow/scripts/variables.yaml
GENERATE_ARTIFACTS_ON_FAILURE:
description: >
For instance Bazel needs artifacts (.odb and .rpt files) on a failure to
allow the user to save hours on re-running the failed step locally, but when
working with a Makefile flow, it is more natural to fail the step and leave
the user to manually inspect the logs and artifacts directly via the file
system.
Set to 1 to change the behavior to generate artifacts upon failure to e.g.
do a global route. The exit code will still be non-zero on all other
failures that aren't covered by the "useful to inspect the artifacts on
failure" use-case.
Example: just like detailed routing, a global route that fails with
congestion, is not a build failure(as in exit code non-zero), it is a
successful(as in zero exit code) global route that produce reports detailing
the problem.
Detailed route will not proceed, if there is global routing congestion
This allows build systems, such as bazel, to create artifacts for global and
detailed route, even if the operation had problems, without having know
about the semantics between global and detailed route.
Considering that global and detailed route can run for a long time and use a
lot of memory, this allows inspecting results on a laptop for a build that
ran on a server.
Expand All @@ -32,7 +27,6 @@ TNS_END_PERCENT:
description: >
Default TNS_END_PERCENT value for post CTS timing repair. Try fixing all
violating endpoints by default (reduce to 5% for runtime).
Specifies how many percent of violating paths to fix [0-100]. Worst path
will always be fixed.
default: 100
Expand Down
11 changes: 11 additions & 0 deletions yamlfix.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
explicit_start = true
line_length = 120
preserve_quotes = true
quote_representation = "'"
section_whitelines = 0
sequence_style = "block_style"
comments_min_spaces_from_content = 2
allow_duplicate_keys = false
indent_mapping = 2
indent_offset = 2
indent_sequence = 4

0 comments on commit b64ab9e

Please sign in to comment.