Skip to content

Commit

Permalink
Added extra step in workflow to set DIS_PATH environment variable
Browse files Browse the repository at this point in the history
  • Loading branch information
ArneMaes0 committed Jun 11, 2024
1 parent b3ba8f0 commit bbe789e
Show file tree
Hide file tree
Showing 4 changed files with 285 additions and 16 deletions.
301 changes: 285 additions & 16 deletions .github/workflows/DataMiner+CI+Automation.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,289 @@ on:
push:
branches: []
tags:
- '[0-9]+.[0-9]+.[0-9]+.[0-9]+'
- '[0-9]+.[0-9]+.[0-9]+.[0-9]+-[0-9a-zA-Z]+'
workflow_dispatch:
- "[0-9]+.[0-9]+.[0-9]+.[0-9]+"
- "[0-9]+.[0-9]+.[0-9]+.[0-9]+-[0-9a-zA-Z]+"
workflow_dispatch: null
jobs:
CI:
name: CI
uses: SkylineCommunications/_ReusableWorkflows/.github/workflows/Automation Master Workflow.yml@main
with:
referenceName: ${{ github.ref_name }}
runNumber: ${{ github.run_number }}
referenceType: ${{ github.ref_type }}
repository: ${{ github.repository }}
owner: ${{ github.repository_owner }}
sonarCloudProjectName: SkylineCommunications_SLC-DISMACRO-Script-Context
secrets:
api-key: ${{ secrets.DATAMINER_DEPLOY_KEY }}
sonarCloudToken: ${{ secrets.SONAR_TOKEN }}
validate_skyline_quality_gate:
name: SDK Skyline Quality Gate
runs-on: windows-latest
env:
detected-unit-tests: none
outputs:
quality: ${{ steps.quality-step.outputs.results }}
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Initialize
run: |
echo "workspace" ${{ github.workspace }}
echo "ref name" ${{ github.ref_name }}
echo "run number" ${{ github.run_number }}
echo "ref type" ${{ github.ref_type }}
echo "repository" ${{ github.repository }}
- name: Set up JDK 17
uses: actions/setup-java@v4
with:
java-version: 17
distribution: zulu
- name: Find .sln file
id: findSlnFile
run: >
echo solutionFilePath=$(find . -type f -name '*.sln') >> $GITHUB_OUTPUT
shell: bash
- name: Enable Skyline GitHub NuGet Registry
if: github.repository_owner == 'SkylineCommunications'
run: dotnet nuget add source
"https://nuget.pkg.github.com/SkylineCommunications/index.json"
--username USERNAME --password ${{ secrets.GITHUB_TOKEN }}
- name: Enable Skyline Azure Cloud NuGet Registry
env:
AZURE_TOKEN_EXISTS: ${{ secrets.azureToken }}
if: env.AZURE_TOKEN_EXISTS != null && github.repository_owner ==
'SkylineCommunications'
run: >
$SOURCE_NAME="CloudNuGets"
$SOURCE_URL="https://pkgs.dev.azure.com/skyline-cloud/Cloud_NuGets/_packaging/CloudNuGet/nuget/v3/index.json"
# Check if the source exists. If it does, update it.
if (dotnet nuget list source | Select-String -Pattern $SOURCE_NAME) {
Write-Host "Updating existing source $SOURCE_NAME."
dotnet nuget update source $SOURCE_NAME --source $SOURCE_URL --username az --password ${{ secrets.azureToken }} --store-password-in-clear-text
} else {
Write-Host "Adding new source $SOURCE_NAME."
dotnet nuget add source $SOURCE_URL --name $SOURCE_NAME --username az --password ${{ secrets.azureToken }} --store-password-in-clear-text
}
- name: Enable Skyline Azure Private NuGet Registry
env:
AZURE_TOKEN_EXISTS: ${{ secrets.azureToken }}
if: env.AZURE_TOKEN_EXISTS != null && github.repository_owner ==
'SkylineCommunications'
run: >
$SOURCE_NAME="PrivateAzureNuGets"
$SOURCE_URL="https://pkgs.dev.azure.com/skyline-cloud/_packaging/skyline-private-nugets/nuget/v3/index.json"
# Check if the source exists. If it does, update it.
if (dotnet nuget list source | Select-String -Pattern $SOURCE_NAME) {
Write-Host "Updating existing source $SOURCE_NAME."
dotnet nuget update source $SOURCE_NAME --source $SOURCE_URL --username az --password ${{ secrets.azureToken }} --store-password-in-clear-text
} else {
Write-Host "Adding new source $SOURCE_NAME."
dotnet nuget add source $SOURCE_URL --name $SOURCE_NAME --username az --password ${{ secrets.azureToken }} --store-password-in-clear-text
}
- name: Set DIS_PATH environment variable
run: echo "DIS_PATH=${{ github.workspace }}\\Dlls\\DIS" >> $GITHUB_ENV
shell: bash
- name: Building
run: dotnet build "${{ steps.findSlnFile.outputs.solutionFilePath }}"
-p:DefineConstants="DCFv1%3BDBInfo%3BALARM_SQUASHING" --configuration
Release -nodeReuse:false
- name: Unit Tests
id: unit-tests
run: dotnet test "${{ steps.findSlnFile.outputs.solutionFilePath }}" --filter
TestCategory!=IntegrationTest --logger
"trx;logfilename=unitTestResults.trx" --collect "XPlat Code Coverage"
--
DataCollectionRunSettings.DataCollectors.DataCollector.Configuration.Format=cobertura,opencover
continue-on-error: true
- name: Install SonarCloud scanner
run: |
dotnet tool install dotnet-sonarscanner --global
- name: Prepare SonarCloud Variables
id: prepSonarCloudVar
run: >
import os
env_file = os.getenv('GITHUB_ENV')
with open(env_file, "a") as myfile:
myfile.write("lowerCaseOwner=" + str.lower("${{ github.repository_owner }}"))
shell: python
- name: Get SonarCloud Status
id: get-sonarcloud-status
run: >
echo "sonarCloudProjectStatus=$(curl https://${{ secrets.sonarCloudToken
}}@sonarcloud.io/api/qualitygates/project_status?projectKey=SkylineCommunications_SLC-DISMACRO-Script-Context)"
>> $env:GITHUB_OUTPUT
continue-on-error: true
- name: Trigger Initial Analysis
if: fromJson(steps.get-sonarcloud-status.outputs.sonarCloudProjectStatus).projectStatus.status ==
'NONE'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SONAR_TOKEN: ${{ secrets.sonarCloudToken }}
run: >
dotnet sonarscanner begin
/k:"SkylineCommunications_SLC-DISMACRO-Script-Context" /o:"${{
env.lowerCaseOwner }}" /d:sonar.token="${{ secrets.sonarCloudToken }}"
/d:sonar.host.url="https://sonarcloud.io"
/d:sonar.cs.opencover.reportsPaths="**/TestResults/**/coverage.opencover.xml"
/d:sonar.cs.vstest.reportsPaths="**/TestResults/**.trx"
dotnet build "${{ steps.findSlnFile.outputs.solutionFilePath }}" -p:DefineConstants="DCFv1%3BDBInfo%3BALARM_SQUASHING" --configuration Release -nodeReuse:false
dotnet sonarscanner end /d:sonar.token="${{ secrets.sonarCloudToken }}"
continue-on-error: true
- name: Analyze
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SONAR_TOKEN: ${{ secrets.sonarCloudToken }}
run: >
dotnet sonarscanner begin
/k:"SkylineCommunications_SLC-DISMACRO-Script-Context" /o:"${{
env.lowerCaseOwner }}" /d:sonar.token="${{ secrets.sonarCloudToken }}"
/d:sonar.host.url="https://sonarcloud.io"
/d:sonar.cs.opencover.reportsPaths="**/TestResults/**/coverage.opencover.xml"
/d:sonar.cs.vstest.reportsPaths="**/TestResults/**.trx"
dotnet build "${{ steps.findSlnFile.outputs.solutionFilePath }}" -p:DefineConstants="DCFv1%3BDBInfo%3BALARM_SQUASHING" --configuration Release -nodeReuse:false
dotnet sonarscanner end /d:sonar.token="${{ secrets.sonarCloudToken }}"
continue-on-error: true
- name: SonarCloud Quality Gate check
id: sonarcloud-quality-gate-check
uses: sonarsource/sonarqube-quality-gate-action@master
with:
scanMetadataReportFile: .sonarqube/out/.sonar/report-task.txt
continue-on-error: true
timeout-minutes: 5
env:
SONAR_TOKEN: ${{ secrets.sonarCloudToken }}
- name: Quality Gate
id: quality-step
run: >
if "${{ steps.unit-tests.outcome }}" == "failure" or "${{
steps.sonarcloud-quality-gate-check.outcome }}" == "failure" or "${{
steps.sonarcloud-quality-gate-check.outputs.quality-gate-status }}" ==
"FAILED":
print("Quality gate failed due to:")
if "${{ steps.unit-tests.outcome }}" == "failure":
print("- Test failures")
if "${{ steps.sonarcloud-quality-gate-check.outcome }}" == "failure":
print("- Could not retrieve SonarCloud quality gate status")
if "${{ steps.sonarcloud-quality-gate-check.outputs.quality-gate-status }}" == "FAILED":
print("- Code analysis quality gate failed")
if "${{ steps.unit-tests.outcome }}" == "failure" or "${{ steps.sonarcloud-quality-gate-check.outcome }}" == "failure" or "${{ steps.sonarcloud-quality-gate-check.outputs.quality-gate-status }}" == "FAILED":
exit(1)
shell: python
artifact_creation_registration:
name: Artifact Registration and Upload
if: github.ref_type == 'tag'
runs-on: ubuntu-latest
needs: validate_skyline_quality_gate
env:
result-artifact-id: none
outputs:
artifact-id: ${{ env.result-artifact-id }}
steps:
- uses: actions/checkout@v4
- name: readDir
run: ls
- name: Initialize
run: |
echo "workspace" ${{ github.workspace }}
echo "ref name" ${{ github.ref_name }}
echo "run number" ${{ github.run_number }}
echo "ref type" ${{ github.ref_type }}
echo "repository" ${{ github.repository }}
- name: Find .sln file
id: findSlnFile
run: >
echo solutionFilePath=$(find . -type f -name '*.sln') >> $GITHUB_OUTPUT
shell: bash
- name: Find or create NuGet.config file
if: github.repository_owner == 'SkylineCommunications'
id: findOrCreateNuGetFile
run: |
file=$(find . -type f -iname 'nuget.config' | head -n 1)
if [[ -n "$file" ]]; then
echo "NuGet config file exists: $file"
echo NuGetFileName=$(basename $file) >> $GITHUB_OUTPUT
else
echo "NuGet config does not exist. Creating..."
dotnet new nugetconfig --output ${{ github.workspace }}
echo NuGetFileName=nuget.config >> $GITHUB_OUTPUT
fi
shell: bash
- name: Enable Skyline GitHub NuGet Registry
if: github.repository_owner == 'SkylineCommunications'
run: dotnet nuget add source
"https://nuget.pkg.github.com/SkylineCommunications/index.json"
--username USERNAME --password ${{ secrets.GITHUB_TOKEN }}
--store-password-in-clear-text --configfile ${{ github.workspace
}}/${{ steps.findOrCreateNuGetFile.outputs.NuGetFileName }}
- name: Enable Skyline Azure Cloud NuGet Registry
env:
AZURE_TOKEN_EXISTS: ${{ secrets.azureToken }}
if: env.AZURE_TOKEN_EXISTS != null && github.repository_owner ==
'SkylineCommunications'
run: >
$SOURCE_NAME="CloudNuGets"
$SOURCE_URL="https://pkgs.dev.azure.com/skyline-cloud/Cloud_NuGets/_packaging/CloudNuGet/nuget/v3/index.json"
# Check if the source exists. If it does, update it.
if (dotnet nuget list source | Select-String -Pattern $SOURCE_NAME) {
Write-Host "Updating existing source $SOURCE_NAME."
dotnet nuget update source $SOURCE_NAME --source $SOURCE_URL --username az --password ${{ secrets.azureToken }} --store-password-in-clear-text
} else {
Write-Host "Adding new source $SOURCE_NAME."
dotnet nuget add source $SOURCE_URL --name $SOURCE_NAME --username az --password ${{ secrets.azureToken }} --store-password-in-clear-text
}
shell: pwsh
- name: Enable Skyline Azure Private NuGet Registry
env:
AZURE_TOKEN_EXISTS: ${{ secrets.azureToken }}
if: env.AZURE_TOKEN_EXISTS != null && github.repository_owner ==
'SkylineCommunications'
run: >
$SOURCE_NAME="PrivateAzureNuGets"
$SOURCE_URL="https://pkgs.dev.azure.com/skyline-cloud/_packaging/skyline-private-nugets/nuget/v3/index.json"
# Check if the source exists. If it does, update it.
if (dotnet nuget list source | Select-String -Pattern $SOURCE_NAME) {
Write-Host "Updating existing source $SOURCE_NAME."
dotnet nuget update source $SOURCE_NAME --source $SOURCE_URL --username az --password ${{ secrets.azureToken }} --store-password-in-clear-text
} else {
Write-Host "Adding new source $SOURCE_NAME."
dotnet nuget add source $SOURCE_URL --name $SOURCE_NAME --username az --password ${{ secrets.azureToken }} --store-password-in-clear-text
}
shell: pwsh
- name: NuGet restore solution
run: dotnet restore "${{ steps.findSlnFile.outputs.solutionFilePath }}"
- name: Install .NET Tools
run: |
dotnet tool install -g Skyline.DataMiner.CICD.Tools.Packager
dotnet tool install -g Skyline.DataMiner.CICD.Tools.CatalogUpload
- name: Create package name
id: packageName
run: |
tempName="${{ github.repository }} ${{ github.ref_name }}"
echo name=${tempName//[\"\/\\<>|:*?]/_} >> $GITHUB_OUTPUT
shell: bash
- name: Create dmapp package
run: dataminer-package-create dmapp "${{ github.workspace }}" --type automation
--version ${{ github.ref_name }} --output "${{ github.workspace }}"
--name "${{ steps.packageName.outputs.name }}"
- name: Upload to Catalog
id: uploadToCatalog
run: echo "id=$(dataminer-catalog-upload with-registration --path-to-artifact
"${{ github.workspace }}/${{ steps.packageName.outputs.name }}.dmapp"
--uri-sourcecode "${{ github.server_url }}/${{ github.repository }}"
--artifact-version ${{ github.ref_name }} --dm-catalog-token ${{
secrets.api-key }})" >> $GITHUB_OUTPUT
- name: (Release) Set artifact Id
run: echo "result-artifact-id=${{ steps.uploadToCatalog.outputs.id }}" >>
$GITHUB_ENV
Binary file added Dlls/DIS/SLDisCommon.dll
Binary file not shown.
Binary file added Dlls/DIS/SLDisLib.dll
Binary file not shown.
Binary file added Dlls/DIS/SLDisMacros.dll
Binary file not shown.

0 comments on commit bbe789e

Please sign in to comment.