Skip to content

Commit

Permalink
Refactor CI to use Matrix Strategy (#322)
Browse files Browse the repository at this point in the history
  • Loading branch information
sailro authored Apr 16, 2024
1 parent 1bf605d commit 7eb00d0
Show file tree
Hide file tree
Showing 7 changed files with 100 additions and 237 deletions.
13 changes: 0 additions & 13 deletions .github/actions/setvars/action.yml

This file was deleted.

2 changes: 0 additions & 2 deletions .github/variables/unity.env

This file was deleted.

71 changes: 0 additions & 71 deletions .github/workflows/ci-linux.yml

This file was deleted.

71 changes: 0 additions & 71 deletions .github/workflows/ci-macos.yml

This file was deleted.

99 changes: 99 additions & 0 deletions .github/workflows/ci-matrix.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
name: CI

on:
push:
branches:
- main
- release/*
pull_request:
branches:
- main
- release/*

env:
DOTNET_CLI_TELEMETRY_OPTOUT: 1
DOTNET_SKIP_FIRST_TIME_EXPERIENCE: 1
DOTNET_NOLOGO: 1
UNITY_HASH: '887be4894c44'
UNITY_FULL_VERSION: '2022.3.22f1'

jobs:
compute:
runs-on: ubuntu-latest
permissions:
actions: read
contents: read
deployments: read
packages: none
pull-requests: write
security-events: write
outputs:
UNITY_HASH: ${{ env.UNITY_HASH }}
UNITY_FULL_VERSION: ${{ env.UNITY_FULL_VERSION }}
steps:
- name: Compute outputs
run: |
echo "UNITY_HASH=${{ env.UNITY_HASH }}" >> $GITHUB_OUTPUT
echo "UNITY_FULL_VERSION=${{ env.UNITY_FULL_VERSION }}" >> $GITHUB_OUTPUT
ci:
strategy:
matrix:
include:
- os: ubuntu
download: curl -o ./Unity.tar.xz -k https://download.unity3d.com/download_unity/${{ needs.compute.outputs.UNITY_HASH }}/LinuxEditorInstaller/Unity.tar.xz
install: mkdir -p ~/Unity && tar -xf Unity.tar.xz -C ~/Unity
- os: macos
download: curl -o ./unity.pkg -k https://download.unity3d.com/download_unity/${{ needs.compute.outputs.UNITY_HASH }}/MacEditorInstaller/Unity.pkg
install: sudo installer -package unity.pkg -target /
- os: windows
download: cmd /c bitsadmin /TRANSFER unity /DOWNLOAD /PRIORITY foreground "https://download.unity3d.com/download_unity/${{ needs.compute.outputs.UNITY_HASH }}/Windows64EditorInstaller/UnitySetup64-${{ needs.compute.outputs.UNITY_FULL_VERSION }}.exe" "%CD%\unitysetup.exe"
install: cmd /c unitysetup.exe /UI=reduced /S /D=%ProgramFiles%\Unity
name: CI-${{ matrix.os }}
runs-on: ${{ matrix.os }}-latest
needs: compute
permissions:
actions: read
contents: read
deployments: read
packages: none
pull-requests: write
security-events: write

steps:
- name: Checkout
uses: actions/checkout@v4

- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: '8.0.x'

- name: Download Unity on ${{ matrix.os }}
run: ${{ matrix.download }}

- name: Install Unity on ${{ matrix.os }}
run: ${{ matrix.install }}

- name: Initialize CodeQL
uses: github/codeql-action/init@v3

- name: Build
run: dotnet build -c Debug ./src/Microsoft.Unity.Analyzers.sln /p:UseSharedCompilation=false

- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v3

- name: Test context (main)
if: github.ref == 'refs/heads/main'
run: echo "TEST_FILTER=." >> $GITHUB_ENV
shell: bash

- name: Test context (feature)
if: github.ref != 'refs/heads/main'
run: echo "TEST_FILTER=FullyQualifiedName!~ConsistencyTests" >> $GITHUB_ENV
shell: bash

- name: Test
run: dotnet test -c Debug ./src/Microsoft.Unity.Analyzers.Tests --filter ${{env.TEST_FILTER}}
shell: bash
77 changes: 0 additions & 77 deletions .github/workflows/ci-windows.yml

This file was deleted.

4 changes: 1 addition & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
# Analyzers for Unity

[![Build status on Windows](https://github.com/microsoft/Microsoft.Unity.Analyzers/workflows/CI-Windows/badge.svg)](https://github.com/microsoft/Microsoft.Unity.Analyzers/actions?query=workflow%3ACI-Windows)
[![Build status on macOS](https://github.com/microsoft/Microsoft.Unity.Analyzers/workflows/CI-macOS/badge.svg)](https://github.com/microsoft/Microsoft.Unity.Analyzers/actions?query=workflow%3ACI-macOS)
[![Build status on Linux](https://github.com/microsoft/Microsoft.Unity.Analyzers/workflows/CI-Linux/badge.svg)](https://github.com/microsoft/Microsoft.Unity.Analyzers/actions?query=workflow%3ACI-Linux)
[![Build status](https://github.com/microsoft/Microsoft.Unity.Analyzers/workflows/CI/badge.svg)](https://github.com/microsoft/Microsoft.Unity.Analyzers/actions?query=workflow%3ACI)
[![NuGet](https://img.shields.io/nuget/v/Microsoft.Unity.Analyzers.svg)](https://nuget.org/packages/Microsoft.Unity.Analyzers)

This project provides Visual Studio with a better understanding of Unity projects by adding Unity-specific diagnostics or by removing general C# diagnostics that do not apply to Unity projects.
Expand Down

0 comments on commit 7eb00d0

Please sign in to comment.