Skip to content

Commit

Permalink
Add workflow to verify the changelog snippets (#6139)
Browse files Browse the repository at this point in the history
  • Loading branch information
Garanas committed Apr 30, 2024
1 parent 6544985 commit 3fa2d2a
Show file tree
Hide file tree
Showing 5 changed files with 105 additions and 7 deletions.
32 changes: 26 additions & 6 deletions .github/workflows/changelog.yaml
@@ -1,29 +1,49 @@
name: Create changelog

on:
on:
workflow_dispatch:
pull_request:
paths:
- "changelog/snippets/*.md"
push:

branches:
- deploy/fafdevelop

jobs:
verify:
name: Verify
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
sparse-checkout: |
changelog/snippets
- name: Verify the changelog snippets
working-directory: changelog/snippets # script assumes it is in this directory
run: |
./verify.sh
bundle:
name: Bundle
runs-on: ubuntu-latest
needs: [verify]
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
sparse-checkout: |
changelog/snippets
- name: Create the changelog
working-directory: changelog/snippets # script assumes it is in this directory
working-directory: changelog/snippets # script assumes it is in this directory
run: |
./combine.sh
- name: Add the changelog as an artifact
uses: actions/upload-artifact@v4
with:
name: changelog
path: |
changelog/snippets/changelog.md
11 changes: 10 additions & 1 deletion .github/workflows/test.yaml
@@ -1,6 +1,15 @@
name: Test

on: [push]
on:
workflow_dispatch:
pull_request:
push:
branches:
- deploy/fafdevelop
- deploy/faf
- deploy/fafbeta
- develop
- master

jobs:
syntax:
Expand Down
2 changes: 2 additions & 0 deletions changelog/snippets/other.6139.md
@@ -0,0 +1,2 @@
- (#6139, 6138, 6137) Generate the changelog based on changelog snippets

65 changes: 65 additions & 0 deletions changelog/snippets/verify.sh
@@ -0,0 +1,65 @@
#!/bin/bash

# -----------------------------------------------------------------------------
# Copyright (c) 2024 FAForever
#
# 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.
# -----------------------------------------------------------------------------

# -----------------------------------------------------------------------------
#region Verify that the script has everything it needs.

# The primary check is whether we launched the script from the correct
# directory. The active directory should always be '(...)/fa/changelog/snippets'

if ! ls *.md >/dev/null 2>&1; then
echo "No Markdown files found to verify. Are you looking in the wrong directory?"
exit 1
fi

#endregion

# -----------------------------------------------------------------------------
#region Verify the snippets whether they match the convention

# Function to process snippets file names
is_valid_filename() {
local filename="$1"

# Pattern to match: starts with 'fix', 'graphics', etc.,
# followed by a dot, then 1 to 5 digits, and ends with '.md'
if [[ "$filename" =~ ^(fix|graphics|performance|ai|features|other|performance|balance)\.[0-9]{1,5}\.md$ ]]; then
return 0
else
return 1
fi
}

for file in *.md; do
if is_valid_filename "$file"; then
echo " - Verified: $file"
else
echo "Invalid format: $file"
exit 1
fi
done

echo "All snippets are formatted correctly."

#endregion
2 changes: 2 additions & 0 deletions engine/moho.lua
Expand Up @@ -68,3 +68,5 @@ moho = {
WldUIProvider_methods = require("/engine/User/CLuaWldUIProvider.lua"),
world_mesh_methods = require("/engine/User/CUIWorldMesh.lua"),
}


0 comments on commit 3fa2d2a

Please sign in to comment.