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: Turquoise Space - JBehave Junit Runner - CI / CD | |
on: | |
push: | |
branches: | |
- master | |
- TurquoiseSpace | |
- 3.0.0 | |
pull_request: | |
branches: | |
- master | |
- TurquoiseSpace | |
- 3.0.0 | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
java: [ 11, 17, 21 ] | |
name: Java ${{ matrix.java }} | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- name: Extract branch name | |
shell: bash | |
run: echo "branch=${GITHUB_HEAD_REF:-${GITHUB_REF#refs/heads/}}" >> $GITHUB_OUTPUT | |
id: extract_branch | |
- name: Get Current Date | |
id: date | |
run: echo "::set-output name=date::$(date +'%Y-%m-%d_%H-%M-%S_%Z')" | |
- name: Setup JDK | |
uses: actions/setup-java@v3 | |
with: | |
distribution: 'temurin' | |
java-version: ${{ matrix.java }} | |
cache: 'maven' | |
- name: Build with Maven | |
run: mvn clean install -Dgpg.skip=true | |
- name: Publish test coverage data to Coveralls | |
if: matrix.java == '17' | |
env: | |
COVERALLS_REPO_TOKEN: ${{ secrets.COVERALLS_REPO_TOKEN }} | |
BRANCH_NAME_OR_REF: ${{ github.head_ref || github.ref }} | |
run: | | |
if [[ -n $COVERALLS_REPO_TOKEN ]]; then | |
mvn coveralls:report -DrepoToken=${COVERALLS_REPO_TOKEN} -D branch=${BRANCH_NAME_OR_REF} -DpullRequest=${{github.event.pull_request.number}}; | |
else | |
echo No COVERALLS_REPO_TOKEN, the test coverage publishing to Coveralls is skipped; | |
fi; | |
- name: Analyze with Codacy | |
if: matrix.java == '11' | |
env: | |
CODACY_PROJECT_TOKEN: ${{ secrets.CODACY_PROJECT_TOKEN }} | |
CODACY_API_TOKEN: ${{ secrets.CODACY_API_TOKEN }} | |
run: | | |
if [[ -n $CODACY_PROJECT_TOKEN && -n $CODACY_API_TOKEN ]]; then | |
mvn com.gavinmogan:codacy-maven-plugin:coverage -DcoverageReportFile=target/site/jacoco/jacoco.xml -DprojectToken=${CODACY_PROJECT_TOKEN} -DapiToken=${CODACY_API_TOKEN} -Dcommit=${GITHUB_SHA}; | |
else | |
echo No CODACY_PROJECT_TOKEN and/or CODACY_API_TOKEN, the publishing to Codacy is skipped; | |
fi; | |
- name: Anazlyze with SonarCloud | |
if: matrix.java == '17' | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} | |
GITHUB_BRANCH: ${{ steps.extract_branch.outputs.branch }} | |
JOB_DATETIME: ${{ steps.date.outputs.date }} | |
run: | | |
if [[ -n $GITHUB_TOKEN && -n $SONAR_TOKEN ]]; then | |
mvn verify sonar:sonar -Dsonar.token=${SONAR_TOKEN} -Dsonar.branch.name=${GITHUB_BRANCH} -Dsonar.analysis.buildNumber=${GITHUB_BRANCH}_${JOB_DATETIME} -Dgpg.skip=true -Pcoverage | |
else | |
echo No GITHUB_TOKEN and/or SONAR_TOKEN, the publishing to SonarCloud is skipped; | |
fi; |