Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PR: Update actions #35

Merged
merged 2 commits into from
Aug 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions .github/workflows/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# Github actions

## ci

* Build and release when pushes to `main` or `dev`.

## pr

* Build when PRs a ready for review.
* Does not sign the executable.

## tests

* Run tests on pushes to `main`, `dev` and PRs ready for review.
* Only runs if code under `src` has changed (can by bypassed manually).
35 changes: 6 additions & 29 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,6 @@ on:
- main
- dev
workflow_dispatch:
inputs:
force_build:
default: false
required: false
type: boolean
description: Bypass code changed check on build
force_release:
default: false
required: false
type: boolean
description: Bypass branch check on release

env:
Solution_Directory: src\AnalyticsEngine\
Expand Down Expand Up @@ -47,18 +36,7 @@ jobs:
runs-on: ubuntu-latest
outputs:
build_number: ${{ steps.build_number.outputs.number }}
code_changed: ${{ inputs.force_build || steps.changes.outputs.code == 'true' }}
steps:
- name: Checkout source
uses: actions/checkout@v4
- name: Check if code has been modified so a build is needed
id: changes
uses: dorny/paths-filter@v3
with:
filters: |
code:
- 'src/**'
- 'reports/**'
- name: Calculate build number
id: build_number
run: echo "number=$((${{ vars.BUILD_NUMBER_OFFSET }} + ${{ github.run_number }}))" >> "$GITHUB_OUTPUT"
Expand All @@ -77,7 +55,6 @@ jobs:
# - Publish artifacts
runs-on: windows-latest
needs: setup_build
if: needs.setup_build.outputs.code_changed == 'true'
strategy:
matrix:
configuration: [Release] # [Debug, Release]
Expand All @@ -95,7 +72,6 @@ jobs:
echo "ZIPS_FOLDER=${{ env.Zips_Folder }}" >> "$GITHUB_OUTPUT"
echo "PFX_PATH=${{ env.Pfx_Path }}" >> "$GITHUB_OUTPUT"
env:
#${{ github.ref_name }} - build ${{ env.BuildId }}
Zips_Folder: ${{ runner.temp }}/zips/
Pfx_Path: ${{ runner.temp }}/SPOInsightsBinaries.pfx
- name: Decode the PFX
Expand Down Expand Up @@ -250,7 +226,6 @@ jobs:
# - Publish artifacts
runs-on: ubuntu-latest
needs: setup_build
if: needs.setup_build.outputs.code_changed == 'true'
steps:
- name: Checkout source
uses: actions/checkout@v4
Expand All @@ -276,7 +251,6 @@ jobs:
- setup_build
- build_dotnet
- build_aitracker
if: inputs.force_release || github.ref_name == 'main' || github.ref_name == 'dev'
permissions:
# Required to create tags in the repo
contents: write
Expand All @@ -286,11 +260,14 @@ jobs:
steps:
- name: Checkout source
uses: actions/checkout@v4
if: false
with:
fetch-depth: 0
- name: Install Changelog Generator
if: false
run: sudo gem install github_changelog_generator
- name: Generate Changelog
if: false
run: |
git branch
last_tag=""
Expand Down Expand Up @@ -320,13 +297,13 @@ jobs:
GITHUB_TOKEN: ${{ github.token }}
BASE: ${{ steps.artifacts.outputs.download-path }}
with:
draft: ${{ vars.PUBLISH_RELEASES == 'false' }}
draft: ${{ vars.PUBLISH_RELEASES != 'true' }}
prerelease: ${{ github.ref_name != 'main' }}
makeLatest: ${{ github.ref_name == 'main' }}
name: ${{ env.LABEL }}
tag: ${{ env.BuildId }}
commit: ${{ github.sha }}
bodyFile: CHANGELOG.md
generateReleaseNotes: false
# bodyFile: CHANGELOG.md
generateReleaseNotes: true
artifacts: "${{ env.BASE }}/drop_dotnet/*.zip,${{ env.BASE }}/drop_aitracker/*.zip"
artifactContentType: application/zip
239 changes: 239 additions & 0 deletions .github/workflows/pr.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,239 @@
name: pr

on:
pull_request:
types:
- ready_for_review
workflow_dispatch:
inputs:
force_build:
default: false
required: false
type: boolean
description: Bypass code changed check

env:
Solution_Directory: src\AnalyticsEngine\
Build_Platform: Any CPU
Build_ProcessorArchitecture: x86
ClientID: ${{ secrets.APP_CLIENTID }}
ClientSecret: ${{ secrets.APP_CLIENTSECRET }}
TenantGUID: ${{ secrets.APP_TENANTGUID }}
TenantDomain: ${{ secrets.APP_TENANTDOMAIN }}
CognitiveEndpoint: ${{ secrets.APP_COGNITIVEENDPOINT }}
CognitiveKey: ${{ secrets.APP_COGNITIVEKEY}}
CosmosDbTestContainerCurrent: stats
CosmosDbTestContainerHistory: history
CosmosDbTestDatabaseName: UnitTestDevOps
CosmosDb: ${{ secrets.APP_COSMOSDB }}
redis: ${{ secrets.CONNECTIONSTRINGS_REDIS }}
ServiceBus: ${{ secrets.CONNECTIONSTRINGS_SERVICEBUS }}
Storage: ${{ secrets.CONNECTIONSTRINGS_STORAGE }}
SoftwareDownloadURL: ${{ secrets.SOFTWAREDOWNLOADURL }}
StatsApiSecret: ${{ secrets.STATSAPISECRET }}
StatsApiUrl: ${{ secrets.STATSAPIURL }}

jobs:
setup_build:
# This step will calculate the build number with an offset
# so that build numbers will follow the ones from Azure DevOps.
# It will also check that the important folders have been updated.
runs-on: ubuntu-latest
outputs:
code_changed: ${{ inputs.force_build || steps.changes.outputs.code == 'true' }}
steps:
- name: Checkout source
uses: actions/checkout@v4
- name: Check if code has been modified so a build is needed
id: changes
uses: dorny/paths-filter@v3
with:
filters: |
code:
- 'src/**'
- 'reports/**'

build_dotnet:
# Preparation:
# - Transform configuration files
# - Restore dependencies
# Build:
# - Build .Net projects
# Output:
# - Clean .Net builds
# - Copy PS scripts
# - Zip files
# - Publish artifacts
runs-on: windows-latest
needs: setup_build
if: needs.setup_build.outputs.code_changed == 'true'
strategy:
matrix:
configuration: [Release] # [Debug, Release]
env:
BuildId: ${{ github.run_number }}
BuildLabel: PR ${{ github.run_number }}
steps:
- name: Prepare build
id: prep
shell: bash
run: |
mkdir -p "${{ env.Zips_Folder }}"
echo "ZIPS_FOLDER=${{ env.Zips_Folder }}" >> "$GITHUB_OUTPUT"
env:
Zips_Folder: ${{ runner.temp }}/zips/
- name: Checkout source
uses: actions/checkout@v4
- name: Setup MSBuild
uses: microsoft/setup-msbuild@v2
- name: Cache NuGet Packages
id: nuget-packages
uses: actions/cache@v4
env:
cache-name: nuget-package-cache
with:
path: ~\.nuget\packages
key: ${{ runner.os }}-${{ env.cache-name }}
# Configuration files
- name: Year substitution
shell: bash
run: |
year=$(date +%Y)
find ./src -name AssemblyInfo.cs | xargs sed -i "s/© __year__/© $year/"
- name: Config substitutions
uses: devops-actions/[email protected]
with:
files: '${{ env.Solution_Directory }}\*\App.Release.config, ${{ env.Solution_Directory }}\Web\Web.Release.config'
- name: Restore the application
run: msbuild ${{ env.Solution_Directory }} -t:Restore `
-p:Configuration=${{ env.Configuration }} `
-p:Platform="${{ env.Build_Platform }}" `
-p:ProcessorArchitecture=${{ env.Build_ProcessorArchitecture }}
env:
Configuration: ${{ matrix.configuration }}
# Projects building
- name: Build WebJob.AppInsightsImporter
run: msbuild ${{ env.Solution_Directory }}\WebJob.AppInsightsImporter\WebJob.AppInsightsImporter.csproj `
-p:Configuration=${{ env.Configuration }} `
-p:Platform="${{ env.Build_Platform }}" `
-p:ProcessorArchitecture=${{ env.Build_ProcessorArchitecture }} `
-p:OutDir=${{ runner.temp }}\AppInsightsImporter `
-p:OutputPath=${{ env.Configuration }} `
-p:AllowedReferenceRelatedFileExtensions=none `
-p:EmitCompilerGeneratedFiles=false
env:
Configuration: ${{ matrix.configuration }}
- name: Archive AppInsightsImporter
run: |
Remove-Item -Force -Recurse -ErrorAction SilentlyContinue "${{ runner.temp }}\AppInsightsImporter\_PublishedWebsites"
Compress-Archive -Force -Path "${{ runner.temp }}\AppInsightsImporter" `
-DestinationPath "${{ env.folder }}\AppInsightsImporter.zip"
env:
folder: ${{ steps.prep.outputs.ZIPS_FOLDER }}
- name: Build WebJob.Office365ActivityImporter
run: |
msbuild ${{ env.Solution_Directory }}\WebJob.Office365ActivityImporter\WebJob.Office365ActivityImporter.csproj `
-p:Configuration=${{ env.Configuration }} `
-p:Platform="${{ env.Build_Platform }}" `
-p:ProcessorArchitecture=${{ env.Build_ProcessorArchitecture }} `
-p:OutDir=${{ runner.temp }}\Office365ActivityImporter `
-p:OutputPath=${{ env.Configuration }} `
-p:AllowedReferenceRelatedFileExtensions=none `
-p:EmitCompilerGeneratedFiles=false
env:
Configuration: ${{ matrix.configuration }}
- name: Copy Automation scripts
run: |
Copy-Item -Verbose -Force -Recurse `
-Path "src/AnalyticsEngine/WebJob.Office365ActivityImporter/AutomationPS" `
-Destination "${{ runner.temp }}\Office365ActivityImporter\"
- name: Archive Office365ActivityImporter
run: |
Remove-Item -Force -Recurse -ErrorAction SilentlyContinue `
"${{ runner.temp }}\Office365ActivityImporter\_PublishedWebsites"
Compress-Archive -Force -Path "${{ runner.temp }}\Office365ActivityImporter" `
-DestinationPath "${{ env.folder }}\Office365ActivityImporter.zip"
env:
folder: ${{ steps.prep.outputs.ZIPS_FOLDER }}
- name: Build Website
run: msbuild ${{ env.Solution_Directory }}\Web\Web.csproj `
-p:Configuration=${{ env.Configuration }} `
-p:Platform="${{ env.Build_Platform }}" `
-p:ProcessorArchitecture=${{ env.Build_ProcessorArchitecture }} `
-p:OutDir=${{ runner.temp }}\Website `
-p:OutputPath=${{ env.Configuration }} `
-p:AllowedReferenceRelatedFileExtensions=none `
-p:EmitCompilerGeneratedFiles=false
env:
Configuration: ${{ matrix.configuration }}
- name: Archive Website
run: |
Remove-Item -Force -Recurse -ErrorAction SilentlyContinue `
"${{ runner.temp }}\Website\_PublishedWebsites\Web\bin\Scripts"
Compress-Archive -Force -Path "${{ runner.temp }}\Website\_PublishedWebsites\Web" `
-DestinationPath "${{ env.folder }}\Website.zip"
env:
folder: ${{ steps.prep.outputs.ZIPS_FOLDER }}
- name: Build Installer
run: |
msbuild ${{ env.Solution_Directory }}\App.ControlPanel\App.ControlPanel.WinForms.csproj `
-p:Configuration=${{ env.Configuration }} `
-p:Platform="${{ env.Build_Platform }}" `
-p:ProcessorArchitecture=${{ env.Build_ProcessorArchitecture }} `
-p:OutDir=${{ runner.temp }}\ControlPanelApp `
-p:OutputPath=${{ env.Configuration }} `
-p:AllowedReferenceRelatedFileExtensions=none `
-p:EmitCompilerGeneratedFiles=false
env:
Configuration: ${{ matrix.configuration }}
- name: Archive ControlPanelApp
run: Compress-Archive -Force -Path "${{ runner.temp }}\ControlPanelApp" `
-DestinationPath "${{ env.folder }}\ControlPanelApp.zip"
env:
folder: ${{ steps.prep.outputs.ZIPS_FOLDER }}
- name: Archive Reports
run: |
Get-ChildItem '.\reports\Usage Analytics\*' `
-Exclude "*_base.pbit" -Include "*.pbit","Readme.txt" | Compress-Archive `
-Force -DestinationPath "${{ env.folder }}\Analytics_Reports.zip"
env:
folder: ${{ steps.prep.outputs.ZIPS_FOLDER }}
# Wrap up
- name: Upload artifacts
uses: actions/upload-artifact@v4
with:
path: ${{ env.folder }}
name: drop_dotnet
if-no-files-found: error
env:
folder: ${{ steps.prep.outputs.ZIPS_FOLDER }}

build_aitracker:
# NPM ai tracker
# Build:
# - Build AI Tracker
# Output:
# - Clean AI Tracker
# - Zip files
# - Publish artifacts
runs-on: ubuntu-latest
needs: setup_build
if: needs.setup_build.outputs.code_changed == 'true'
steps:
- name: Checkout source
uses: actions/checkout@v4
- name: Build AITracker
run: |
cd src/SPO/AITracker/TypeScript
npm ci
npm run build
cd ../..
rm -rf AITracker/TypeScript
zip -r AITrackerInstaller.zip AITracker
# Wrap up
- name: Upload artifacts
uses: actions/upload-artifact@v4
with:
path: src/SPO/AITrackerInstaller.zip
name: drop_aitracker
if-no-files-found: error
4 changes: 1 addition & 3 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,8 @@ on:
- main
- dev
pull_request:
branches:
- dev
types:
- opened
- ready_for_review
workflow_dispatch:
inputs:
force_run:
Expand Down