Skip to content

Commit

Permalink
CI: Update Windows dependency build action and workflow job
Browse files Browse the repository at this point in the history
  • Loading branch information
PatTheMav committed Jun 17, 2023
1 parent 40bc0c0 commit 33f7dac
Show file tree
Hide file tree
Showing 3 changed files with 100 additions and 69 deletions.
79 changes: 42 additions & 37 deletions .github/actions/build-windows-deps/action.yml
Original file line number Diff line number Diff line change
@@ -1,67 +1,72 @@
name: 'Build Windows Dependencies'
description: 'Builds Windows dependencies for obs-deps with specified architecture, type, and build config'
name: Build Windows Dependencies
description: Builds Windows dependencies for obs-deps with specified architecture, type, and build config
inputs:
target:
description: 'Build target for dependencies'
description: Build target for dependencies
required: true
type:
description: 'Build type (shared or static libraries)'
description: Build type (shared or static libraries)
required: false
default: 'static'
default: static
config:
description: 'Build configuration'
description: Build configuration
required: false
default: 'Release'
cacheRevision:
description: 'Cache revision number to force creation of new cache generation'
default: Release
workingDirectory:
description: Working directory for repository action
required: false
default: '01'
default: ${{ github.workspace }}
runs:
using: 'composite'
using: composite
steps:
- name: Environment Setup
id: deps-env-setup
id: env-setup
shell: pwsh
run: |
Get-Content .\deps.windows\*.ps1 > temp.txt
$DepsHash = ((Get-FileHash -Path temp.txt -Algorithm SHA256).Hash)
# Environment Setup
"hash=${DepsHash}" >> $env:GITHUB_OUTPUT
$Content = Get-Content ${{ inputs.workingDirectory }}/deps.windows/*.ps1
$Sha256Hasher = [System.Security.Cryptography.HashAlgorithm]::Create('sha256')
$ContentHash = $Sha256Hasher.ComputeHash([System.Text.Encoding]::UTF8.GetBytes($Content))
"hash=$([System.BitConverter]::ToString($ContentHash).Replace('-','').SubString(0,9).ToLower())" >> $env:GITHUB_OUTPUT
- name: Restore Windows Dependencies from Cache
id: deps-cache
uses: actions/cache@v3
uses: actions/cache/restore@v3
with:
path: |
${{ github.workspace }}/*_build_temp/*
!${{ github.workspace }}/*_build_temp/**/.git
!${{ github.workspace }}/*_build_temp/*.tar.gz
!${{ github.workspace }}/*_build_temp/*.tar.xz
!${{ github.workspace }}/*_build_temp/*.zip
key: ${{ inputs.target }}-deps-${{ inputs.type }}-${{ steps.deps-env-setup.outputs.hash }}-${{ inputs.cacheRevision }}
${{ inputs.workingDirectory }}/*_build_temp/*
!${{ inputs.workingDirectory }}/*_build_temp/**/.git
!${{ inputs.workingDirectory }}/*_build_temp/*.tar.gz
!${{ inputs.workingDirectory }}/*_build_temp/*.tar.xz
!${{ inputs.workingDirectory }}/*_build_temp/*.zip
key: ${{ inputs.target }}-deps-${{ inputs.type }}-${{ inputs.config }}-${{ steps.env-setup.outputs.hash }}

- name: Install Windows Dependencies
if: ${{ steps.deps-cache.outputs.cache-hit == 'true' }}
shell: pwsh
run: |
$Params = @{
SkipBuild = $true
SkipUnpack = $true
Target = '${{ inputs.target }}'
Configuration = '${{ inputs.config }}'
}
if ( '${{ inputs.type }}' -eq 'shared' ) { $Params += @{Shared = $true} }
# Install Windows Dependencies
./Build-Dependencies.ps1 @Params
- name: Build and Install Windows Dependencies
if: ${{ steps.deps-cache.outputs.cache-hit != 'true' }}
shell: pwsh
run: |
$Params = @{
Target = '${{ inputs.target }}'
Configuration = '${{ inputs.config }}'
Shared = $(if ( '${{ inputs.type }}' -eq 'shared' ) { $true } else { $false })
SkipBuild = $(if ( '${{ steps.deps-cache.outputs.cache-hit }}' -eq 'true' ) { $true } else { $false })
SkipUnpack = $(if ( '${{ steps.deps-cache.outputs.cache-hit }}' -eq 'true' ) { $true } else { $false })
}
if ( '${{ inputs.type }}' -eq 'shared' ) { $Params += @{Shared = $true} }
./Build-Dependencies.ps1 @Params
- name: Save Windows Dependencies to Cache
uses: actions/cache/save@v3
if: github.event_name == 'schedule' || (github.event_name == 'push' && steps.deps-cache.outputs.cache-hit != 'true')
with:
path: |
${{ inputs.workingDirectory }}/*_build_temp/*
!${{ inputs.workingDirectory }}/*_build_temp/**/.git
!${{ inputs.workingDirectory }}/*_build_temp/*.tar.gz
!${{ inputs.workingDirectory }}/*_build_temp/*.tar.xz
!${{ inputs.workingDirectory }}/*_build_temp/*.zip
key: ${{ inputs.target }}-deps-${{ inputs.type }}-${{ inputs.config }}-${{ steps.env-setup.outputs.hash }}
45 changes: 14 additions & 31 deletions .github/workflows/main.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -375,21 +375,20 @@ jobs:
outputName: qt6-${{ matrix.target }}-${{ needs.pre-checks.outputs.shortHash }}

windows-build:
name: 'Build Windows Dependencies'
name: Build Windows Dependencies
runs-on: windows-2022
needs: pre-checks
strategy:
fail-fast: true
matrix:
target: [x64, x86]
include:
- target: x64
config: 'Release'
type: 'static'
config: Release
type: static
- target: x86
config: 'Release'
type: 'static'
env:
CACHE_REVISION: '3'
config: Release
type: static
defaults:
run:
shell: pwsh
Expand All @@ -400,41 +399,26 @@ jobs:
- name: Setup Environment
id: setup
run: |
# Setup Environment
$Target='${{ matrix.target }}'
$ArtifactName="deps-windows-${Target}-${{ github.sha }}"
$ArtifactName="deps-windows-${Target}-${{ needs.pre-checks.outputs.shortHash }}"
$FileName="windows-deps-$(Get-Date -Format 'yyyy-MM-dd')-${Target}.zip"
"artifactName=${ArtifactName}" >> $env:GITHUB_OUTPUT
"artifactFileName=${FileName}" >> $env:GITHUB_OUTPUT
- name: 'Check for GitHub Labels'
id: seekingTesters
if: ${{ github.event_name == 'pull_request' }}
run: |
$LabelFound = try {
$Params = @{
Authentication = 'Bearer'
Token = (ConvertTo-SecureString '${{ secrets.GITHUB_TOKEN }}' -AsPlainText)
Uri = '${{ github.event.pull_request.url }}'
UseBasicParsing = $true
}
(Invoke-RestMethod @Params).labels.name.contains("Seeking Testers")
} catch {
$false
}
"found=$(([string]${LabelFound}).ToLower())" >> $env:GITHUB_OUTPUT
- name: Build ntv2 debug
- name: Build ntv2 Debug
if: matrix.target == 'x64'
shell: pwsh
run: |
# Build ntv2 Debug
$Params = @{
Target = '${{ matrix.target }}'
Configuration = 'Debug'
Dependencies = 'ntv2'
}
if ( '${{ matrix.type }}' -eq 'shared' ) { $Params += @{Shared = $true} }
./Build-Dependencies.ps1 @Params
Remove-Item -Recurse -Force ${{ github.workspace }}/windows_build_temp
Expand All @@ -445,10 +429,9 @@ jobs:
target: ${{ matrix.target }}
type: ${{ matrix.type }}
config: ${{ matrix.config }}
cacheRevision: ${{ env.CACHE_REVISION }}

- name: Publish Build Artifacts
if: ${{ success() && (github.event_name != 'pull_request' || steps.seekingTesters.outputs.found == 'true') }}
if: github.event_name != 'pull_request' || fromJSON(needs.pre-checks.outputs.seekingTesters)
uses: actions/upload-artifact@v3
with:
name: ${{ steps.setup.outputs.artifactName }}
Expand Down
45 changes: 44 additions & 1 deletion .github/workflows/scheduled.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ jobs:
fi
done <<< \
"$(gh api repos/${GITHUB_REPOSITORY}/actions/caches \
--jq '.actions_caches.[] | select(.ref|test("refs/heads/master")) | select(.key|test(".+-qt6-.+")) | {id, key} | join(";")')"
--jq '.actions_caches.[] | select(.ref|test("refs/heads/master")) | select(.key|test(".+-(qt6|deps)-.+")) | select(.key|test(".+ffmpeg.+")|not) | {id, key} | join(";")')"
echo '::endgroup::'
echo '::group::Processing pull request cache entries'
Expand All @@ -73,6 +73,49 @@ jobs:
--jq '.actions_caches.[] | select(.ref|test("refs/heads/master")|not) | {id, key, ref} | join(";")' &> /dev/null)"
echo '::endgroup::'
windows-build:
name: Build Windows Dependencies
runs-on: windows-2022
strategy:
fail-fast: true
matrix:
target: [x64, x86]
include:
- target: x64
config: Release
type: static
- target: x86
config: Release
type: static
defaults:
run:
shell: pwsh
steps:
- name: Checkout
uses: actions/checkout@v3

- name: Build ntv2 Debug
if: matrix.target == 'x64'
shell: pwsh
run: |
# Build ntv2 Debug
$Params = @{
Target = '${{ matrix.target }}'
Configuration = 'Debug'
Dependencies = 'ntv2'
}
./Build-Dependencies.ps1 @Params
Remove-Item -Recurse -Force ${{ github.workspace }}/windows_build_temp
- name: Build Windows Dependencies
uses: ./.github/actions/build-windows-deps
with:
target: ${{ matrix.target }}
type: ${{ matrix.type }}
config: ${{ matrix.config }}

macos-qt6-build:
name: Build Qt6 (macOS)
runs-on: macos-13
Expand Down

0 comments on commit 33f7dac

Please sign in to comment.