-
Notifications
You must be signed in to change notification settings - Fork 3
150 lines (147 loc) · 5.58 KB
/
test_and_build.yml
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
name: NetEvent_test_and_build
on:
push:
branches:
- main
- develop
- 'feature/Andy_Tickets'
tags: [ v**]
paths:
- '**'
- '!Docs/**'
- '!packaging/Docs**'
- '!docker-compose.yml'
- '!.env.example.yml'
- '!README.md'
- '!.github/workflows/website_build.yml'
- '!.github/workflows/update_dockerhub.yml'
- '!.github/workflows/update_docs_translation.yml'
- '!.github/dependabot.yml'
pull_request:
types: [opened, synchronize, reopened]
branches:
- main
- develop
- 'feature/**'
tags: [ v**]
paths:
- '**'
- '!Docs/**'
- '!packaging/Docs**'
- '!docker-compose.yml'
- '!.env.example.yml'
- '!README.md'
- '!.github/workflows/website_build.yml'
- '!.github/workflows/update_dockerhub.yml'
- '!.github/workflows/update_docs_translation.yml'
- '!.github/dependabot.yml'
jobs:
test_linux_x64:
runs-on: ubuntu-latest
if: ${{ !startsWith( github.event.pull_request.head.label, 'lan2play-weblate' ) }}
steps:
- name : machine echo github
env : { CONTENT : "${{ toJson(github) }}" }
run : "echo $CONTENT"
- name: Set up JDK 11
uses: actions/setup-java@v3
with:
distribution: 'temurin'
java-version: '17'
- name: Setup .NET
uses: actions/setup-dotnet@v3
with:
dotnet-version: 7.0
- uses: actions/checkout@v3
with:
fetch-depth: 0
- 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
- name: Install SonarCloud scanner
if: steps.cache-sonar-scanner.outputs.cache-hit != 'true'
shell: pwsh
run: |
New-Item -Path ./sonar/scanner -ItemType Directory
dotnet tool install dotnet-sonarscanner --tool-path ./sonar/scanner
- name: Update SonarCloud scanner
if: steps.cache-sonar-scanner.outputs.cache-hit != 'false'
shell: pwsh
run: |
dotnet tool update dotnet-sonarscanner --tool-path ./sonar/scanner
- name: Restore dependencies
run: dotnet restore
- name: start sonarscanner
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SONAR_TOKEN: ${{ secrets.NETEVENT_SONAR_TOKEN }}
run: ./sonar/scanner/dotnet-sonarscanner begin /k:"Lan2Play_NetEvent" /o:"lan2play" /d:sonar.token="${{ secrets.NETEVENT_SONAR_TOKEN }}" /d:sonar.host.url="https://sonarcloud.io" /d:sonar.cs.opencover.reportsPaths="./**/*.opencover.xml"
- name: dotnet build
run: dotnet build --no-restore
- name: dotnet test
run: dotnet test --no-build --no-restore --collect "XPlat Code Coverage" -- DataCollectionRunSettings.DataCollectors.DataCollector.Configuration.Format=opencover
- name: stop sonarscanner
if: always()
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SONAR_TOKEN: ${{ secrets.NETEVENT_SONAR_TOKEN }}
run: ./sonar/scanner/dotnet-sonarscanner end /d:sonar.token="${{ secrets.NETEVENT_SONAR_TOKEN }}"
build_docker_linux_x64:
runs-on: ubuntu-latest
if: ${{ !startsWith( github.event.pull_request.head.label, 'lan2play-weblate' ) }}
needs:
- test_linux_x64
steps:
- name: Checkout
uses: actions/checkout@v3
with:
submodules: recursive
- name: Set up QEMU
uses: docker/[email protected]
- name: Pull Latest Linux Base Image
run: docker pull lan2play/netevent
- name: set Version
if: ${{ (startsWith(github.ref, 'refs/tags/v')) }}
run: echo "NETEVENTNETVER=$(echo ${GITHUB_REF} | sed 's|refs/heads/||g' | sed 's|refs/tags/v||g' | sed 's|-beta||g' )" >> $GITHUB_ENV
- name: set Version
if: ${{ !(startsWith(github.ref, 'refs/tags/v')) }}
run: echo "NETEVENTNETVER=0.0.1" >> $GITHUB_ENV
- name: Build Linux Image
uses: docker/[email protected]
with:
context: .
file: ./Dockerfile
tags: |
lan2play/netevent:latest
lan2play/netevent:tickets
build-args: |
BUILDNODE=GitHub (Run Number: ${{ github.run_number }} Run ID: ${{ github.run_id }})
BUILDID=${{ github.run_id }}
BUILDNUMBER=${{ github.run_number }}
SOURCE_COMMIT=${{ github.sha }}
NETEVENTNETVER=${{ env.NETEVENTNETVER }}
no-cache: true
# - name: Test Linux Image
# run: docker run --rm lan2play/netevent:latest /docker/test.sh
- name: Login to DockerHub
if: ${{ (startsWith(github.ref, 'refs/tags/v')) || ( github.event_name == 'push' && (github.ref_name == 'feature/Andy_Tickets' || github.base_ref == 'feature/Andy_Tickets') ) }}
uses: docker/[email protected]
with:
username: ${{ secrets.NETEVENT_DOCKERHUB_USERNAME }}
password: ${{ secrets.NETEVENT_DOCKERHUB_TOKEN }}
- name: Push to Docker HUB Tickets
if: ${{ github.event_name == 'push' && (github.ref_name == 'feature/Andy_Tickets' || github.base_ref == 'feature/Andy_Tickets') }}
run: docker push lan2play/netevent:tickets
- name: Push to Docker HUB
if: ${{ (startsWith(github.ref, 'refs/tags/v')) }}
run: docker push lan2play/netevent:latest