Use same context in direct dispatch as in background acquire #854
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: Maven CI | |
on: | |
schedule: | |
- cron: '42 0 * * 1' | |
push: | |
branches: | |
- master | |
pull_request: | |
branches: | |
- master | |
pull_request_target: | |
types: | |
- labeled | |
branches: | |
- master | |
release: | |
types: | |
- published | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
permissions: | |
checks: write | |
security-events: write | |
contents: write | |
strategy: | |
matrix: | |
java: | |
- 17 | |
- 21 | |
event: | |
- ${{ github.event_name }} | |
exclude: | |
- event: pull_request_target | |
java: 17 | |
steps: | |
- uses: actions/checkout@v4 | |
if: ${{ github.event_name != 'pull_request_target' }} | |
with: | |
fetch-depth: 0 | |
persist-credentials: ${{ !startsWith(github.event_name, 'pull_request') }} | |
- uses: actions/checkout@v4 | |
if: ${{ github.event_name == 'pull_request_target' }} | |
with: | |
fetch-depth: 0 | |
ref: ${{ github.event.pull_request.head.ref }} | |
repository: ${{ github.event.pull_request.head.repo.full_name }} | |
persist-credentials: false | |
# Initializes the CodeQL tools for scanning. | |
- name: Initialize CodeQL | |
if: ${{ matrix.java == '17' && github.event_name != 'release' && github.event_name != 'pull_request_target' }} | |
uses: github/codeql-action/init@v3 | |
with: | |
languages: java | |
- name: Set up JDK ${{ matrix.java }} | |
uses: actions/setup-java@v4 | |
with: | |
distribution: 'zulu' | |
java-version: ${{ matrix.java }} | |
cache: 'maven' | |
- name: Setup Git | |
run: > | |
git config --global user.email "[email protected]" && | |
git config --global user.name "GitHub Actions" | |
if: ${{ !startsWith(github.event_name, 'pull_request') }} | |
- name: Build with Maven | |
run: mvn -B -V -e -Dstyle.color=always clean verify | |
- name: Upload Openliberty logfiles | |
if: ${{ failure() }} | |
uses: actions/upload-artifact@v3 | |
with: | |
name: openliberty-logs | |
path: '**/target/liberty/wlp/usr/servers/*/logs/**/*.log' | |
retention-days: 5 | |
- name: Publish Test Report | |
if: ${{ (success() || failure()) && matrix.java == '21' && github.event_name == 'pull_request' }} | |
uses: scacap/action-surefire-report@v1 | |
with: | |
report_paths: "**/target/*-reports/TEST-*.xml" | |
- name: Unittest Coverage | |
if: ${{ matrix.java == '21' && github.event_name != 'release' && github.event_name != 'pull_request_target' }} | |
run: > | |
mvn -B -Dstyle.color=always jacoco:report | |
- name: Unittest Codecov | |
if: ${{ matrix.java == '21' && github.event_name != 'release' && github.event_name != 'pull_request_target' }} | |
uses: codecov/codecov-action@v4 | |
with: | |
flags: unittests | |
token: ${{ secrets.CODECOV_TOKEN }} | |
- name: Integrationstest Coverage | |
if: ${{ matrix.java == '21' && github.event_name != 'release' && github.event_name != 'pull_request_target' }} | |
run: > | |
mvn -B -Dstyle.color=always jacoco:report-integration@report-integration | |
- name: Integrationstest Codecov | |
if: ${{ matrix.java == '21' && github.event_name != 'release' && github.event_name != 'pull_request_target' }} | |
uses: codecov/codecov-action@v4 | |
with: | |
flags: integration | |
token: ${{ secrets.CODECOV_TOKEN }} | |
- name: Perform CodeQL Analysis | |
if: ${{ matrix.java == '17' && github.event_name != 'release' && github.event_name != 'pull_request_target' }} | |
uses: github/codeql-action/analyze@v3 | |
- name: Sonar Report | |
if: ${{ matrix.java == '21' && (!startsWith(github.event_name, 'pull_request') || !github.event.pull_request.head.repo.fork || contains(github.event.pull_request.labels.*.name, 'sonar')) }} | |
run: > | |
if [ "$GITHUB_EVENT_NAME" == "pull_request_target" ]; | |
then | |
export GITHUB_EVENT_NAME=pull_request; | |
export GITHUB_REF=refs/pull/$GITHUB_PULL_REQUEST/merge; | |
fi && | |
mvn -B -e -Dstyle.color=always jacoco:report jacoco:report-integration@report-integration sonar:sonar -Dsonar.organization=jonasrutishauser-github | |
env: | |
GITHUB_PULL_REQUEST: ${{ github.event.number }} | |
GITHUB_TOKEN: ${{ github.token }} | |
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} | |
SONAR_HOST_URL: https://sonarcloud.io | |
- name: Upload test results to Codecov | |
if: ${{ matrix.java == '21' && github.event_name != 'release' && github.event_name != 'pull_request_target' }} | |
uses: codecov/test-results-action@v1 | |
with: | |
token: ${{ secrets.CODECOV_TOKEN }} | |
- name: Deploy Site | |
if: ${{ matrix.java == '17' && github.event_name != 'release' && !startsWith(github.event_name, 'pull_request') }} | |
run: mvn -B -e -Dstyle.color=always site-deploy | |
env: | |
GITHUB_TOKEN: ${{ github.token }} | |
update-pr: | |
runs-on: ubuntu-latest | |
if: ${{ github.event_name == 'pull_request_target' && contains(github.event.pull_request.labels.*.name, 'sonar') }} | |
steps: | |
- name: Remove Sonar Label | |
uses: peter-murray/remove-labels-action@v1 | |
with: | |
labels: sonar |