Update dependency Microsoft.NET.Test.Sdk to v17.11.0 #656
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Development workflow | |
on: [push] | |
env: | |
DOTNET_CLI_TELEMETRY_OPTOUT: true | |
DOTNET_SKIP_FIRST_TIME_EXPERIENCE: true | |
DOTNET_NOLOGO: true | |
permissions: | |
contents: write | |
discussions: write | |
jobs: | |
build: | |
name: Build and Test | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v3 | |
- name: Fetch all history for all tags and branches | |
run: | | |
git config remote.origin.url https://x-access-token:${{ secrets.GITHUB_TOKEN }}@github.com/${{ github.repository }} | |
git fetch --prune --unshallow | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v2 | |
- name: Setup .NET Core | |
uses: actions/setup-dotnet@master | |
with: | |
dotnet-version: 7.0.x | |
- name: Install GitVersion | |
uses: gittools/actions/gitversion/setup@v0.10.2 | |
with: | |
versionSpec: '5.x' | |
env: | |
DOTNET_SYSTEM_GLOBALIZATION_INVARIANT: true | |
- name: Use GitVersion | |
id: gitversion | |
uses: gittools/actions/gitversion/execute@v0.10.2 | |
- name: Build .NET solution | |
env: | |
SemVer: ${{ steps.gitversion.outputs.semVer }} | |
run: | | |
dotnet --version | |
dotnet build ./EmojiVoto.sln --configuration Release | |
- name: Test .NET solution | |
run: | | |
dotnet --version | |
dotnet test /p:CollectCoverage=true /p:CoverletOutputFormat=opencover ./EmojiVoto.sln --configuration Release | |
- name: CodeCov | |
uses: codecov/codecov-action@v3 | |
publish: | |
name: Publish Docker image | |
runs-on: ubuntu-latest | |
needs: [build] | |
strategy: | |
fail-fast: true | |
matrix: | |
include: | |
- svcName: EmojiSvc | |
svcDockerName: bravecobra/emoji-svc | |
- svcName: EmojiVoting | |
svcDockerName: bravecobra/emoji-voting-svc | |
- svcName: EmojiUI | |
svcDockerName: bravecobra/emoji-ui-svc | |
- svcName: EmojiVoteBot | |
svcDockerName: bravecobra/emoji-votebot | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v3 | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v2 | |
- name: Fetch all history for all tags and branches | |
run: | | |
git config remote.origin.url https://x-access-token:${{ secrets.GITHUB_TOKEN }}@github.com/${{ github.repository }} | |
git fetch --prune --unshallow | |
- name: Setup .NET Core | |
uses: actions/setup-dotnet@master | |
with: | |
dotnet-version: 7.0.x | |
- name: Install GitVersion | |
uses: gittools/actions/gitversion/setup@v0.10.2 | |
with: | |
versionSpec: '5.x' | |
env: | |
DOTNET_SYSTEM_GLOBALIZATION_INVARIANT: true | |
- name: Use GitVersion | |
id: gitversion | |
uses: gittools/actions/gitversion/execute@v0.10.2 | |
- name: Docker meta | |
id: meta | |
uses: docker/metadata-action@v4 | |
with: | |
images: ${{ matrix.svcDockerName }} | |
flavor: | | |
latest=false | |
tags: | | |
type=raw,enable=${{ github.ref == 'refs/heads/develop' }},value=latest | |
type=raw,enable=${{ github.ref == 'refs/heads/master' }},value=stable | |
type=raw,value=ci | |
type=semver,pattern={{version}},value=${{ steps.gitversion.outputs.semVer }} | |
- name: Login to DockerHub | |
uses: docker/login-action@v2 | |
# if: github.ref == 'refs/heads/master' || github.ref == 'refs/heads/develop' || contains(github.ref, 'refs/tags') || contains(github.ref, 'refs/heads/release') || contains(github.ref, 'refs/heads/hotfix') | |
with: | |
username: ${{ secrets.DOCKERHUB_USERNAME }} | |
password: ${{ secrets.DOCKERHUB_TOKEN }} | |
- name: Build and push ${{ matrix.svcName }} image | |
uses: docker/build-push-action@v4 | |
if: github.ref == 'refs/heads/master' || github.ref == 'refs/heads/develop' || contains(github.ref, 'refs/tags') || contains(github.ref, 'refs/heads/release') || contains(github.ref, 'refs/heads/hotfix') | |
env: | |
SemVer: ${{ steps.gitversion.outputs.semVer }} | |
with: | |
context: . | |
file: src/${{ matrix.svcName }}/Dockerfile | |
push: true | |
tags: ${{ steps.meta.outputs.tags }} | |
labels: ${{ steps.meta.outputs.labels }} | |
- name: Build and push ${{ matrix.svcName }} image | |
uses: docker/build-push-action@v4 | |
env: | |
SemVer: ${{ steps.gitversion.outputs.semVer }} | |
with: | |
context: . | |
file: src/${{ matrix.svcName }}/Dockerfile | |
tags: ${{ steps.meta.outputs.tags }} | |
labels: ${{ steps.meta.outputs.labels }} | |
outputs: type=docker,dest=${{ matrix.svcName }}.tar | |
- name: Upload artifact | |
uses: actions/upload-artifact@v3 | |
with: | |
name: ${{ matrix.svcName }} | |
path: ${{ matrix.svcName }}.tar | |
docker-run: | |
name: Test Docker-Compose scenarios | |
runs-on: ubuntu-latest | |
needs: [publish] | |
strategy: | |
matrix: | |
profile: [individual, grafana, otlp] | |
steps: | |
# need checkout before using compose-action | |
- name: Checkout | |
uses: actions/checkout@v3 | |
- name: Download artifact | |
uses: actions/download-artifact@v3 | |
- name: Load Docker image | |
run: | | |
find . -type f -name '*.tar' -exec docker load --input {} \; | |
docker image ls -a | |
- name: Docker-compose up | |
run: | | |
TAG=ci docker-compose --profile app --profile ${{ matrix.profile }} -f docker-compose.yml -f ./docker-compose/docker-compose.${{ matrix.profile }}.yaml up -d --remove-orphans | |
- name: Letting the bot vote | |
if: ${{ matrix.profile != 'individual' }} | |
run: | | |
sleep 90 | |
- name: Run newman tests | |
uses: matt-ball/newman-action@master | |
if: ${{ matrix.profile != 'individual' }} | |
with: | |
collection: ./tests/${{ matrix.profile }}/EmojiVoto.postman_collection.json | |
- name: Docker-compose down | |
run: | | |
TAG=ci docker-compose --profile app --profile ${{ matrix.profile }} -f docker-compose.yml -f ./docker-compose/docker-compose.${{ matrix.profile }}.yaml down --volumes | |
release: | |
runs-on: ubuntu-latest | |
name: Generate Release | |
needs: [docker-run] | |
if: startsWith(github.ref, 'refs/tags') | |
steps: | |
- name: Build Release | |
uses: softprops/action-gh-release@v1 | |
with: | |
generate_release_notes: true | |
discussion_category_name: Announcements | |
append_body: true |