From e110b845d33e91e84d8c479dc94aead31824e73f Mon Sep 17 00:00:00 2001 From: Nick Grifka Date: Tue, 16 Apr 2024 12:26:14 -0700 Subject: [PATCH] add CI build --- .github/dependabot.yml | 9 ++ .github/workflows/build-reuse-unix.yml | 88 ++++++++++++++ .github/workflows/build-reuse-win.yml | 75 ++++++++++++ .github/workflows/build-reuse-winkernel.yml | 73 +++++++++++ .github/workflows/build.yml | 127 ++++++++++++++++++++ 5 files changed, 372 insertions(+) create mode 100644 .github/dependabot.yml create mode 100644 .github/workflows/build-reuse-unix.yml create mode 100644 .github/workflows/build-reuse-win.yml create mode 100644 .github/workflows/build-reuse-winkernel.yml create mode 100644 .github/workflows/build.yml diff --git a/.github/dependabot.yml b/.github/dependabot.yml new file mode 100644 index 0000000..e56fa41 --- /dev/null +++ b/.github/dependabot.yml @@ -0,0 +1,9 @@ + +version: 2 +updates: + + - package-ecosystem: "github-actions" + directory: "/" + schedule: + interval: "weekly" + day: "saturday" diff --git a/.github/workflows/build-reuse-unix.yml b/.github/workflows/build-reuse-unix.yml new file mode 100644 index 0000000..0b0c712 --- /dev/null +++ b/.github/workflows/build-reuse-unix.yml @@ -0,0 +1,88 @@ +name: Build Unix + +# The caller is responsible for making sure all options passed to this workflow are valid and compatible with each other. + +on: + workflow_call: + inputs: + ref: + required: false + default: '' + type: string + config: + required: false + default: 'Release' + type: string + # options: + # - Debug + # - Release + plat: + required: false + type: string + default: 'linux' + # options: + # - linux + # - android + # - ios + # - macos + os: + required: false + type: string + default: 'ubuntu-20.04' + # options: + # - ubuntu-20.04 + # - ubuntu-22.04 + # - macos-12 + arch: + required: false + default: 'x64' + type: string + # options: + # - x86 + # - x64 + # - arm + # - arm64 + static: + required: false + default: '' + type: string + clang: + required: false + default: '' + type: string + build: + required: false + default: '' # Empty string means build all + type: string + +permissions: read-all + +jobs: + build-unix-reuse: + name: Build + runs-on: ${{ inputs.os }} + container: + image: ${{ inputs.plat == 'linux' && format('ghcr.io/microsoft/msquic/linux-build-xcomp:{0}', inputs.os) || '' }} + steps: + - name: Checkout repository + uses: actions/checkout@9bb56186c3b09b4f86b1c65136769dd318469633 + with: + repository: microsoft/cxplat + ref: ${{ inputs.ref }} + - name: Set ownership + if: inputs.plat == 'linux' + run: | + # this is to fix GIT not liking owner of the checkout dir + chown -R $(id -u):$(id -g) $PWD + - name: Prepare Machine + shell: pwsh + run: scripts/prepare-machine.ps1 -ForBuild + - name: Build + if: inputs.build == '' + shell: pwsh + run: scripts/build.ps1 -Config ${{ inputs.config }} -Platform ${{ inputs.plat }} -Arch ${{ inputs.arch }} ${{ inputs.static }} ${{ inputs.clang }} -OneBranch + - name: Upload build artifacts + uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 + with: + name: ${{ inputs.config }}-${{ inputs.plat }}-${{ inputs.os }}-${{ inputs.arch }}-${{ inputs.static }}${{ inputs.clang }}${{ inputs.build }} + path: artifacts diff --git a/.github/workflows/build-reuse-win.yml b/.github/workflows/build-reuse-win.yml new file mode 100644 index 0000000..5d0f125 --- /dev/null +++ b/.github/workflows/build-reuse-win.yml @@ -0,0 +1,75 @@ +name: Build WinUser + +# The caller is responsible for making sure all options passed to this workflow are valid and compatible with each other. + +on: + workflow_call: + inputs: + ref: + required: false + default: '' + type: string + config: + required: false + default: 'Release' + type: string + # options: + # - Debug + # - Release + plat: + required: false + type: string + default: 'windows' + # options: + # - windows + # - uwp + # - winkernel + os: + required: false + type: string + default: 'windows-2019' + # options: + # - windows-2019 + # - windows-2022 + arch: + required: false + default: 'x64' + type: string + # options: + # - x86 + # - x64 + # - arm64 + static: + required: false + default: '' + type: string + build: + required: false + default: '' # Empty string means build all + type: string + +permissions: read-all + +jobs: + build-windows-reuse: + if: inputs.plat == 'windows' || inputs.plat == 'uwp' + name: Build + runs-on: ${{ inputs.os }} + steps: + - name: Checkout repository + uses: actions/checkout@9bb56186c3b09b4f86b1c65136769dd318469633 + with: + repository: microsoft/cxplat + ref: ${{ inputs.ref }} + - name: Prepare Machine + shell: pwsh + run: scripts/prepare-machine.ps1 -ForBuild + - name: Build + if: inputs.build == '' + shell: pwsh + run: scripts/build.ps1 -Config ${{ inputs.config }} -Platform ${{ inputs.plat }} -Arch ${{ inputs.arch }} ${{ inputs.static }} + - name: Upload build artifacts + uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 + with: + name: ${{ inputs.config }}-${{ inputs.plat }}-${{ inputs.os }}-${{ inputs.arch }}-${{ inputs.static }}${{ inputs.build }} + path: artifacts diff --git a/.github/workflows/build-reuse-winkernel.yml b/.github/workflows/build-reuse-winkernel.yml new file mode 100644 index 0000000..86bfd21 --- /dev/null +++ b/.github/workflows/build-reuse-winkernel.yml @@ -0,0 +1,73 @@ +name: Build WinKernel + +# The caller is responsible for making sure all options passed to this workflow are valid and compatible with each other. + +on: + workflow_call: + inputs: + ref: + required: false + default: '' + type: string + config: + required: false + default: 'Release' + type: string + # options: + # - Debug + # - Release + plat: + required: false + type: string + default: 'winkernel' + # options: + # - winkernel + os: + required: false + type: string + default: 'windows-2019' + # options: + # - windows-2019 + # - windows-2022 + arch: + required: false + default: 'x64' + type: string + # options: + # - x86 + # - x64 + # - arm64 + build: + required: false + default: '' # Empty string means build all + type: string + +permissions: read-all + +jobs: + build-windows-kernel-reuse: + name: Build + runs-on: ${{ inputs.os }} + steps: + - name: Checkout repository + uses: actions/checkout@9bb56186c3b09b4f86b1c65136769dd318469633 + with: + repository: microsoft/cxplat + ref: ${{ inputs.ref }} + - name: Prepare Machine + shell: pwsh + run: scripts/prepare-machine.ps1 -ForBuild + - name: Add msbuild to PATH + uses: microsoft/setup-msbuild@6fb02220983dee41ce7ae257b6f4d8f9bf5ed4ce + - name: Nuget Restore + shell: pwsh + run: msbuild cxplat.kernel.sln -t:restore /p:RestorePackagesConfig=true /p:Configuration=${{ inputs.config }} /p:Platform=${{ inputs.arch }} + - name: Build + if: inputs.build == '' + shell: pwsh + run: msbuild cxplat.kernel.sln /m /p:Configuration=${{ inputs.config }} /p:Platform=${{ inputs.arch }} /p:CXPLAT_VER_SUFFIX=-official + - name: Upload build artifacts + uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 + with: + name: ${{ inputs.config }}-${{ inputs.plat }}-${{ inputs.os }}-${{ inputs.arch }}-${{ inputs.build }} + path: artifacts diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 0000000..dbe11f9 --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,127 @@ +name: Build + +on: + workflow_dispatch: + push: + branches: + - main + - release/* + pull_request: + branches: + - main + - release/* + +concurrency: + # Cancel any workflow currently in progress for the same PR. + # Allow running concurrently with any other commits. + group: build-${{ github.event.pull_request.number || github.sha }} + cancel-in-progress: true + +permissions: read-all + +jobs: + build-windows: + name: WinUser + needs: [] + strategy: + fail-fast: false + matrix: + config: ['Debug', 'Release'] + plat: [windows, uwp] # TODO: Support gamecore_console + os: ['windows-2022'] + arch: [x86, x64, arm64] + static: ['', '-Static'] + exclude: + # TODO: FIX: Static builds fail with UWP + - plat: uwp + static: '-Static' + uses: ./.github/workflows/build-reuse-win.yml + with: + config: ${{ matrix.config }} + plat: ${{ matrix.plat }} + os: ${{ matrix.os }} + arch: ${{ matrix.arch }} + static: ${{ matrix.static }} + + build-windows-kernel: + name: WinKernel + needs: [] + strategy: + fail-fast: false + matrix: + config: ['Debug', 'Release'] + plat: [winkernel] + os: ['windows-2022'] + arch: [x64, arm64] + uses: ./.github/workflows/build-reuse-winkernel.yml + with: + config: ${{ matrix.config }} + plat: ${{ matrix.plat }} + os: ${{ matrix.os }} + arch: ${{ matrix.arch }} + + build-ubuntu-cross-compile: + name: UbuntuArm + needs: [] + strategy: + fail-fast: false + matrix: + config: ['Debug', 'Release'] + plat: [linux] + os: ['ubuntu-20.04', 'ubuntu-22.04'] + arch: [arm, arm64] + static: ['', '-Static'] + uses: ./.github/workflows/build-reuse-unix.yml + with: + config: ${{ matrix.config }} + plat: ${{ matrix.plat }} + os: ${{ matrix.os }} + arch: ${{ matrix.arch }} + static: ${{ matrix.static }} + + build-ubuntu: + name: Ubuntu + needs: [] + strategy: + fail-fast: false + matrix: + config: ['Debug', 'Release'] + plat: [linux, android] + os: ['ubuntu-20.04', 'ubuntu-22.04'] + arch: [x86, x64] + static: ['', '-Static'] + clang: ['', '-Clang'] + exclude: + # Android doesn't support x86 + - plat: android + arch: x86 + # Android doesn't use Clang + - plat: android + clang: '-Clang' + uses: ./.github/workflows/build-reuse-unix.yml + with: + config: ${{ matrix.config }} + plat: ${{ matrix.plat }} + os: ${{ matrix.os }} + arch: ${{ matrix.arch }} + static: ${{ matrix.static }} + clang: ${{ matrix.clang }} + + build-darwin: + name: MacOs + needs: [] + strategy: + fail-fast: false + matrix: + config: ['Debug', 'Release'] + plat: [macos, ios] + os: ['macos-12'] + arch: [x64, arm64] + static: ['', '-Static'] + uses: ./.github/workflows/build-reuse-unix.yml + with: + config: ${{ matrix.config }} + plat: ${{ matrix.plat }} + os: ${{ matrix.os }} + arch: ${{ matrix.arch }} + static: ${{ matrix.static }}