|
8 | 8 | DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }}
|
9 | 9 |
|
10 | 10 | jobs:
|
11 |
| - build: |
| 11 | + |
| 12 | + version: |
| 13 | + |
12 | 14 | runs-on: ubuntu-latest
|
13 | 15 | timeout-minutes: 30
|
| 16 | + outputs: |
| 17 | + version: ${{ steps.version.outputs.version }} |
| 18 | + |
14 | 19 | steps:
|
| 20 | + |
15 | 21 | - name: Checkout
|
16 | 22 | uses: actions/checkout@v3
|
17 | 23 | with:
|
18 | 24 | fetch-depth: 0
|
| 25 | + |
19 | 26 | - name: Build Reason
|
20 | 27 | env:
|
21 | 28 | GITHUB_EVENT: ${{ toJson(github) }}
|
22 | 29 | run: "echo ref: ${{github.ref}} event: ${{github.event_name}}"
|
| 30 | + |
| 31 | + - name: Version |
| 32 | + id: version |
| 33 | + run: | |
| 34 | + dotnet tool install --global minver-cli --version 4.3.0 |
| 35 | + version=$(minver --tag-prefix v) |
| 36 | + echo "version=$version" >> $GITHUB_OUTPUT |
| 37 | + echo "### $version" >> $GITHUB_STEP_SUMMARY |
| 38 | +
|
| 39 | + test-api: |
| 40 | + |
| 41 | + runs-on: ubuntu-latest |
| 42 | + timeout-minutes: 30 |
| 43 | + |
| 44 | + steps: |
| 45 | + |
| 46 | + - name: Checkout |
| 47 | + uses: actions/checkout@v3 |
| 48 | + with: |
| 49 | + fetch-depth: 0 |
| 50 | + |
23 | 51 | - name: Setup .NET Core
|
24 | 52 | uses: actions/setup-dotnet@v3
|
25 | 53 | with:
|
26 | 54 | dotnet-version: 7.0.*
|
27 | 55 | dotnet-quality: ga
|
28 |
| - - name: Build Version |
29 |
| - run: | |
30 |
| - dotnet tool install --global minver-cli --version 4.3.0 |
31 |
| - version=$(minver --tag-prefix v) |
32 |
| - echo "MINVERVERSIONOVERRIDE=$version" >> $GITHUB_ENV |
33 |
| - echo "VERSION=$version" >> $GITHUB_ENV |
34 |
| - echo "### Version: $version" >> $GITHUB_STEP_SUMMARY |
35 |
| - - name: Lint .NET |
36 |
| - run: dotnet format --verify-no-changes --no-restore --verbosity diagnostic |
37 |
| - - name: Build |
38 |
| - run: dotnet build --configuration Release /clp:NoSummary |
| 56 | + |
39 | 57 | - name: Start Services
|
| 58 | + working-directory: docker |
| 59 | + run: docker compose up -d elasticsearch & |
| 60 | + |
| 61 | + - uses: actions/cache@v3 |
| 62 | + with: |
| 63 | + path: ~/.nuget/packages |
| 64 | + key: nuget-${{ runner.os }}-${{ hashFiles('**/packages.lock.json') }} |
| 65 | + restore-keys: | |
| 66 | + nuget-${{ runner.os }}- |
| 67 | +
|
| 68 | + - name: Nuget Restore |
| 69 | + run: dotnet restore |
| 70 | + |
| 71 | + - name: Build |
| 72 | + run: dotnet build --no-restore --configuration Release |
| 73 | + |
| 74 | + - name: Wait for Elasticsearch |
40 | 75 | working-directory: docker
|
41 | 76 | run: docker compose up --wait elasticsearch
|
42 |
| - - name: Run Tests |
43 |
| - run: dotnet test --configuration Release --no-build --logger GitHubActions |
| 77 | + |
| 78 | + - name: Run .NET Tests |
| 79 | + run: dotnet test --no-restore --no-build --configuration Release --collect:"XPlat Code Coverage" -m:1 --logger trx --results-directory coverage --logger GitHubActions |
| 80 | + |
| 81 | + - name: Copy Coverage to Predictable Location |
| 82 | + run: cp coverage/*/coverage.cobertura.xml coverage/coverage.cobertura.xml |
| 83 | + |
| 84 | + - name: Code Coverage Summary Report |
| 85 | + |
| 86 | + with: |
| 87 | + filename: coverage/coverage.cobertura.xml |
| 88 | + badge: true |
| 89 | + format: "markdown" |
| 90 | + output: "both" |
| 91 | + |
| 92 | + - name: Add Coverage PR Comment |
| 93 | + uses: marocchino/sticky-pull-request-comment@v2 |
| 94 | + if: github.event_name == 'pull_request' |
| 95 | + with: |
| 96 | + recreate: true |
| 97 | + path: code-coverage-results.md |
| 98 | + |
| 99 | + - name: Write Coverage to Job Summary |
| 100 | + run: cat code-coverage-results.md >> $GITHUB_STEP_SUMMARY |
| 101 | + |
| 102 | + test-client: |
| 103 | + |
| 104 | + runs-on: ubuntu-latest |
| 105 | + timeout-minutes: 30 |
| 106 | + defaults: |
| 107 | + run: |
| 108 | + working-directory: ./src/Exceptionless.Web/ClientApp |
| 109 | + |
| 110 | + steps: |
| 111 | + |
| 112 | + - name: Checkout |
| 113 | + uses: actions/checkout@v3 |
| 114 | + with: |
| 115 | + fetch-depth: 0 |
| 116 | + |
| 117 | + - name: Setup .NET Core |
| 118 | + uses: actions/setup-dotnet@v3 |
| 119 | + with: |
| 120 | + dotnet-version: 7.0.* |
| 121 | + dotnet-quality: ga |
| 122 | + |
| 123 | + - name: Cache node_modules |
| 124 | + uses: actions/cache@v3 |
| 125 | + with: |
| 126 | + path: | |
| 127 | + node_modules |
| 128 | + key: node-modules-${{ hashFiles('package-lock.json') }} |
| 129 | + |
44 | 130 | - name: Setup Node.js environment
|
45 | 131 | uses: actions/setup-node@v3
|
46 | 132 | with:
|
47 | 133 | node-version: 18
|
| 134 | + |
48 | 135 | - name: Install Npm Packages
|
49 |
| - working-directory: src/Exceptionless.Web/ClientApp |
50 | 136 | run: npm ci
|
| 137 | + |
51 | 138 | - name: Lint Client
|
52 |
| - working-directory: src/Exceptionless.Web/ClientApp |
53 |
| - run: | |
54 |
| - npm run lint |
55 |
| - npm run prettier:check |
| 139 | + run: npm run lint |
| 140 | + |
| 141 | + - name: Run Unit Tests |
| 142 | + run: echo "npm run test:unit" |
| 143 | + |
| 144 | + - name: Run Integration Tests |
| 145 | + run: echo "npm run test:integration" |
| 146 | + |
| 147 | + build-docker: |
| 148 | + |
| 149 | + runs-on: ubuntu-latest |
| 150 | + needs: [version] |
| 151 | + timeout-minutes: 30 |
| 152 | + env: |
| 153 | + VERSION: ${{needs.version.outputs.version}} |
| 154 | + |
| 155 | + steps: |
| 156 | + |
| 157 | + - name: Checkout |
| 158 | + uses: actions/checkout@v3 |
| 159 | + with: |
| 160 | + fetch-depth: 0 |
| 161 | + |
56 | 162 | - name: Set up Docker Buildx
|
57 | 163 | if: "${{ env.DOCKER_USERNAME != '' }}"
|
58 | 164 | uses: docker/setup-buildx-action@v2
|
59 | 165 | with:
|
60 | 166 | platforms: linux/amd64
|
| 167 | + |
| 168 | + - name: Build api docker image |
| 169 | + run: | |
| 170 | + echo "::remove-matcher owner=csc::" |
| 171 | + docker buildx build . --target api --platform linux/amd64 --tag exceptionless/api-ci:latest --cache-from type=gha --cache-to type=gha,mode=max --load |
| 172 | +
|
| 173 | + - name: Build job docker image |
| 174 | + run: | |
| 175 | + echo "::remove-matcher owner=csc::" |
| 176 | + docker buildx build . --target job --platform linux/amd64 --tag exceptionless/job-ci:latest --cache-from type=gha --cache-to type=gha,mode=max --load |
| 177 | +
|
| 178 | + - name: Build app docker image |
| 179 | + run: | |
| 180 | + echo "::remove-matcher owner=csc::" |
| 181 | + docker buildx build . --target app --platform linux/amd64 --tag exceptionless/app-ci:latest --cache-from type=gha --cache-to type=gha,mode=max --load |
| 182 | +
|
| 183 | + - name: Build all-in-one docker image |
| 184 | + run: | |
| 185 | + echo "::remove-matcher owner=csc::" |
| 186 | + docker buildx build . --target exceptionless --platform linux/amd64 --tag exceptionless/exceptionless-ci:latest --cache-from type=gha --cache-to type=gha,mode=max --load |
| 187 | +
|
| 188 | + - name: Build all-in-one Elasticsearch 7 docker image |
| 189 | + if: "${{ env.DOCKER_USERNAME != '' && startsWith(github.ref, 'refs/tags/v') && github.event_name != 'pull_request' }}" |
| 190 | + run: | |
| 191 | + echo "::remove-matcher owner=csc::" |
| 192 | + docker buildx build . --target exceptionless7 --platform linux/amd64 --tag exceptionless/exceptionless:latest-elasticsearch7 --cache-from type=gha --cache-to type=gha,mode=max --load |
| 193 | +
|
61 | 194 | - name: Login to GitHub Container Registry
|
62 | 195 | if: "${{ env.DOCKER_USERNAME != '' }}"
|
63 | 196 | uses: docker/login-action@v2
|
64 | 197 | with:
|
65 | 198 | registry: ghcr.io
|
66 | 199 | username: ${{ github.actor }}
|
67 | 200 | password: ${{ secrets.GITHUB_TOKEN }}
|
| 201 | + |
68 | 202 | - name: Login to DockerHub
|
69 | 203 | if: "${{ env.DOCKER_USERNAME != '' }}"
|
70 | 204 | uses: docker/login-action@v2
|
71 | 205 | with:
|
72 | 206 | username: ${{ env.DOCKER_USERNAME }}
|
73 | 207 | password: ${{ secrets.DOCKER_PASSWORD }}
|
| 208 | + |
| 209 | + - name: Wait for test jobs |
| 210 | + uses: yogeshlonkar/wait-for-jobs@v0 |
| 211 | + with: |
| 212 | + jobs: 'test-api,test-client' |
| 213 | + interval: '2500' |
| 214 | + ttl: '10' |
| 215 | + |
74 | 216 | - name: Publish CI Packages
|
75 | 217 | if: "${{ env.DOCKER_USERNAME != '' }}"
|
76 | 218 | run: |
|
77 | 219 | echo "::remove-matcher owner=csc::"
|
78 |
| - # tag and push docker image |
| 220 | + # tag and push docker images |
| 221 | +
|
79 | 222 | for image in {"api","job","app","exceptionless"}; do
|
80 |
| - docker buildx build --target $image --platform linux/amd64 --output "type=image,push=true" . --tag exceptionless/$image-ci:$VERSION --tag exceptionless/$image-ci:latest --tag ghcr.io/exceptionless/exceptionless/$image:$VERSION --tag ghcr.io/exceptionless/exceptionless/$image:latest |
| 223 | + docker image tag exceptionless/$image-ci:latest exceptionless/$image-ci:$VERSION |
| 224 | + docker image tag exceptionless/$image-ci:latest ghcr.io/exceptionless/exceptionless/$image-ci:$VERSION |
| 225 | + docker image tag exceptionless/$image-ci:latest ghcr.io/exceptionless/exceptionless/$image-ci:latest |
| 226 | +
|
| 227 | + docker image push --all-tags exceptionless/$image-ci |
81 | 228 | done
|
82 |
| - #docker buildx build --target exceptionless7 --platform linux/amd64 --output "type=image,push=true" . --tag exceptionless/exceptionless-ci:$VERSION-elasticsearch7 --tag exceptionless/exceptionless-ci:latest-elasticsearch7 --tag ghcr.io/exceptionless/exceptionless/exceptionless:$VERSION-elasticsearch7 --tag ghcr.io/exceptionless/exceptionless/exceptionless:latest-elasticsearch7 |
| 229 | +
|
83 | 230 | - name: Publish Release Packages
|
84 | 231 | if: "${{ env.DOCKER_USERNAME != '' && startsWith(github.ref, 'refs/tags/v') && github.event_name != 'pull_request' }}"
|
85 | 232 | run: |
|
86 |
| - # tag and push docker image |
| 233 | + echo "::remove-matcher owner=csc::" |
| 234 | + # tag and push docker images |
| 235 | +
|
| 236 | + # only build elasticsearch 7 all-in-one image for release builds |
| 237 | + docker image tag exceptionless/exceptionless:latest-elasticsearch7 exceptionless/exceptionless:$VERSION-elasticsearch7 |
| 238 | +
|
87 | 239 | for image in {"api","job","app","exceptionless"}; do
|
88 |
| - docker buildx build --target $image --platform linux/amd64 --output "type=image,push=true" . --tag exceptionless/$image:$VERSION --tag exceptionless/$image:latest |
| 240 | + docker image tag exceptionless/$image-ci:latest exceptionless/$image:$VERSION |
| 241 | + docker image tag exceptionless/$image-ci:latest exceptionless/$image:latest |
| 242 | +
|
| 243 | + docker image push --all-tags exceptionless/$image |
89 | 244 | done
|
90 |
| - docker buildx build --target exceptionless7 --platform linux/amd64 --output "type=image,push=true" . --tag exceptionless/exceptionless:$VERSION-elasticsearch7 --tag exceptionless/exceptionless:latest-elasticsearch7 |
| 245 | +
|
| 246 | + deploy: |
| 247 | + if: "${{ (github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/v')) && github.event_name != 'pull_request' }}" |
| 248 | + needs: [version,build-docker] |
| 249 | + runs-on: ubuntu-latest |
| 250 | + timeout-minutes: 30 |
| 251 | + env: |
| 252 | + VERSION: ${{needs.version.outputs.version}} |
| 253 | + |
| 254 | + steps: |
| 255 | + |
91 | 256 | - name: Install Helm
|
92 | 257 | if: "${{ env.DOCKER_USERNAME != '' && github.event_name != 'pull_request' }}"
|
93 | 258 | uses: azure/setup-helm@v3
|
94 | 259 | with:
|
95 |
| - version: v3.11.1 |
| 260 | + version: v3.13.0 |
| 261 | + |
96 | 262 | - name: Deploy Changes to Development Environment
|
97 | 263 | if: "${{ env.DOCKER_USERNAME != '' && github.ref == 'refs/heads/main' && github.event_name != 'pull_request' }}"
|
98 | 264 | run: |
|
99 | 265 | az login --service-principal --username ${{ secrets.AZ_USERNAME }} --password ${{ secrets.AZ_PASSWORD }} --tenant ${{ secrets.AZ_TENANT }} --output none
|
100 | 266 | az aks get-credentials --resource-group exceptionless-v6 --name ex-k8s-v6
|
101 | 267 | sed -i "s/^appVersion:.*$/appVersion: '${VERSION}'/" ./k8s/exceptionless/Chart.yaml
|
102 | 268 | helm upgrade --set "version=${VERSION}" --reuse-values --values ./k8s/ex-dev-values.yaml ex-dev --namespace ex-dev ./k8s/exceptionless
|
| 269 | +
|
103 | 270 | - name: Deploy Changes to Production Environment
|
104 | 271 | if: "${{ env.DOCKER_USERNAME != '' && startsWith(github.ref, 'refs/tags/v') && github.event_name != 'pull_request' }}"
|
105 | 272 | run: |
|
|
0 commit comments