Skip to content

Commit

Permalink
CICD: use shell scripts for core operations
Browse files Browse the repository at this point in the history
  • Loading branch information
swharden committed Apr 13, 2024
1 parent 763fc40 commit 2c686b2
Show file tree
Hide file tree
Showing 10 changed files with 91 additions and 90 deletions.
60 changes: 18 additions & 42 deletions .github/workflows/pr1.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,50 +8,26 @@ on:
pull_request:

jobs:
evaluate:
name: Evaluate Changes
quick:
name: Quick Test
runs-on: ubuntu-latest
outputs:
MOD_SP4: ${{ steps.set-vars.outputs.MOD_SP4 }}
MOD_SP5: ${{ steps.set-vars.outputs.MOD_SP5 }}
permissions:
security-events: write
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup CodeQL
uses: github/codeql-action/init@v3
with:
fetch-depth: "0" # all branches
- name: Evaluate changed files in PR
run: |
git diff ${{ github.event.pull_request.base.sha }} ${{ github.event.pull_request.head.sha }} --name-only
git diff ${{ github.event.pull_request.base.sha }} ${{ github.event.pull_request.head.sha }} --name-only > changed.txt
- name: Identify affected versions
run: |
sed -n '/src\/ScottPlot4/p' changed.txt
sed -n '/src\/ScottPlot4/p' changed.txt > changed4.txt
sed -n '/src\/ScottPlot5/p' changed.txt
sed -n '/src\/ScottPlot5/p' changed.txt > changed5.txt
find . -type f -name "changed*.txt" -empty -delete
- name: Set workflow variables
id: set-vars
run: |
echo "MOD_SP4=$( [[ -f changed4.txt ]] && echo true || echo false )" >> $GITHUB_OUTPUT
echo "MOD_SP5=$( [[ -f changed5.txt ]] && echo true || echo false )" >> $GITHUB_OUTPUT
- name: ScottPlot4 Changed (${{ steps.set-vars.outputs.MOD_SP4 }})
if: ${{ steps.set-vars.outputs.MOD_SP4 == 'true' }}
run: echo sp4 changed
- name: ScottPlot5 Changed (${{ steps.set-vars.outputs.MOD_SP5 }})
if: ${{ steps.set-vars.outputs.MOD_SP5 == 'true' }}
run: echo sp5 changed

sp4-check:
needs: evaluate
if: needs.evaluate.outputs.MOD_SP4 == 'true' || github.event_name == 'workflow_dispatch'
uses: ./.github/workflows/task-sp4-check.yaml
permissions:
security-events: write

sp5-check:
needs: evaluate
if: needs.evaluate.outputs.MOD_SP5 == 'true' || github.event_name == 'workflow_dispatch'
uses: ./.github/workflows/task-sp5-check.yaml
permissions:
security-events: write
languages: csharp
build-mode: manual
- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: 8.0.x
- name: Build
run: .github/workflows/scripts/check-build.sh
- name: Test
run: .github/workflows/scripts/check-test.sh
- name: Security Scan
uses: github/codeql-action/analyze@v3
78 changes: 30 additions & 48 deletions .github/workflows/pr2.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,55 +13,37 @@ concurrency:
cancel-in-progress: true

jobs:
evaluate:
name: Evaluate Changes
runs-on: ubuntu-latest
outputs:
MOD_SP4: ${{ steps.set-vars.outputs.MOD_SP4 }}
MOD_SP5: ${{ steps.set-vars.outputs.MOD_SP5 }}
autoformat:
uses: ./.github/workflows/task-autoformat-check.yaml
full:
name: Full Build
runs-on: windows-latest
permissions:
security-events: write
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup CodeQL
uses: github/codeql-action/init@v3
with:
fetch-depth: "0" # all branches
- name: Evaluate changed files in PR
run: |
git diff ${{ github.event.pull_request.base.sha }} ${{ github.event.pull_request.head.sha }} --name-only
git diff ${{ github.event.pull_request.base.sha }} ${{ github.event.pull_request.head.sha }} --name-only > changed.txt
- name: Identify affected versions
run: |
sed -n '/src\/ScottPlot4/p' changed.txt
sed -n '/src\/ScottPlot4/p' changed.txt > changed4.txt
sed -n '/src\/ScottPlot5/p' changed.txt
sed -n '/src\/ScottPlot5/p' changed.txt > changed5.txt
find . -type f -name "changed*.txt" -empty -delete
- name: Set workflow variables
id: set-vars
run: |
echo "MOD_SP4=$( [[ -f changed4.txt ]] && echo true || echo false )" >> $GITHUB_OUTPUT
echo "MOD_SP5=$( [[ -f changed5.txt ]] && echo true || echo false )" >> $GITHUB_OUTPUT
- name: ScottPlot4 Changed (${{ steps.set-vars.outputs.MOD_SP4 }})
if: ${{ steps.set-vars.outputs.MOD_SP4 == 'true' }}
run: echo sp4 changed
- name: ScottPlot5 Changed (${{ steps.set-vars.outputs.MOD_SP5 }})
if: ${{ steps.set-vars.outputs.MOD_SP5 == 'true' }}
run: echo sp5 changed

sp4-full:
needs: evaluate
if: needs.evaluate.outputs.MOD_SP4 == 'true' || github.event_name == 'workflow_dispatch'
uses: ./.github/workflows/task-sp4-full-build.yaml
permissions:
security-events: write

sp5-full:
needs: evaluate
if: needs.evaluate.outputs.MOD_SP5 == 'true' || github.event_name == 'workflow_dispatch'
uses: ./.github/workflows/task-sp5-full-build.yaml
permissions:
security-events: write

autoformat-check:
needs: evaluate
if: needs.evaluate.outputs.MOD_SP5 == 'true' || github.event_name == 'workflow_dispatch'
uses: ./.github/workflows/task-autoformat-check.yaml
languages: csharp
build-mode: manual
- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: 8.0.x
- name: Setup MSBuild
uses: microsoft/setup-msbuild@v2
- name: Setup Java
uses: actions/setup-java@v4
with:
distribution: "microsoft"
java-version: "17"
- name: Setup
run: .github/workflows/scripts/full-setup.bat
- name: Build
run: .github/workflows/scripts/full-build.bat
- name: Test
run: .github/workflows/scripts/full-test.bat
- name: Security Scan
uses: github/codeql-action/analyze@v3
1 change: 1 addition & 0 deletions .github/workflows/scripts/autoformat-check.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
echo check and warn of formatting errors
1 change: 1 addition & 0 deletions .github/workflows/scripts/autoformat-fix.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
echo check and fix formatting
11 changes: 11 additions & 0 deletions .github/workflows/scripts/check-build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/bin/bash

while IFS=$'\n' read -r line; do
time1=$(date +%s)
echo "Building: $line"
dotnet restore "$line"
dotnet build "$line" --configuration Release /p:TargetFrameworks="net8.0"
time2=$(date +%s)
elapsed=$((time2 - time1))
echo "$line built in $elapsed seconds"
done <".github/workflows/scripts/check-projects.txt"
5 changes: 5 additions & 0 deletions .github/workflows/scripts/check-projects.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
src/ScottPlot5/ScottPlot5/ScottPlot.csproj
src/ScottPlot5/ScottPlot5 Tests/ScottPlot Tests.csproj
src/ScottPlot5/ScottPlot5 Cookbook/ScottPlot Cookbook.csproj
src/ScottPlot5/ScottPlot5 Demos/ScottPlot5 WinForms Demo/WinForms Demo.csproj
src/ScottPlot4/ScottPlot/ScottPlot.csproj
7 changes: 7 additions & 0 deletions .github/workflows/scripts/check-test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/bin/bash

.github/workflows/scripts/check-files.sh

for filepath in "${project_files[@]}"; do
dotnet test "$filepath" --configuration Release --no-build --verbosity minimal
done
7 changes: 7 additions & 0 deletions .github/workflows/scripts/full-build.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
:: ScottPlot5
dotnet restore "src\ScottPlot4\ScottPlot5.sln"
dotnet build "src\ScottPlot4\ScottPlot5.sln" --configuration Release

:: ScottPlot4
dotnet restore "src\ScottPlot4\ScottPlot4.sln"
dotnet build "src\ScottPlot4\ScottPlot4.sln" --configuration Release
6 changes: 6 additions & 0 deletions .github/workflows/scripts/full-setup.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
:: ScottPlot5
dotnet workload install maui-android maui-ios maccatalyst wasm-tools
dotnet workload restore "src\ScottPlot5\ScottPlot5.sln"

:: ScottPlot4
dotnet workload restore "src\ScottPlot4\ScottPlot4.sln"
5 changes: 5 additions & 0 deletions .github/workflows/scripts/full-test.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
:: ScottPlot5
dotnet test "src\ScottPlot5\ScottPlot5.sln" --configuration Release --no-build --verbosity minimal

:: ScottPlot4
dotnet test "src\ScottPlot5\ScottPlot4.sln" --configuration Release --no-build --verbosity minimal

0 comments on commit 2c686b2

Please sign in to comment.