Test pipeline #14
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: Continuous Integration Build Pipeline | |
| on: | |
| push: | |
| branches: [ master ] | |
| pull_request: | |
| branches: [ master ] | |
| defaults: | |
| run: | |
| shell: bash | |
| env: | |
| JAVA_VERSION: '17' | |
| jobs: | |
| build: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v3 | |
| - name: Set up JDK | |
| uses: actions/setup-java@v3 | |
| with: | |
| java-version: ${{ env.JAVA_VERSION }} | |
| distribution: 'adopt' | |
| cache: maven | |
| - name: Build with Maven | |
| run: mvn clean install | |
| - name: Upload build artifacts | |
| if: always() | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: build-artifacts | |
| path: target/*.jar | |
| test: | |
| needs: build | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v3 | |
| - name: Set up JDK | |
| uses: actions/setup-java@v3 | |
| with: | |
| java-version: ${{ env.JAVA_VERSION }} | |
| distribution: 'adopt' | |
| cache: maven | |
| - name: Run Tests | |
| run: mvn test | |
| - name: Upload Surefire test results | |
| if: always() | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: surefire-reports | |
| path: target/surefire-reports/ | |
| - name: Upload JaCoCo reports | |
| if: always() | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: jacoco-reports | |
| path: target/site/jacoco/ | |
| code-scan: | |
| needs: test | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v3 | |
| with: | |
| fetch-depth: 0 | |
| - name: Download JaCoCo reports | |
| uses: actions/download-artifact@v4 | |
| with: | |
| name: jacoco-reports | |
| path: target/site/jacoco/ | |
| - name: Setup Code Climate | |
| run: | | |
| curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./cc-test-reporter | |
| chmod +x ./cc-test-reporter | |
| ./cc-test-reporter before-build | |
| - name: Run Code Climate Analysis | |
| env: | |
| CC_TEST_REPORTER_ID: ${{ secrets.CC_TEST_REPORTER_ID }} | |
| run: | | |
| JACOCO_SOURCE_PATH=src/main/java ./cc-test-reporter format-coverage target/site/jacoco/jacoco.xml --input-type jacoco | |
| ./cc-test-reporter upload-coverage | |
| security-scan: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v3 | |
| - name: Install Snyk CLI | |
| run: npm install -g snyk | |
| - name: Run Snyk to check for vulnerabilities | |
| id: snyk | |
| continue-on-error: true | |
| env: | |
| SNYK_TOKEN: ${{ secrets.SNYK_TOKEN }} | |
| run: snyk test --all-projects --severity-threshold=high --sarif-file-output=snyk.sarif | |
| - name: Upload result to GitHub Code Scanning | |
| uses: github/codeql-action/upload-sarif@v3 | |
| with: | |
| sarif_file: snyk.sarif | |
| - name: Check Snyk scan status | |
| if: steps.snyk.outcome == 'failure' | |
| run: | | |
| echo "Security vulnerabilities found" | |
| exit 1 |