Skip to content

CI

CI #55

Workflow file for this run

name: CI
on:
push:
branches: [ main ]
tags:
- 'v*'
pull_request:
branches: [ main ]
schedule:
- cron: '0 7 * * *'
workflow_dispatch:
jobs:
build:
strategy:
fail-fast: false
matrix:
runner-os: [windows-latest, ubuntu-latest, macos-latest]
runs-on: ${{ matrix.runner-os }}
steps:
- uses: actions/checkout@v4
- name: Initialize CodeQL
if: matrix.runner-os == 'ubuntu-latest'
uses: github/codeql-action/init@v2
with:
languages: 'csharp'
config-file: ./.github/codeql/codeql-config.yml
- name: Setup .NET
uses: actions/setup-dotnet@v2
with:
global-json-file: global.json
- name: dotnet format
run: dotnet format src/OctoshiftCLI.sln --verify-no-changes
- name: Restore dependencies
run: dotnet restore src/OctoshiftCLI.sln
- name: Build
run: dotnet build src/OctoshiftCLI.sln --no-restore /p:TreatWarningsAsErrors=true
- name: Unit Test
run: dotnet test src/OctoshiftCLI.Tests/OctoshiftCLI.Tests.csproj --no-build --verbosity normal --logger:"junit;LogFilePath=unit-tests.xml" --collect:"XPlat Code Coverage" --results-directory ./coverage
- name: Copy Coverage To Predictable Location
if: always() && matrix.runner-os == 'ubuntu-latest'
run: cp coverage/**/coverage.cobertura.xml coverage/coverage.cobertura.xml
- name: Code Coverage Summary Report
uses: irongut/[email protected]
if: always() && matrix.runner-os == 'ubuntu-latest'
with:
filename: coverage/coverage.cobertura.xml
badge: true
format: 'markdown'
output: 'both'
# This is used by the subsequent publish-test-results.yml
- name: Upload Unit Test Results
if: always() && matrix.runner-os == 'ubuntu-latest'
uses: actions/upload-artifact@v3
with:
name: Unit Test Results
path: src/OctoshiftCLI.Tests/unit-tests.xml
# This is used by the subsequent publish-test-results.yml
- name: Upload Code Coverage Report
if: always() && matrix.runner-os == 'ubuntu-latest'
uses: actions/upload-artifact@v3
with:
name: Code Coverage Report
path: code-coverage-results.md
upload-event-file:
runs-on: ubuntu-latest
steps:
# This is used by the subsequent publish-test-results.yaml
- name: Upload Event File
uses: actions/upload-artifact@v3
with:
name: Event File
path: ${{ github.event_path }}
build-for-e2e-test:
if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.owner.login == 'github'
strategy:
fail-fast: false
matrix:
target-os: [windows-latest, ubuntu-latest, macos-latest]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Setup .NET
uses: actions/setup-dotnet@v2
with:
global-json-file: global.json
- name: Build Artifacts (Linux)
if: matrix.target-os == 'ubuntu-latest'
run: ./publish.ps1
shell: pwsh
env:
SKIP_WINDOWS: "true"
SKIP_MACOS: "true"
- name: Build Artifacts (Windows)
if: matrix.target-os == 'windows-latest'
run: ./publish.ps1
shell: pwsh
env:
SKIP_LINUX: "true"
SKIP_MACOS: "true"
- name: Build Artifacts (MacOS)
if: matrix.target-os == 'macos-latest'
run: ./publish.ps1
shell: pwsh
env:
SKIP_WINDOWS: "true"
SKIP_LINUX: "true"
- name: Upload Binaries
uses: actions/upload-artifact@v3
with:
name: binaries-${{ matrix.target-os }}
path: |
dist/linux-x64/ado2gh-linux-amd64
dist/linux-x64/bbs2gh-linux-amd64
dist/linux-x64/gei-linux-amd64
dist/osx-x64/ado2gh-darwin-amd64
dist/osx-x64/bbs2gh-darwin-amd64
dist/osx-x64/gei-darwin-amd64
dist/win-x64/ado2gh-windows-amd64.exe
dist/win-x64/bbs2gh-windows-amd64.exe
dist/win-x64/gei-windows-amd64.exe
e2e-test:
if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.owner.login == 'github'
needs: [ build-for-e2e-test ]
strategy:
fail-fast: false
matrix:
runner-os: [windows-latest, ubuntu-latest, macos-latest]
source-vcs: [AdoBasic, AdoCsv, Bbs, Ghes, Github]
runs-on: ${{ matrix.runner-os }}
concurrency: integration-test-${{ matrix.source-vcs }}-${{ matrix.runner-os }}
steps:
- uses: actions/checkout@v4
- name: Setup .NET
uses: actions/setup-dotnet@v2
with:
global-json-file: global.json
- name: Download Binaries
uses: actions/download-artifact@v3
with:
name: binaries-${{ matrix.runner-os }}
path: dist
- name: Copy binary to root (linux)
if: matrix.runner-os == 'ubuntu-latest'
run: |
New-Item -Path "./" -Name "gh-gei" -ItemType "directory"
New-Item -Path "./" -Name "gh-ado2gh" -ItemType "directory"
New-Item -Path "./" -Name "gh-bbs2gh" -ItemType "directory"
Copy-Item ./dist/linux-x64/gei-linux-amd64 ./gh-gei/gh-gei
Copy-Item ./dist/linux-x64/ado2gh-linux-amd64 ./gh-ado2gh/gh-ado2gh
Copy-Item ./dist/linux-x64/bbs2gh-linux-amd64 ./gh-bbs2gh/gh-bbs2gh
shell: pwsh
- name: Copy binary to root (windows)
if: matrix.runner-os == 'windows-latest'
run: |
New-Item -Path "./" -Name "gh-gei" -ItemType "directory"
New-Item -Path "./" -Name "gh-ado2gh" -ItemType "directory"
New-Item -Path "./" -Name "gh-bbs2gh" -ItemType "directory"
Copy-Item ./dist/win-x64/gei-windows-amd64.exe ./gh-gei/gh-gei.exe
Copy-Item ./dist/win-x64/ado2gh-windows-amd64.exe ./gh-ado2gh/gh-ado2gh.exe
Copy-Item ./dist/win-x64/bbs2gh-windows-amd64.exe ./gh-bbs2gh/gh-bbs2gh.exe
shell: pwsh
- name: Copy binary to root (macos)
if: matrix.runner-os == 'macos-latest'
run: |
New-Item -Path "./" -Name "gh-gei" -ItemType "directory"
New-Item -Path "./" -Name "gh-ado2gh" -ItemType "directory"
New-Item -Path "./" -Name "gh-bbs2gh" -ItemType "directory"
Copy-Item ./dist/osx-x64/gei-darwin-amd64 ./gh-gei/gh-gei
Copy-Item ./dist/osx-x64/ado2gh-darwin-amd64 ./gh-ado2gh/gh-ado2gh
Copy-Item ./dist/osx-x64/bbs2gh-darwin-amd64 ./gh-bbs2gh/gh-bbs2gh
shell: pwsh
- name: Set execute permissions
run: |
chmod +x ./gh-gei/gh-gei
chmod +x ./gh-ado2gh/gh-ado2gh
chmod +x ./gh-bbs2gh/gh-bbs2gh
- name: Install gh-gei extension
run: gh extension install .
shell: pwsh
working-directory: ./gh-gei
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Install gh-ado2gh extension
run: gh extension install .
shell: pwsh
working-directory: ./gh-ado2gh
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Install gh-bbs2gh extension
run: gh extension install .
shell: pwsh
working-directory: ./gh-bbs2gh
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
publish:
runs-on: ubuntu-latest
needs: [ build, e2e-test ]
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Setup .NET
uses: actions/setup-dotnet@v2
with:
global-json-file: global.json
- name: Build Artifacts
run: ./publish.ps1
shell: pwsh
env:
CLI_VERSION: "99.99.99"
- name: Upload Artifacts
uses: actions/upload-artifact@v3
with:
name: All Builds
path: ./dist/