|
| 1 | +name: Unit tests |
| 2 | + |
| 3 | +# Trigger the workflow on pull requests and direct pushes to any branch |
| 4 | +on: |
| 5 | + push: |
| 6 | + pull_request: |
| 7 | + |
| 8 | + |
| 9 | +jobs: |
| 10 | + |
| 11 | + test: |
| 12 | + name: ${{ matrix.os }} |
| 13 | + runs-on: ${{ matrix.os }} |
| 14 | + strategy: |
| 15 | + matrix: |
| 16 | + os: |
| 17 | + - ubuntu-latest |
| 18 | + - macos-latest |
| 19 | + # Pull requests from the same repository won't trigger this checks as they were already triggered by the push |
| 20 | + if: github.event_name == 'push' || github.event.pull_request.head.repo.full_name != github.repository |
| 21 | + steps: |
| 22 | + - name: Clone the code |
| 23 | + uses: actions/checkout@v2 |
| 24 | + - name: Setup Go |
| 25 | + uses: actions/setup-go@v2 |
| 26 | + with: |
| 27 | + go-version: '1.15' |
| 28 | + # This step is needed as the following one tries to remove |
| 29 | + # kustomize for each test but has no permission to do so |
| 30 | + - name: Remove pre-installed kustomize |
| 31 | + run: sudo rm -f /usr/local/bin/kustomize |
| 32 | + - name: Perform the test |
| 33 | + run: make test |
| 34 | + - name: Report failure |
| 35 | + uses: nashmaniac/[email protected] |
| 36 | + # Only report failures of pushes (PRs have are visible through the Checks section) to the default branch |
| 37 | + if: failure() && github.event_name == 'push' && github.ref == 'refs/heads/master' |
| 38 | + with: |
| 39 | + title: 🐛 Unit tests failed on ${{ matrix.os }} for ${{ github.sha }} |
| 40 | + token: ${{ secrets.GITHUB_TOKEN }} |
| 41 | + labels: kind/bug |
| 42 | + body: https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }} |
| 43 | + |
| 44 | + coverage: |
| 45 | + name: Code coverage |
| 46 | + needs: |
| 47 | + - test |
| 48 | + runs-on: ubuntu-latest |
| 49 | + # Pull requests from the same repository won't trigger this checks as they were already triggered by the push |
| 50 | + if: github.event_name == 'push' || github.event.pull_request.head.repo.full_name != github.repository |
| 51 | + steps: |
| 52 | + - name: Clone the code |
| 53 | + uses: actions/checkout@v2 |
| 54 | + - name: Setup Go |
| 55 | + uses: actions/setup-go@v2 |
| 56 | + with: |
| 57 | + go-version: '1.15' |
| 58 | + - name: Generate the coverage output |
| 59 | + run: make test-coverage |
| 60 | + - name: Send the coverage output |
| 61 | + uses: shogo82148/actions-goveralls@v1 |
| 62 | + with: |
| 63 | + path-to-profile: coverage-all.out |
| 64 | + - name: Report failure |
| 65 | + uses: nashmaniac/[email protected] |
| 66 | + # Only report failures of pushes (PRs have are visible through the Checks section) to the default branch |
| 67 | + if: failure() && github.event_name == 'push' && github.ref == 'refs/heads/master' |
| 68 | + with: |
| 69 | + title: 🐛 Coverage report failed for ${{ github.sha }} |
| 70 | + token: ${{ secrets.GITHUB_TOKEN }} |
| 71 | + labels: kind/bug |
| 72 | + body: https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }} |
0 commit comments