Skip to content

Commit fdb73f5

Browse files
committed
Initial creation of CI workflow
1 parent 7e01e38 commit fdb73f5

File tree

1 file changed

+122
-0
lines changed

1 file changed

+122
-0
lines changed

.github/workflows/ci.yml

Lines changed: 122 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,122 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
paths-ignore:
8+
- '*.md'
9+
pull_request:
10+
paths-ignore:
11+
- '*.md'
12+
13+
# The run name, either 'CubeKit PR Validation' if via a PR, or just 'CubeKit CI' if activated another way.
14+
run-name: ${{ github.event_name == 'pull_request' && 'CubeKit PR Validation' || 'CubeKit CI' }}
15+
16+
# Environment variables. No values should be hardcoded, they should all be accessible as an environment variable.
17+
env:
18+
# MSBuild file locations
19+
WORKING_DIR: ${{ github.workspace }}
20+
SOLUTION_PATH: '${{ github.workspace }}\CubeKit.sln'
21+
HEAD_PROJECTS_DIR: '${{ github.workspace }}\src\platforms'
22+
HEAD_EXTENSIONS_DIR: '${{ github.workspace }}\src\extensions'
23+
# Build configurations and tests
24+
AUTOMATED_TESTS_ARCHITECTURE: 'x64'
25+
AUTOMATED_TESTS_CONFIGURATION: 'Release'
26+
# AUTOMATED_TESTS_PROJECT_DIR: '${{ github.workspace }}\tests\Files.InteractionTests'
27+
# AUTOMATED_TESTS_PROJECT_PATH: '${{ github.workspace }}\tests\Files.InteractionTests\Files.InteractionTests.csproj'
28+
# AUTOMATED_TESTS_ASSEMBLY_DIR: '${{ github.workspace }}\artifacts\TestsAssembly'
29+
ARTIFACTS_STAGING_DIR: '${{ github.workspace }}\artifacts'
30+
31+
# Runner jobs
32+
jobs:
33+
# This is a simple workflow that checks the formatting of XAML.
34+
# XAML is not used in many places in CubeKit, but ensuring that
35+
# it is formatted is imperative nonetheless.
36+
# TODO: Migrate this to a separate workflow in another repository
37+
check-formatting:
38+
name: Check Formatting
39+
40+
if: github.repository_owner == 'RiversideValley'
41+
42+
runs-on: windows-latest
43+
44+
steps:
45+
46+
- name: Checkout the repository
47+
uses: actions/checkout@v4
48+
with:
49+
fetch-depth: 2
50+
- name: Setup .NET 8
51+
uses: actions/setup-dotnet@v4
52+
53+
- name: Install XamlStyler.Console
54+
run: 'dotnet tool install --global XamlStyler.Console'
55+
56+
- name: Check XAML formatting
57+
id: check-step
58+
run: |
59+
$changedFiles = (git diff --diff-filter=d --name-only HEAD~1) -split "\n" | Where-Object {$_ -like "*.xaml"}
60+
foreach ($file in $changedFiles)
61+
{
62+
xstyler -p -l None -f $file
63+
if ($LASTEXITCODE -ne 0)
64+
{
65+
echo "::error file=$file::Format check failed"
66+
}
67+
}
68+
continue-on-error: true
69+
70+
- name: Fail if necessary
71+
if: steps.check-step.outcome == 'failure'
72+
run: exit 1
73+
74+
build:
75+
name: Build
76+
77+
if: github.repository_owner == 'RiversideValley'
78+
79+
runs-on: windows-latest
80+
strategy:
81+
fail-fast: false
82+
matrix:
83+
configuration: [Debug, Release]
84+
platform: [Any CPU]
85+
env:
86+
CONFIGURATION: ${{ matrix.configuration }}
87+
ARCHITECTURE: ${{ matrix.platform }}
88+
SLN_CONFIG_VALUE: ${{ matrix.configuration }}|${{ matrix.platform }}
89+
90+
steps:
91+
92+
- name: Checkout the repository
93+
uses: actions/checkout@v4
94+
- name: Setup MSBuild
95+
uses: microsoft/setup-msbuild@v2
96+
- name: Setup NuGet
97+
uses: NuGet/setup-nuget@v2
98+
- name: Setup .NET
99+
uses: actions/setup-dotnet@v4
100+
with:
101+
dotnet-version: 9.x
102+
103+
- name: Restore NuGet
104+
shell: pwsh
105+
run: 'nuget restore $env:SOLUTION_PATH'
106+
107+
- name: Restore project
108+
shell: pwsh
109+
run: |
110+
msbuild $env:SOLUTION_PATH `
111+
-t:Restore `
112+
-p:Platform=$env:ARCHITECTURE `
113+
-p:Configuration=$env:CONFIGURATION
114+
115+
- name: Build CubeKit
116+
run: |
117+
msbuild `
118+
$env:PACKAGE_PROJECT_PATH `
119+
-t:Build `
120+
-clp:ErrorsOnly `
121+
-p:Configuration=$env:CONFIGURATION `
122+
-p:Platform=$env:ARCHITECTURE

0 commit comments

Comments
 (0)