Skip to content

Merge Main

Merge Main #821

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/setup-qemu-action@v2.1.0
- 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/build-push-action@v4.0.0
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/login-action@v2.1.0
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