TEST #230
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: MSBuild | |
concurrency: | |
group: "${{ github.event_name }} : ${{ github.ref }}" | |
cancel-in-progress: true | |
on: | |
pull_request_target: | |
branches: [ master ] | |
types: [ opened, synchronize, labeled ] | |
push: | |
tags: | |
- 'v*' | |
merge_group: | |
types: [ checks_requested ] | |
env: | |
# Path to the solution file relative to the root of the project. | |
SOLUTION_FILE_PATH: ./src/EasyEPlanner.sln | |
# Configuration type to build. | |
# You can convert this to a build matrix if you need coverage of multiple configuration types. | |
# https://docs.github.com/actions/learn-github-actions/managing-complex-workflows#using-a-build-matrix | |
BUILD_CONFIGURATION: Release | |
jobs: | |
check: | |
name: Check | |
runs-on: windows-latest | |
outputs: | |
result: ${{ steps.pass.outputs.result }} | |
steps: | |
- id: is_organization_member | |
run: > | |
$response = (curl -L | |
-w '%{http_code}' | |
-H "Accept: application/vnd.github+json" | |
-H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" | |
-H "X-GitHub-Api-Version: 2022-11-28" | |
https://api.github.com/orgs/savushkin-r-d/members/${{ github.event.sender.login }}) | |
echo "response=$response" >> $env:GITHUB_OUTPUT | |
continue-on-error: true | |
# --On linux-- | |
# run: | | |
# response=`curl -L \ | |
# ... \ | |
# ...` | |
# echo "response=$response" >> $GITHUB_OUTPUT | |
- id: pass | |
if: >- | |
(github.event.action == 'labeled' && github.event.label.name == 'safe to test') || | |
((github.event.action == 'synchronize' || github.event.action == 'opened') && ${{ steps.is_organization_member.outputs.response == '204' }}) || | |
github.event_name == 'merge_group' || | |
contains(github.ref, 'tags/v') | |
run: echo "result=success" >> $env:GITHUB_OUTPUT | |
# On linux: >> $GITHUB_OUTPUT | |
build: | |
name: Build, analyze and test | |
runs-on: windows-latest | |
needs: check | |
if: needs.check.outputs.result == 'success' | |
steps: | |
- uses: actions/checkout@v3 | |
with: | |
submodules: 'recursive' | |
ref: ${{ github.event.pull_request.head.sha }} | |
fetch-depth: 0 | |
- name: Set up JDK 17 | |
uses: actions/setup-java@v3 | |
with: | |
java-version: 17 | |
distribution: 'zulu' | |
- name: Cache SonarCloud packages | |
uses: actions/cache@v3 | |
with: | |
path: ~\sonar\cache | |
key: ${{ runner.os }}-sonar | |
restore-keys: ${{ runner.os }}-sonar | |
- name: Cache SonarCloud scanner | |
id: cache-sonar-scanner | |
uses: actions/cache@v3 | |
with: | |
path: .\.sonar\scanner | |
key: ${{ runner.os }}-sonar-scanner | |
restore-keys: ${{ runner.os }}-sonar-scanner | |
- name: Install SonarCloud scanner | |
if: steps.cache-sonar-scanner.outputs.cache-hit != 'true' | |
shell: powershell | |
run: | | |
New-Item -Path .\.sonar\scanner -ItemType Directory | |
dotnet tool update dotnet-sonarscanner --tool-path .\.sonar\scanner | |
- name: Install dotnet-coverage | |
shell: powershell | |
run: | | |
dotnet tool install --global dotnet-coverage | |
- name: Add MSBuild to PATH | |
uses: microsoft/[email protected] | |
- name: Restore NuGet packages | |
working-directory: ${{env.GITHUB_WORKSPACE}} | |
run: nuget restore ${{env.SOLUTION_FILE_PATH}} | |
- name: Download fetch.exe and EPLAN API binaries, copy it to the .net specific path | |
run: | | |
curl -L "https://github.com/gruntwork-io/fetch/releases/download/v0.4.2/fetch_windows_amd64.exe" -O | |
md src/bin/${{env.BUILD_CONFIGURATION}} | |
./fetch_windows_amd64.exe --github-oauth-token="${{ secrets.EPLAN_API_BIN }}" --repo="https://github.com/savushkin-r-d/EPLAN-API-bin" --tag="2.9" --release-asset=".*" "src/bin/${{env.BUILD_CONFIGURATION}}" | |
md submodule/EplanIdleTimeModule/EplanIdleTimeModule/bin/${{env.BUILD_CONFIGURATION}} | |
cp src/bin/${{env.BUILD_CONFIGURATION}}/* submodule/EplanIdleTimeModule/EplanIdleTimeModule/bin/${{env.BUILD_CONFIGURATION}} | |
- name: Sonar scanner begin | |
working-directory: ${{env.GITHUB_WORKSPACE}} | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} | |
PULL_REQUEST_DATA: /d:sonar.pullrequest.key=${{ github.event.pull_request.number }} /d:sonar.pullrequest.branch=${{ github.event.pull_request.head.ref }} /d:sonar.scm.revision=${{ github.event.pull_request.head.sha }} | |
run: .\.sonar\scanner\dotnet-sonarscanner begin /k:"savushkin-r-d_EasyEPLANner" /o:"savushkin-r-d" /d:sonar.login="${{ secrets.SONAR_TOKEN }}" /d:sonar.host.url="https://sonarcloud.io" /d:sonar.cs.vscoveragexml.reportsPaths="EasyEplanner.Tests/coverage.xml" ${{ github.event_name == 'pull_request_target' && env.PULL_REQUEST_DATA || '' }} | |
- name: Build | |
working-directory: ${{env.GITHUB_WORKSPACE}} | |
run: msbuild /m /p:Configuration=${{env.BUILD_CONFIGURATION}} ${{env.SOLUTION_FILE_PATH}} | |
- name: Test | |
working-directory: EasyEplanner.Tests | |
run: dotnet test --configuration ${{env.BUILD_CONFIGURATION}} --collect "Code Coverage" | |
- name: Test coverage merge | |
working-directory: EasyEplanner.Tests | |
run: dotnet-coverage merge -o coverage.xml -f xml -r *.coverage | |
- name: Sonar scanner end | |
working-directory: ${{env.GITHUB_WORKSPACE}} | |
env: | |
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} | |
run: .\.sonar\scanner\dotnet-sonarscanner end /d:sonar.login="${{ secrets.SONAR_TOKEN }}" | |
- name: Download sys_base_objects_description | |
working-directory: ${{env.GITHUB_WORKSPACE}} | |
run: | | |
md /objects_description | |
./fetch_windows_amd64.exe --github-oauth-token="${{ secrets.EPLAN_API_BIN }}" --repo="https://github.com/savushkin-r-d/ptusa-Lua-dairy-system" --ref="master" "/objects_description" | |
md src/bin/${{env.BUILD_CONFIGURATION}}/Lua/BaseObjectsDescriptionFiles | |
copy /objects_description/EasyEplannerObjectsDescription/sys_base_objects_description.lua src/bin/${{env.BUILD_CONFIGURATION}}/Lua/BaseObjectsDescriptionFiles/sys_base_objects_description.lua | |
- name: Delete extra files | |
working-directory: src/bin/${{env.BUILD_CONFIGURATION}} | |
run: | | |
del *.pdb | |
del Eplan.EplApi.* | |
del EplanBaseNetu.dll | |
- name: Pack | |
working-directory: src/bin | |
run: cmake -E tar cfv EasyEPLANner.zip --format=zip ${{env.BUILD_CONFIGURATION}} | |
- name: Upload artifact | |
uses: actions/upload-artifact@v3 | |
with: | |
name: EasyEPLANner | |
path: src/bin/EasyEPLANner.zip | |
release: | |
if: contains(github.ref, 'tags/v') | |
name: Release | |
runs-on: ubuntu-latest | |
needs: build | |
steps: | |
- name: Create Release | |
id: create_release | |
uses: actions/[email protected] | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
tag_name: ${{ github.ref }} | |
release_name: Release ${{ github.ref }} | |
draft: false | |
prerelease: false | |
- name: Store Release url | |
run: | | |
echo "${{ steps.create_release.outputs.upload_url }}" > ./upload_url | |
- uses: actions/upload-artifact@v1 | |
with: | |
path: ./upload_url | |
name: upload_url | |
publish: | |
if: contains(github.ref, 'tags/v') | |
name: publish | |
runs-on: ubuntu-latest | |
needs: release | |
steps: | |
- name: Download artifact | |
uses: actions/download-artifact@v1 | |
with: | |
name: EasyEPLANner | |
path: ./ | |
- name: Download URL | |
uses: actions/download-artifact@v1 | |
with: | |
name: upload_url | |
path: ./ | |
- id: set_upload_url | |
run: | | |
upload_url=`cat ./upload_url` | |
echo ::set-output name=upload_url::$upload_url | |
- name: Upload to Release | |
id: upload_to_release | |
uses: actions/[email protected] | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
upload_url: ${{ steps.set_upload_url.outputs.upload_url }} | |
asset_path: ./EasyEPLANner.zip | |
asset_name: EasyEPLANner.zip | |
asset_content_type: application/zip |