Skip to content

Commit

Permalink
🚧Project and ci improvements (#112)
Browse files Browse the repository at this point in the history
* Start work for issue #111

* ci: rename workflows

* ci: improve workflows

* ide: simple ide improvements

* docs: move images folder

* docs: move release notes

* ide: update tab settings

* ci: update workflow command syntax & update reusable workflow versions
  • Loading branch information
CalvinWilkinson authored Jul 21, 2023
1 parent a22a203 commit a48c862
Show file tree
Hide file tree
Showing 34 changed files with 258 additions and 151 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/add-new-issue-to-project.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ on:
jobs:
add_new_issue_to_project:
name: Add New Issue
uses: KinsonDigital/Infrastructure/.github/workflows/add-issue-to-project.yml@v9.1.0
uses: KinsonDigital/Infrastructure/.github/workflows/add-issue-to-project.yml@v10.0.1
with:
org-name: "${{ vars.ORGANIZATION_NAME }}"
org-project-name: "${{ vars.ORG_PROJECT_NAME }}"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: ✅Build Status Check
run-name: ✅Build Status Check ${{ github.base_ref == 'main' && '(Release Build)' || '(Debug Build)' }}
run-name: ✅Build Status Check (${{ github.base_ref }} branch)


defaults:
Expand All @@ -8,25 +8,34 @@ defaults:


on:
workflow_dispatch:
pull_request:
branches: [main, preview]


jobs:
main_build_status_check:
name: ${{ vars.PROJECT_NAME }} Build Status Check
uses: KinsonDigital/Infrastructure/.github/workflows/build-csharp-project.yml@v9.1.0
name: Build ${{ vars.PROJECT_NAME }}
uses: KinsonDigital/Infrastructure/.github/workflows/build-csharp-project.yml@v10.0.1
with:
project-name: "${{ vars.PROJECT_NAME }}"
build-config: Debug
net-sdk-version: "${{ vars.NET_SDK_VERSION }}"


perf_build_status_check:
name: ${{ vars.PROJECT_NAME }} Perf Tests Build Status Check
uses: KinsonDigital/Infrastructure/.github/workflows/build-csharp-project.yml@v9.1.0
name: Build ${{ vars.PROJECT_NAME }}PerfTests
uses: KinsonDigital/Infrastructure/.github/workflows/build-csharp-project.yml@v10.0.1
with:
project-name: "${{ vars.PROJECT_NAME }}PerfTests"
build-config: Debug
net-sdk-version: "${{ vars.NET_SDK_VERSION }}"


build_status_check:
name: ${{ vars.PROJECT_NAME }} Build Status Check
needs: [main_build_status_check, perf_build_status_check]
runs-on: ubuntu-latest
steps:
- name: Print Status Check Pass Message
shell: pwsh
run: Write-Host "::notice::✅Test Status Check Passed✅";
81 changes: 81 additions & 0 deletions .github/workflows/prepare-release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
name: 🚁Prepare Release


defaults:
run:
shell: pwsh


on:
workflow_dispatch:
inputs:
release-type:
description: The type of release. Choose 'Preview' or 'Production'.
required: true
type: choice
options: [Preview, Production]
release-version:
required: true
description: The version of the release to prepare.
type: string


jobs:
print_validate_workflow:
name: Ptin & Validate Prepare Release Workflow
runs-on: ubuntu-latest
steps:
- name: Print Environment Variables
run: Get-ChildItem -Path Env:* | Sort-Object Name

- name: Validate Workflow Inputs
run: |
$releaseType = "${{ inputs.release-type }}".ToLower();
if (""${{ vars.PROJECT_NAME }}".Trim().ToLower() -eq "") {
Write-Host "::error::The 'PROJECT_NAME' org or repo variable be empty.";
exit 1;
}
if ($releaseType -eq "") {
Write-Host "::error::The 'release-type' workflow input cannot be empty.";
exit 1;
}
if ($releaseType -ne 'preview' -and $releaseType -ne 'roduction') {
Write-Host "::error::The release type input must be either 'Preview' or 'Production'.";
exit 1;
}
$releaseVersion = "${{ inputs.release-version }}".Trim().ToLower();
if ($releaseVersion -eq "") {
Write-Host "::error::The release version input cannot be empty.";
exit 1;
}
$prodVersionRegex = "v[0-9]+\.[0-9]+\.[0-9]+";
$prevVersionRegex = "v[0-9]+\.[0-9]+\.[0-9]+-preview\.[0-9]+";
# Verify that the version has valid syntax
if (($releaseVersion -match $prodVersionRegex) -or ($releaseVersion -match $prevVersionRegex)) {
Write-Host "::notice::The 'release-version' workflow input is valid.";
} else {
$versionSyntax = $releaseType == "production" ? "v#.#.#" : "v#.#.#-preview.#";
Write-Host "::error::The 'release-version' workflow input is not valid. Expected format: '$versionSyntax";
exit 1;
}
prepare_release:
name: Prepare ${{ inputs.release-type }} Release Of ${{ vars.PROJECT_NAME }}
uses: KinsonDigital/Infrastructure/.github/workflows/prepare-release.yml@v10.0.1
with:
project-name: ${{ vars.PROJECT_NAME }}
release-type: ${{ inputs.release-type }}
release-version: ${{ inputs.release-version }}
secrets:
cicd-pat: ${{ secrets.CICD_TOKEN }}
31 changes: 0 additions & 31 deletions .github/workflows/prev-release.yml

This file was deleted.

47 changes: 47 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
name: 🚀Release
run-name: ${{ vars.PROJECT_NAME }} ${{ inputs.release-type }} Release ${{ inputs.dry-run == true && '(Dry Run)' || '' }}


defaults:
run:
shell: pwsh


on:
workflow_dispatch:
inputs:
release-type:
description: The type of release. Choose 'Preview' or 'Production'.
required: true
type: choice
options: [Preview, Production]
dry-run:
description: Check to run the workflow without creating a release.
required: false
default: false
type: boolean


jobs:
run_release:
name: Performing ${{ inputs.release-type }} Release of ${{ vars.PROJECT_NAME }} (${{ inputs.release-type == 'Production' && 'Release' || 'Debug' }})
uses: KinsonDigital/Infrastructure/.github/workflows/dotnet-lib-release.yml@v10.0.1
with:
project-name: "${{ vars.PROJECT_NAME}}"
release-type: "${{ inputs.release-type }}"
run-branch: "${{ github.ref_name }}"
net-sdk-version: "${{ vars.NET_SDK_VERSION }}"
relative-release-notes-dir-path: "${{ vars.RELATIVE_RELEASE_NOTES_DIR_PATH }}"
release-notes-file-name-prefix: "${{ vars.RELEASE_NOTES_FILE_NAME_PREFIX }}"
build-config: ${{ inputs.release-type == 'Production' && 'Release' || 'Debug' }}
pr-include-notes-label: "${{ vars.PR_INCLUDE_NOTES_LABEL }}"
send-release-tweet: ${{ vars.TWITTER_BROADCAST_ENABLED == 'true' }}
dry-run: ${{ inputs.dry-run }}
transpile-readme: true
secrets:
cicd-pat: "${{ secrets.CICD_TOKEN }}"
nuget-org-api-key: "${{ secrets.NUGET_ORG_API_KEY }}"
twitter-consumer-api-key: "${{ secrets.TWITTER_CONSUMER_API_KEY }}"
twitter-consumer-api-secret: "${{ secrets.TWITTER_CONSUMER_API_SECRET }}"
twitter-access-token: "${{ secrets.TWITTER_ACCESS_TOKEN }}"
twitter-access-token-secret: "${{ secrets.TWITTER_ACCESS_TOKEN_SECRET }}"
10 changes: 6 additions & 4 deletions .github/workflows/sonar-scan-pr-status-check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,11 @@ jobs:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
run: |
./.sonar/scanner/dotnet-sonarscanner begin /k:"KinsonDigital_Carbonate" /o:"kinsondigital" /d:sonar.login="${{ secrets.SONAR_TOKEN }}" /d:sonar.host.url="https://sonarcloud.io"
$orgNameLower = "${{ vars.ORGANIZATION_NAME }}".ToLower();
dotnet clean "${{ github.workspace }}/Carbonate/Carbonate.csproj";
dotnet build "${{ github.workspace }}/Carbonate/Carbonate.csproj" -c Debug;
./.sonar/scanner/dotnet-sonarscanner begin -k:"${{ vars.ORGANIZATION_NAME }}_${{ vars.PROJECT_NAME }}" -o:"$orgNameLower" -d:sonar.login="${{ secrets.SONAR_TOKEN }}" -d:sonar.host.url="https://sonarcloud.io"
./.sonar/scanner/dotnet-sonarscanner end /d:sonar.login="${{ secrets.SONAR_TOKEN }}"
dotnet clean "${{ github.workspace }}/${{ vars.PROJECT_NAME }}/${{ vars.PROJECT_NAME }}.csproj";
dotnet build "${{ github.workspace }}/${{ vars.PROJECT_NAME }}/${{ vars.PROJECT_NAME }}.csproj" -c Debug;
./.sonar/scanner/dotnet-sonarscanner end -d:sonar.login="${{ secrets.SONAR_TOKEN }}"
17 changes: 10 additions & 7 deletions .github/workflows/sync-bot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,18 @@ on:

jobs:
sync_bot:
name: Sync Bot
name: Sync Bot Status Check
if: ${{ !github.event.issue.pull_request }}
runs-on: ubuntu-latest
steps:
- name: Set Up Deno
if: startsWith(github.ref_name, 'feature/')
uses: denoland/setup-deno@v1
with:
deno-version: v1.x

- name: Run Sync Bot (Issue Change)
if: startsWith(github.ref_name, 'feature/')
run: |
$scriptUrl = "${{ vars.SCRIPT_BASE_URL }}/${{ vars.CICD_SCRIPTS_VERSION }}/${{ vars.SCRIPT_RELATIVE_DIR_PATH}}/sync-bot-status-check.ts";
Expand All @@ -32,20 +34,21 @@ jobs:
Write-Host "::notice::Issue: $issueNumber";
if ($manuallyExecuted -and $issueNumber -eq "0") {
Write-Host "::error::The issue or PR number must be a value greater than 0.";
Write-Host "::notice::The issue or PR number must be a value greater than 0.";
exit 1;
}
<# Deno Args:
1. Project name
2. Issue number
3. Event type - set to issue event type
4. PAT
1. Organization name
2. Project name
3. Issue number
4. Event Type - set to issue event type
5. PAT
#>
deno run `
--allow-net `
"$scriptUrl" `
"${{ vars.PROJECT_NAME }}" `
"$issueNumber" `
"issue" `
"cicd-pat: ${{ secrets.CICD_TOKEN }}";
"${{ secrets.CICD_TOKEN }}";
20 changes: 8 additions & 12 deletions .github/workflows/sync-issue-to-pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:
sync_issue_to_pr:
name: Start Sync Process
if: |
github.event_name == 'issue_comment' ||
(github.event_name == 'issue_comment' && contains(github.event.comment.body, '[run-sync]')) ||
github.event_name == 'pull_request' && startsWith(github.head_ref, 'feature/')
runs-on: ubuntu-latest
steps:
Expand All @@ -30,30 +30,26 @@ jobs:
run: |
$eventName = "${{ github.event_name }}";
$scriptUrl = "${{ vars.SCRIPT_BASE_URL }}/${{ vars.CICD_SCRIPTS_VERSION }}/${{ vars.SCRIPT_RELATIVE_DIR_PATH }}/sync-issue-to-pr.ts";
$prNumber = $eventName -eq "pull_request" ? "${{ github.event.number }}" : "${{ github.event.issue.number }}";
$command = $eventName -eq "issue_comment" ? "${{ github.event.comment.body }}" : "[initial-sync]";
$issueOrPrNumber = $eventName -eq "pull_request" ? "${{ github.event.number }}" : "${{ github.event.issue.number }}";
Write-Host "::notice::Event Name: $eventName";
Write-Host "::notice::Event Type: $eventName";
Write-Host "::notice::Organization Name: ${{ vars.ORGANIZATION_NAME }}";
Write-Host "::notice::Project Name: ${{ vars.PROJECT_NAME }}";
Write-Host "::notice::Requested By: ${{ github.event.sender.login }}";
Write-Host "::notice::PR Number: $prNumber";
Write-Host "::notice::Comment: $command";
Write-Host "::notice::PR Number: $issueOrPrNumber";
<# Deno Args:
1. Organization name
2. Project name
3. Login name of the user making the issue change
4. Pull request number
5. The sync command - Either '[initial-sync]' or '[run-sync]'
6. PAT
3. Triggered by user
4. Issue or pull request number
5. PAT
#>
deno run `
--allow-net `
"$scriptUrl" `
"${{ vars.ORGANIZATION_NAME }}" `
"${{ vars.PROJECT_NAME }}" `
"${{ github.event.sender.login }}" `
"$prNumber" `
"$command" `
"$issueOrPrNumber" `
"${{ secrets.CICD_TOKEN }}";
12 changes: 7 additions & 5 deletions .github/workflows/sync-status-check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,19 +32,21 @@ jobs:
Write-Host "::notice::Event Type: pr";
if ($manuallyExecuted -and $prNumber -eq "0") {
Write-Host "::error::The issue or PR number must be a value greater than 0.";
Write-Host "::notice::The issue or PR number must be a value greater than 0.";
exit 1;
}
<# Deno Args:
1. Project Name
2. Pull request number
3. Event Type - set to pull request event type
4. PAT
1. Organization name
2. Project name
3. Pull request number
4. Event Type - set to pull request event type
5. PAT
#>
deno run `
--allow-net `
"$scriptUrl" `
"${{ vars.ORGANIZATION_NAME }}" `
"${{ vars.PROJECT_NAME }}" `
"$prNumber" `
"pr" `
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: ✅Testing Status Check
run-name: ✅Testing Status Check ${{ github.base_ref == 'main' && '(Release Build)' || '(Debug Build)' }}
run-name: Unit Testing Status Check (${{ github.base_ref }} branch)


defaults:
Expand All @@ -13,19 +13,29 @@ on:


jobs:
run_unit_tests:
name: ${{ vars.PROJECT_NAME }} Unit Tests Status Check
uses: KinsonDigital/Infrastructure/.github/workflows/run-csharp-tests.yml@v9.1.0
main_tests:
name: Run ${{ vars.PROJECT_NAME }} Tests
uses: KinsonDigital/Infrastructure/.github/workflows/run-csharp-tests.yml@v10.0.1
with:
project-name: "${{ vars.PROJECT_NAME }}Tests"
build-config: Debug
net-sdk-version: "${{ vars.NET_SDK_VERSION }}"


run_integration_tests:
name: ${{ vars.PROJECT_NAME }} Integration Tests Status Check
uses: KinsonDigital/Infrastructure/.github/workflows/run-csharp-tests.yml@v9.1.0
integration_tests:
name: Run ${{ vars.PROJECT_NAME }} Integration Tests
uses: KinsonDigital/Infrastructure/.github/workflows/run-csharp-tests.yml@v10.0.1
with:
project-name: "${{ vars.PROJECT_NAME }}IntegrationTests"
build-config: Debug
net-sdk-version: "${{ vars.NET_SDK_VERSION }}"


test_status_check:
name: ${{ vars.PROJECT_NAME }} Test Status Check
needs: [main_tests, integration_tests]
runs-on: ubuntu-latest
steps:
- name: Print Status Check Pass Message
shell: pwsh
run: Write-Host "::notice::✅Test Status Check Passed✅";
Loading

0 comments on commit a48c862

Please sign in to comment.