Skip to content

This adds a commit message checker, which should fail on this commit … #118

This adds a commit message checker, which should fail on this commit …

This adds a commit message checker, which should fail on this commit … #118

Workflow file for this run

name: Flex CI
on:
push:
branches: ["release/9.1", "develop", "master", "feature/PubSub"]
pull_request:
branches: ["release/9.1", "develop", "master", "feature/PubSub"]
workflow_dispatch:
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true
jobs:
debug_build_and_test:
env:
CROWDIN_API_KEY: ${{ secrets.FLEX_CROWDIN_API }}
name: Build Debug and run Tests
runs-on: windows-latest
steps:
- name: Checkout Files
uses: actions/checkout@v4
id: checkout
- name: Check commit message
shell: bash
run: |
# This script checks that the commit message is formatted according to the standard:
# - First line: no more than 62 chars and not ending with period (or if it is the
# only line: no more than 70 chars)
# - Second line: empty
# - Following lines: no more than 70 chars
# Run git log command and capture its output
log_output=$(git log --pretty=format:"---commit---%n%H%n%B" ${{ github.event.pull_request.base.sha }}..)
# Define states
STATE_INITIAL="INITIAL"
STATE_HASH="HASH"
STATE_FIRST="FIRST"
STATE_LONG_FIRST="LONG_FIRST"
STATE_SECOND="SECOND"
STATE_OTHER="OTHER"
# Initialize variables
state="$STATE_INITIAL"
commit_hash=""
# Function to reset state to Hash
reset_state() {
state="$STATE_HASH"
commit_hash=""
}
# Iterate through the log results
while IFS= read -r log_line; do
case "$state" in
"$STATE_INITIAL")
# Move to Hash state
if [[ "$log_line" == "---commit---" ]]; then
state="$STATE_HASH"
fi
;;
"$STATE_HASH")
# Capture commit hash and move to First state
commit_hash="$log_line"
state="$STATE_FIRST"
;;
"$STATE_FIRST")
# Check first line length and punctuation, move to Second state
if [[ ${#log_line} -gt 70 ]]; then
echo "::warning ⚠️ First line was too long in $commit_hash"
break
elif [[ "$log_line" == *"." ]]; then
echo "::error The first line should not end in a period in $commit_hash"
break
elif [[ ${#log_line} -gt 62 ]]; then
state="$STATE_LONG_FIRST"
else
state="$STATE_SECOND"
fi
;;
"$STATE_LONG_FIRST")
# Check second line and move to Other state
if [[ "$log_line" == "---commit---" ]]; then
reset_state
else
echo "::warning ⚠️ First line should be less than 60 chars if there is more than one line. $commit_hash"
break
fi
;;
"$STATE_SECOND")
# Check second line and move to Other state
if [[ -n "$log_line" ]]; then
echo "::error Second line is not blank in commit $commit_hash"
exit 1
fi
state="$STATE_OTHER"
;;
"$STATE_OTHER")
# Check other lines length and move to Other state or reset to Hash state
if [[ ${#log_line} -gt 70 ]]; then
echo "::warning ⚠️ Line exceeds 70 characters in commit $commit_hash"
break
elif [[ "$log_line" == "---commit---" ]]; then
reset_state
fi
;;
esac
done
- name: Download 461 targeting pack
uses: suisei-cn/actions-download-file@818d6b7dc8fe73f2f924b6241f2b1134ca1377d9 # 1.6.0
id: downloadfile # Remember to give an ID if you need the output filename
with:
url: "https://download.microsoft.com/download/F/1/D/F1DEB8DB-D277-4EF9-9F48-3A65D4D8F965/NDP461-DevPack-KB3105179-ENU.exe"
target: public/
- name: Install targeting pack
shell: cmd
working-directory: public
run: NDP461-DevPack-KB3105179-ENU.exe /q
- name: Setup dotnet
uses: actions/setup-dotnet@v3
with:
dotnet-version: |
2.1.x
3.1.x
5.0.x
- name: Prepare for build
shell: cmd
working-directory: Build
run: build64.bat /t:WriteNonlocalDevelopmentPropertiesFile
- name: Build Debug and run tests
id: build_and_test
shell: powershell
run: |
cd Build
.\build64.bat /t:remakefw-jenkins /p:action=test /p:desktopNotAvailable=true ^| tee-object -FilePath build.log
- name: Scan Debug Build Output
shell: powershell
working-directory: Build
run: |
$results = Select-String -Path "build.log" -Pattern "^\s*[1-9][0-9]* Error\(s\)"
if ($results) {
foreach ($result in $results) {
Write-Host "Found errors in build.log $($result.LineNumber): $($result.Line)" -ForegroundColor red
}
exit 1
} else {
Write-Host "No errors found" -ForegroundColor green
exit 0
}
- name: Capture Test Results
shell: powershell
working-directory: Build
run: .\NUnitReport /a ^| tee-object -FilePath test-results.log
- name: Report Test Results
uses: sillsdev/[email protected]
with:
log-path: Build/test-results.log
token: ${{ secrets.GITHUB_TOKEN }}
- uses: actions/upload-artifact@v4
with:
name: build-logs
path: Build/*.log