Skip to content

Commit ca9de10

Browse files
Merge pull request #416 from erikdarlingdata/dev
Try to fix workflows
2 parents d4ea873 + 209de07 commit ca9de10

File tree

2 files changed

+33
-65
lines changed

2 files changed

+33
-65
lines changed

.github/workflows/TabsAndSpaces.yml

Lines changed: 0 additions & 61 deletions
This file was deleted.

.github/workflows/build-sqlfile.yml

Lines changed: 33 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Regenerate SQL Main File
1+
name: Format and Regenerate SQL Main File
22
on:
33
push:
44
branches:
@@ -10,18 +10,47 @@ jobs:
1010
runs-on: ubuntu-latest
1111
steps:
1212
- uses: actions/checkout@v3
13+
with:
14+
fetch-depth: 0
1315
- name: Checkout Code
1416
run: |
1517
git config --global user.name 'Darling Data'
1618
git config --global user.email 'erik@erikdarling.com'
1719
git checkout
20+
- name: Trim trailing whitespace and replace Tabs
21+
shell: pwsh
22+
run: |
23+
$changedFiles = git --no-pager diff --name-only --relative --diff-filter=AM "${{ github.event.before }}" "${{ github.sha }}" -- '***.sql'
24+
$tabSize = 4
25+
$changedFiles | ForEach-Object {
26+
$outputString = ""
27+
$fullPath = $_
28+
$Content = Get-Content $fullPath
29+
foreach ($Ctnt in $Content) {
30+
$CharArray = $Ctnt.ToCharArray()
31+
$lineOutput = ""
32+
$slidingOffset = 0
33+
for ($charIdx = 0; $charIdx -lt $CharArray.Length; $charIdx++) {
34+
if ($CharArray[$charIdx] -eq "`t") {
35+
$currentTab = $tabSize - (($charIdx + $slidingOffset) % $tabSize)
36+
$slidingOffset += $currentTab - 1
37+
$lineOutput += (" " * $currentTab)
38+
}
39+
else {
40+
$lineOutput += $CharArray[$charIdx]
41+
}
42+
}
43+
$outputString += $lineOutput.TrimEnd() + "`n" # Add line output with trailing spaces removed to the output string, and add newline
44+
}
45+
Set-Content -Path $fullPath -Value ($outputString.TrimEnd())
46+
}
1847
- name: Compile SQL File
1948
shell: pwsh
2049
run: |
2150
cd Install-All
2251
./Merge-All.ps1
2352
- name: Commit Updated File
2453
run: |
25-
git add ./Install-All/DarlingData.sql
26-
git commit -am "Automation: Building SQL File"
27-
git push
54+
git add .
55+
git commit -am "Automation: Format and Build SQL File"
56+
git push

0 commit comments

Comments
 (0)