-
Notifications
You must be signed in to change notification settings - Fork 0
191 lines (166 loc) · 6.59 KB
/
Copy pathbuild-test-push.yml
File metadata and controls
191 lines (166 loc) · 6.59 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
# Copyright (c) Perpetual Intelligence L.L.C. All Rights Reserved.
#
# For license, terms, and data policies, go to:
# https://terms.perpetualintelligence.com
name: build-test-push
# 1 release at a time
concurrency: ${{ github.event.repository.name }}
# CICD. The rc and release are a manual trigger
on:
push:
branches: [ main ]
pull_request:
branches: [ main ]
workflow_dispatch:
inputs:
suffix:
type: choice
description: 'The package deployment suffix'
required: true
options:
- er
- rc
- release
default: er
registry:
type: choice
description: 'The package registry'
required: true
options:
- github
- nuget
default: github
jobs:
setup:
runs-on: ubuntu-latest
environment: github-release
timeout-minutes: 15
# Define environment variables to authenticate the package feeds
env:
PI_GITHUB_USERNAME_ENV: ${{ secrets.PI_GITHUB_USERNAME }}
PI_GITHUB_PAT_ENV: ${{ secrets.PI_GITHUB_PAT }}
PI_NUGET_PAT_ENV: ${{ secrets.PI_NUGET_API_KEY }}
PI_PUBLISH_REGISTRY: github
steps:
# Checkout
- name: Checkout
uses: actions/checkout@v6
# Read env
- name: Read Env
run: cat .github/package_version.env >> $GITHUB_ENV
continue-on-error: false
# Build Number
# Establish a unique build number for current run YYMMDD{RUN_NUMBER}{RUN_ATTEMPT}
- name: Build Number
run: echo "PI_BUILD_NUMBER=$(date +'%y%m%d')${{ github.run_number }}${{ github.run_attempt }}" >> $GITHUB_ENV
continue-on-error: false
# Setup preview package versions based on trigger
# Format: <package>.2.3.6-rc.2201032602
- name: Default metadata (rc)
if: ${{ github.event.inputs.suffix == '' }}
run: echo "PI_CI_PACKAGE_VERSION=${{ env.PI_MAJOR_VERSION }}.${{ env.PI_MINOR_VERSION }}.${{ env.PI_BUILD_VERSION }}-rc.${{ env.PI_BUILD_NUMBER }}" >> $GITHUB_ENV
continue-on-error: false
# Setup engineering package versions
# Format: <package>.2.3.6-er.2201032602
- name: Preview metadata
if: ${{ github.event.inputs.suffix == 'er' }}
run: echo "PI_CI_PACKAGE_VERSION=${{ env.PI_MAJOR_VERSION }}.${{ env.PI_MINOR_VERSION }}.${{ env.PI_BUILD_VERSION }}-er.${{ env.PI_BUILD_NUMBER }}" >> $GITHUB_ENV
continue-on-error: false
# Setup rc package versions
# Format: <package>.2.3.6-rc.2201032602
- name: RC metadata
if: ${{ github.event.inputs.suffix == 'rc' }}
run: echo "PI_CI_PACKAGE_VERSION=${{ env.PI_MAJOR_VERSION }}.${{ env.PI_MINOR_VERSION }}.${{ env.PI_BUILD_VERSION }}-rc.${{ env.PI_BUILD_NUMBER }}" >> $GITHUB_ENV
continue-on-error: false
# Setup release package versions
# Format: <package>.2.3.6
- name: Release metadata
if: ${{ github.event.inputs.suffix == 'release' }}
run: echo "PI_CI_PACKAGE_VERSION=${{ env.PI_MAJOR_VERSION }}.${{ env.PI_MINOR_VERSION }}.${{ env.PI_BUILD_VERSION }}" >> $GITHUB_ENV
continue-on-error: false
# Setup publish registry (github or nuget)
# PI_PUBLISH_REGISTRY defaults to github
- name: Registry metadata
if: ${{ github.event.inputs.registry != '' }}
run: echo "PI_PUBLISH_REGISTRY=${{ github.event.inputs.registry }}" >> $GITHUB_ENV
continue-on-error: false
# Print all env
- name: Print
if: ${{ false }} # Debug
run: |
env
ls
shell: bash
# Setup .Net with global.json
- name: Setup .NET
uses: actions/setup-dotnet@v5
# Setup ReportGenerator
- name: Setup ReportGenerator
run: dotnet tool install --global dotnet-reportgenerator-globaltool
continue-on-error: false
# OneImlx.Shared is the first package so we use the cross project reference to avoid cyclic Nuget dependency resolution.
# See OneImlx.Shared.Test.csproj for more info.
- name: Force cross
run: echo "PI_CI_REFERENCE=cross" >> $GITHUB_ENV
continue-on-error: false
# Publish OneImlx.Shared (deposits coverage into ./coverage)
- name: OneImlx.Shared
id: oneimlx-shared
uses: ./.github/actions/push-package
with:
project: OneImlx.Shared
config: Release
version: ${{ env.PI_CI_PACKAGE_VERSION }}
ghapikey: ${{ env.PI_GITHUB_PAT_ENV }}
nugetapikey: ${{ env.PI_NUGET_PAT_ENV }}
registry: ${{ env.PI_PUBLISH_REGISTRY }}
# Switch to package references for downstream packages
- name: Force package
run: echo "PI_CI_REFERENCE=package" >> $GITHUB_ENV
continue-on-error: false
# Publish OneImlx.Test
- name: OneImlx.Test
id: oneimlx-test
uses: ./.github/actions/push-package
with:
project: OneImlx.Test
config: Release
version: ${{ env.PI_CI_PACKAGE_VERSION }}
ghapikey: ${{ env.PI_GITHUB_PAT_ENV }}
nugetapikey: ${{ env.PI_NUGET_PAT_ENV }}
registry: ${{ env.PI_PUBLISH_REGISTRY }}
# Aggregate coverage report across all packages deposited into ./coverage
- name: Coverage Report
run: reportgenerator -reports:./coverage/**/coverage.cobertura.xml -targetdir:./coverage/report -reporttypes:JsonSummary
shell: bash
# Extract aggregate line and branch coverage
- name: Extract Coverage
id: coverage
run: |
echo "line=$(jq '.summary.linecoverage' ./coverage/report/Summary.json | xargs printf '%.0f')" >> $GITHUB_OUTPUT
echo "branch=$(jq '.summary.branchcoverage' ./coverage/report/Summary.json | xargs printf '%.0f')" >> $GITHUB_OUTPUT
shell: bash
# Update line coverage badge in Gist
- name: Line Coverage Badge
uses: Schneegans/dynamic-badges-action@v1.8.0
with:
auth: ${{ secrets.PI_GITHUB_GIST_PAT }}
gistID: ${{ secrets.PI_GITHUB_GIST_ID }}
filename: coverage_${{ github.event.repository.name }}_line.json
label: coverage-line
message: ${{ steps.coverage.outputs.line }}%
valColorRange: ${{ steps.coverage.outputs.line }}
maxColorRange: 100
minColorRange: 0
# Update branch coverage badge in Gist
- name: Branch Coverage Badge
uses: Schneegans/dynamic-badges-action@v1.8.0
with:
auth: ${{ secrets.PI_GITHUB_GIST_PAT }}
gistID: ${{ secrets.PI_GITHUB_GIST_ID }}
filename: coverage_${{ github.event.repository.name }}_branch.json
label: coverage-branch
message: ${{ steps.coverage.outputs.branch }}%
valColorRange: ${{ steps.coverage.outputs.branch }}
maxColorRange: 100
minColorRange: 0