Quantcast
Channel: The Battle for Wesnoth Forums
Viewing all articles
Browse latest Browse all 578

WML Workshop • Github Workflow Example

$
0
0
I set up a Github workflow for running WML tools on the repo of my custom era. I thought it could be interesting for some. Feel free to use and adapt it it if you think it's useful for you as well.

The tricky bits are:
  • I need the mainline Wesnoth repository, but that is huge and I only want the data directory, so I am using Git sparse checkout.
  • The WML tools should know about core data because my era references it.
  • I don't care about warnings about core data by the WML tools.
  • If the output is non-empty (after some filtering), that's an error.
  • I want to actually see the output in case of failures so I can fix it.
All of these were a bit tricky. My Github workflow solves them all, but it's a bit hacky, so if someone has more elegant ways, feel free to comment. See https://github.com/Tinend/Wesnoth-Era-o ... ws/wml.yml or also inline here:

Code:

name: WMLon: [push, pull_request]jobs:  lint:    runs-on: ubuntu-latest    steps:    - name: Check out the repository      uses: actions/checkout@v4    - name: Create temporary directory to check out wesnoth      run: |        echo "wesnoth_dir=$(mktemp -d)/wesnoth_repo" >> "$GITHUB_ENV"    - name: Clone the Wesnoth Github repository without checking it out.      run: |        git clone --filter=blob:none --no-checkout --depth 1 --sparse --branch 1.18 https://github.com/wesnoth/wesnoth.git "$wesnoth_dir"    - name: Set sparse checkout to only fetch the data/ directory      run: |        git -C "$wesnoth_dir" sparse-checkout set data    - name: Checkout branch 1.18      run: |        git -C "$wesnoth_dir" checkout    - name: Run wmllint and filter out findings from core and fail if the output is non-empty      run: |        wmllint_out=$(mktemp);        "$wesnoth_dir/data/tools/wmllint" -S -d "$wesnoth_dir/data/core" . 2>&1 | grep -v "wesnoth_repo" > "$wmllint_out" || true;        if [ -s "$wmllint_out"  ]; then { cat "$wmllint_out" ; false; } fi    - name: Run wmlindent and fail if the output is non-empty      run: |        wmlindent_out=$(mktemp);        "$wesnoth_dir/data/tools/wmlindent" -d . 2>&1 | cat > "$wmllindent_out" || true;        if [ -s "$wmlindent_out"  ]; then { cat "$wmlindent_out" ; false; } fi    - name: Run wmlscope and filter out findings from core and fail if the output is non-empty      run: |        wmlscope_out=$(mktemp);        "$wesnoth_dir/data/tools/wmlscope" "$wesnoth_dir/data/core" . 2>&1 | grep -v "wesnoth_repo" | grep -v "^#" > "$wmlscope_out" || true;        if [ -s "$wmlscope_out"  ]; then { cat "$wmlscope_out" ; false; } fi

Statistics: Posted by Civhai — Today, 12:13 pm



Viewing all articles
Browse latest Browse all 578

Trending Articles