|
| 1 | +name: Build and Test |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: [ main ] |
| 6 | + paths-ignore: [ '*.md' ] |
| 7 | + pull_request: |
| 8 | + branches: [ '**' ] |
| 9 | + |
| 10 | +jobs: |
| 11 | + build: |
| 12 | + runs-on: ubuntu-latest |
| 13 | + |
| 14 | + steps: |
| 15 | + - uses: actions/checkout@v3 |
| 16 | + - name: Set up JDK |
| 17 | + uses: actions/setup-java@v3 |
| 18 | + with: |
| 19 | + java-version: '17' |
| 20 | + distribution: 'temurin' |
| 21 | + cache: 'gradle' |
| 22 | + |
| 23 | + - name: Build all projects without running tests |
| 24 | + run: ./gradlew --build-cache build -x test |
| 25 | + |
| 26 | + source-clear: |
| 27 | + needs: [ build ] |
| 28 | + runs-on: ubuntu-latest |
| 29 | + |
| 30 | + steps: |
| 31 | + - uses: actions/checkout@v3 |
| 32 | + - name: Set up JDK |
| 33 | + uses: actions/setup-java@v3 |
| 34 | + with: |
| 35 | + java-version: '17' |
| 36 | + distribution: 'temurin' |
| 37 | + cache: 'gradle' |
| 38 | + |
| 39 | + - name: SourceClear scan |
| 40 | + env: |
| 41 | + SRCCLR_API_TOKEN: ${{ secrets.SRCCLR_API_TOKEN }} |
| 42 | + run: ./gradlew --build-cache srcclr |
| 43 | + |
| 44 | + unit-tests-and-sonarqube: |
| 45 | + needs: [ build ] |
| 46 | + runs-on: ubuntu-latest |
| 47 | + steps: |
| 48 | + - uses: actions/checkout@v3 |
| 49 | + # Needed by sonar to get the git history for the branch the PR will be merged into. |
| 50 | + with: |
| 51 | + fetch-depth: 0 |
| 52 | + - name: Set up JDK |
| 53 | + uses: actions/setup-java@v3 |
| 54 | + with: |
| 55 | + java-version: '17' |
| 56 | + distribution: 'temurin' |
| 57 | + cache: 'gradle' |
| 58 | + - name: Test with coverage |
| 59 | + run: ./gradlew --build-cache test jacocoTestReport |
| 60 | + - name: SonarQube scan for library |
| 61 | + run: ./gradlew --build-cache :library:sonar --info |
| 62 | + env: |
| 63 | + SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} |
| 64 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 65 | + - name: SonarQube scan for cli |
| 66 | + run: ./gradlew --build-cache :cli:sonar --info |
| 67 | + env: |
| 68 | + SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} |
| 69 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 70 | + |
| 71 | + notify-slack: |
| 72 | + needs: [ build, unit-tests-and-sonarqube, source-clear ] |
| 73 | + runs-on: ubuntu-latest |
| 74 | + |
| 75 | + if: failure() && github.ref == 'refs/heads/main' |
| 76 | + |
| 77 | + steps: |
| 78 | + - name: Notify slack on failure |
| 79 | + uses: broadinstitute/[email protected] |
| 80 | + env: |
| 81 | + SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }} |
| 82 | + with: |
| 83 | + channel: '#dsp-analysis-journeys-alerts' |
| 84 | + status: failure |
| 85 | + author_name: Build on dev |
| 86 | + fields: job,message |
| 87 | + text: 'Build failed :sadpanda:' |
| 88 | + username: 'Java-PFB GitHub Action' |
| 89 | + |
| 90 | + dispatch-tag: |
| 91 | + needs: [ build, unit-tests-and-sonarqube, source-clear ] |
| 92 | + runs-on: ubuntu-latest |
| 93 | + |
| 94 | + if: success() && github.ref == 'refs/heads/main' |
| 95 | + |
| 96 | + steps: |
| 97 | + - name: Fire off tag action |
| 98 | + uses: broadinstitute/workflow-dispatch@v1 |
| 99 | + with: |
| 100 | + workflow: Tag |
| 101 | + token: ${{ secrets.BROADBOT_TOKEN }} |
0 commit comments