-
Notifications
You must be signed in to change notification settings - Fork 7
139 lines (134 loc) · 4.95 KB
/
slimfaas-ci.yaml
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
name: Docker Images CI
on:
push:
branches: [ main ]
pull_request:
branches: [ main ]
types: [opened, synchronize, reopened]
jobs:
sonarcloud:
name: SonarCloud
runs-on: windows-latest
steps:
- name: Set up JDK 17
uses: actions/setup-java@v3
with:
java-version: 17
distribution: 'zulu' # Alternative distribution options are available.
- uses: actions/checkout@v3
with:
fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis
- name: Cache SonarCloud packages
uses: actions/cache@v3
with:
path: ~\sonar\cache
key: ${{ runner.os }}-sonar
restore-keys: ${{ runner.os }}-sonar
- name: Cache SonarCloud scanner
id: cache-sonar-scanner
uses: actions/cache@v3
with:
path: .\.sonar\scanner
key: ${{ runner.os }}-sonar-scanner
restore-keys: ${{ runner.os }}-sonar-scanner
- uses: actions/setup-dotnet@v3
with:
global-json-file: global.json
- name: Install SonarCloud scanner
if: steps.cache-sonar-scanner.outputs.cache-hit != 'true'
shell: powershell
run: |
New-Item -Path .\.sonar\scanner -ItemType Directory
dotnet tool update dotnet-sonarscanner --tool-path .\.sonar\scanner
- name: Build and analyze
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
shell: powershell
run: |
.\.sonar\scanner\dotnet-sonarscanner begin /k:"AxaFrance_SlimFaas" /o:"axaguildev" /d:sonar.token="${{ secrets.SONAR_TOKEN }}" /d:sonar.host.url="https://sonarcloud.io" /d:sonar.cs.vscoveragexml.reportsPaths=coverage.xml
dotnet tool install --global dotnet-coverage
dotnet-coverage collect "dotnet test" -f xml -o "coverage.xml"
.\.sonar\scanner\dotnet-sonarscanner end /d:sonar.token="${{ secrets.SONAR_TOKEN }}"
unit_tests:
name: Unit Tests
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis
- uses: actions/setup-dotnet@v3
with:
global-json-file: global.json
- name: Run unit tests
run: |
dotnet test --collect "Code Coverage;Format=cobertura" --verbosity normal
- name: ReportGenerator
uses: danielpalme/[email protected]
with:
reports: './**/TestResults/**/*.cobertura.xml'
targetdir: 'coveragereport'
reporttypes: 'HtmlInline;MarkdownSummaryGithub'
- name: Upload coverage report artifact
uses: actions/[email protected]
with:
name: CoverageReport # Artifact name
path: coveragereport # Directory containing files to upload
tags:
needs: unit_tests
runs-on: ubuntu-latest
outputs:
new_version: ${{ steps.tag.outputs.new_version }}
steps:
- uses: actions/checkout@master
- name: Bump version and push tag
id: tag_version
if: github.ref == 'refs/heads/main'
uses: mathieudutour/[email protected]
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
- name: Add tag to output step for main branch
id: tag
run: |
if [ '${{ github.ref }}' = 'refs/heads/main' ]; then
echo "new_version=${{ steps.tag_version.outputs.new_version }}" >> $GITHUB_OUTPUT
else
echo "new_version=pr-${{ github.event.number }}-${{ github.run_number }}" >> $GITHUB_OUTPUT
fi
build_slimfaas:
needs: tags
uses: ./.github/workflows/Docker.yml
with:
image_name: "axaguildev/slimfaas"
image_version: "${{ needs.tags.outputs.new_version }}"
image_build_args: ""
image_context: "."
image_file: "./Dockerfile"
platforms: "linux/amd64,linux/arm64"
secrets:
DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }}
DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }}
build_fibonacci:
needs: tags
uses: ./.github/workflows/Docker.yml
with:
image_name: "axaguildev/fibonacci"
image_version: "${{ needs.tags.outputs.new_version }}"
image_build_args: ""
image_context: "./src/Fibonacci"
image_file: "./src/Fibonacci/Dockerfile"
secrets:
DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }}
DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }}
build_fibonacci_webapp:
needs: tags
uses: ./.github/workflows/Docker.yml
with:
image_name: "axaguildev/fibonacci-webapp"
image_version: "${{ needs.tags.outputs.new_version }}"
image_build_args: ""
image_context: "./src/FibonacciReact"
image_file: "./src/FibonacciReact/Dockerfile"
secrets:
DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }}
DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }}