[MERGE] - GitHub pipeline #2
This file contains hidden or 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: CI/CD Pipeline | |
| on: | |
| push: | |
| branches: | |
| - dev | |
| - main | |
| tags: | |
| - '*' | |
| pull_request: | |
| branches: | |
| - dev | |
| - main | |
| workflow_dispatch: | |
| env: | |
| MAVEN_OPTS: -Dmaven.repo.local=.m2/repository | |
| jobs: | |
| build: | |
| runs-on: ubuntu-latest | |
| container: | |
| image: maven:3.9.9-eclipse-temurin-22 | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Cache Maven dependencies | |
| uses: actions/cache@v4 | |
| with: | |
| path: .m2/repository | |
| key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }} | |
| restore-keys: | | |
| ${{ runner.os }}-maven- | |
| - name: Build with Maven | |
| run: mvn -B clean compile | |
| test: | |
| runs-on: ubuntu-latest | |
| container: | |
| image: maven:3.9.9-eclipse-temurin-22 | |
| env: | |
| DISPLAY: ":99" | |
| MAVEN_OPTS: -Djava.awt.headless=false | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Cache Maven dependencies | |
| uses: actions/cache@v4 | |
| with: | |
| path: .m2/repository | |
| key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }} | |
| restore-keys: | | |
| ${{ runner.os }}-maven- | |
| - name: Install dependencies for JavaFX and Xvfb | |
| run: | | |
| apt-get update -qq | |
| apt-get install -y -qq xvfb libgtk-3-0 libxtst6 libxrender1 libxi6 libx11-6 libxext6 libgl1 | |
| - name: Start Xvfb | |
| run: | | |
| Xvfb :99 -screen 0 1920x1080x24 > /dev/null 2>&1 & | |
| sleep 3 | |
| - name: Run tests | |
| run: mvn -B test | |
| - name: Upload test results | |
| uses: actions/upload-artifact@v4 | |
| if: always() | |
| with: | |
| name: test-results | |
| path: | | |
| **/target/surefire-reports/ | |
| **/target/site/jacoco/ | |
| **/target/jacoco.exec | |
| - name: Publish test report | |
| uses: dorny/test-reporter@v1 | |
| if: always() | |
| with: | |
| name: Maven Tests | |
| path: '**/target/surefire-reports/TEST-*.xml' | |
| reporter: java-junit | |
| # TEMPORARILY DISABLED - Sonar login issues | |
| # sonarqube: | |
| # runs-on: ubuntu-latest | |
| # container: | |
| # image: maven:3.9.9-eclipse-temurin-22 | |
| # needs: test | |
| # if: github.ref == 'refs/heads/dev' || github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/') | |
| # continue-on-error: true | |
| # steps: | |
| # - name: Checkout code | |
| # uses: actions/checkout@v4 | |
| # with: | |
| # fetch-depth: 0 | |
| # - name: Cache Maven dependencies | |
| # uses: actions/cache@v4 | |
| # with: | |
| # path: .m2/repository | |
| # key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }} | |
| # restore-keys: | | |
| # ${{ runner.os }}-maven- | |
| # - name: Download test artifacts | |
| # uses: actions/download-artifact@v4 | |
| # with: | |
| # name: test-results | |
| # - name: Setup settings | |
| # run: | | |
| # chmod +x ./settings.sh | |
| # ./settings.sh | |
| # - name: Compile and run SonarQube analysis | |
| # env: | |
| # PROJECT_KEY_AND_NAME: ${{ secrets.PROJECT_KEY_AND_NAME }} | |
| # SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} | |
| # run: | | |
| # mvn compile -DskipTests | |
| # mvn sonar:sonar deploy -DskipTests \ | |
| # -Dsonar.projectKey=$PROJECT_KEY_AND_NAME \ | |
| # -Dsonar.projectName=$PROJECT_KEY_AND_NAME \ | |
| # -Dsonar.host.url=https://disc.univ-fcomte.fr/cr700-sonarqube \ | |
| # -Dsonar.token=$SONAR_TOKEN \ | |
| # -Dsonar.coverage.jacoco.xmlReportPaths=**/target/site/jacoco/jacoco.xml | |
| deploy: | |
| runs-on: ubuntu-latest | |
| needs: test # Changed from sonarqube since it's temporarily disabled | |
| if: github.ref == 'refs/heads/main' | |
| environment: | |
| name: production | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Cache Maven dependencies | |
| uses: actions/cache@v4 | |
| with: | |
| path: .m2/repository | |
| key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }} | |
| restore-keys: | | |
| ${{ runner.os }}-maven- | |
| - name: Setup settings | |
| run: | | |
| chmod +x ./settings.sh | |
| ./settings.sh | |
| # TEMPORARILY DISABLED - Nexus login issues | |
| # - name: Deploy with Maven | |
| # run: | | |
| # echo "Starting manual Maven deploy..." | |
| # mvn deploy -s ~/.m2/settings.xml |