Improve balance snippet documentation #53
This file contains hidden or 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
| # Copyright (c) 2024 Daniel 'Zjonn' Dubiel | |
| # | |
| # Permission is hereby granted, free of charge, to any person obtaining a copy | |
| # of this software and associated documentation files (the "Software"), to deal | |
| # in the Software without restriction, including without limitation the rights | |
| # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | |
| # copies of the Software, and to permit persons to whom the Software is | |
| # furnished to do so, subject to the following conditions: | |
| # | |
| # The above copyright notice and this permission notice shall be included in all | |
| # copies or substantial portions of the Software. | |
| # | |
| # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | |
| # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | |
| # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | |
| # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | |
| # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | |
| # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | |
| # SOFTWARE. | |
| name: Convert Markdown changelog to Lua | |
| on: | |
| push: | |
| paths: ["docs/_posts/**", ".github/workflows/scripts/python/**"] | |
| workflow_call: | |
| inputs: | |
| artifact: | |
| type: string # fafdevelop or fafbeta | |
| description: The reference (branch or tag) to use to compile the changelog snippets from | |
| jobs: | |
| convert_changelog: | |
| name: Convert changelog | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Set environment variable | |
| run: | | |
| echo "SCRIPTS=.github/workflows/scripts/python" >> $GITHUB_ENV | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| with: | |
| ssh-key: ${{ secrets.SSH_FAFOREVER_MACHINE_USER }} | |
| - name: Download develop artifact | |
| if: inputs.artifact == 'fafdevelop' | |
| uses: actions/download-artifact@v4 | |
| with: | |
| name: changelog-fafdevelop | |
| path: docs/_posts | |
| merge-multiple: true | |
| - name: Download balance artifact | |
| if: inputs.artifact == 'fafbeta' | |
| uses: actions/download-artifact@v4 | |
| with: | |
| name: changelog-fafbeta | |
| path: docs/_posts | |
| merge-multiple: true | |
| - name: Setup python | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: '3.8' | |
| - name: Install dependencies | |
| run: | | |
| python -m pip install --upgrade pip | |
| pip install -r $SCRIPTS/requirements.txt | |
| - name: Convert changelog to Lua | |
| run: | | |
| rm lua/ui/lobby/changelog/generated/* | |
| out_dir=lua/ui/lobby/changelog/generated | |
| python3 $SCRIPTS/changelog_markdown2lua.py "docs/_posts" "${out_dir}" | |
| - name: Create changelog overview in Lua | |
| run: | | |
| out_dir=lua/ui/lobby/changelog/generated | |
| python3 $SCRIPTS/changelog_overview.py "docs/_posts" "${out_dir}/overview.lua" | |
| - name: Commit the generated files | |
| continue-on-error: true # there might be nothing to commit | |
| run: | | |
| # Configure git | |
| git config user.email "github@faforever.com" | |
| git config user.name "FAForever Machine User" | |
| git add . | |
| git commit -m "Update lobby changelogs" | |
| git push | |
| - name: Add the Lua changelog as an artifact | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: lua_changelog | |
| path: | | |
| lua/ui/lobby/changelog/generated | |
| # It's a bit awkward to validate after committing, but doing it in a unified | |
| # pipeline would either require making all other steps work in this container | |
| # or manually installing https://github.com/FAForever/lua-lang and I don't want | |
| # to do either of those. | |
| # The failing CI should still alert the user that something went wrong. | |
| validate_lua_changelog: | |
| name: Validate Lua changelog | |
| runs-on: ubuntu-latest | |
| container: faforever/lua:v5.0-1 | |
| needs: convert_changelog | |
| steps: | |
| - name: Install tooling | |
| run: | | |
| apk add bash git findutils | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| with: | |
| sparse-checkout: | | |
| tests/run-syntax-test.sh | |
| - name: Download the Lua changelog artifact | |
| uses: actions/download-artifact@v4 | |
| with: | |
| name: lua_changelog | |
| - name: Validate changelog files | |
| run: | | |
| ./tests/run-syntax-test.sh |