|
| 1 | +name: CI |
| 2 | + |
| 3 | +# Trigger the CI on pull requests and direct pushes to any branch |
| 4 | +on: |
| 5 | + push: |
| 6 | + pull_request: |
| 7 | + |
| 8 | + |
| 9 | +jobs: |
| 10 | + |
| 11 | + lint: |
| 12 | + name: Lint |
| 13 | + runs-on: ubuntu-latest |
| 14 | + # Pull requests from the same repository won't trigger this checks as they were already triggered by the push |
| 15 | + if: github.event_name == 'push' || github.event.pull_request.head.repo.full_name != github.repository |
| 16 | + steps: |
| 17 | + - name: Clone the code |
| 18 | + uses: actions/checkout@v2 |
| 19 | + - name: Execute golangci-lint |
| 20 | + uses: golangci/golangci-lint-action@v2 |
| 21 | + with: |
| 22 | + version: v1.29 # Always uses the latest patch version. |
| 23 | + only-new-issues: true # Show only new issues if it's a pull request |
| 24 | + |
| 25 | + testdata: |
| 26 | + name: Verify testdata directory |
| 27 | + needs: lint |
| 28 | + runs-on: ubuntu-latest |
| 29 | + # Pull requests from the same repository won't trigger this checks as they were already triggered by the push |
| 30 | + if: github.event_name == 'push' || github.event.pull_request.head.repo.full_name != github.repository |
| 31 | + steps: |
| 32 | + - name: Clone the code |
| 33 | + uses: actions/checkout@v2 |
| 34 | + - name: Setup Go |
| 35 | + uses: actions/setup-go@v2 |
| 36 | + with: |
| 37 | + go-version: '^1.15' |
| 38 | + # This step is needed as the following one tries to remove |
| 39 | + # kustomize for each test but has no permission to do so |
| 40 | + - name: Remove pre-installed kustomize |
| 41 | + run: sudo rm -f /usr/local/bin/kustomize |
| 42 | + - name: Verify testdata directory |
| 43 | + run: make check-testdata |
| 44 | + |
| 45 | + test: |
| 46 | + name: Test for ${{ matrix.os }} |
| 47 | + needs: lint |
| 48 | + runs-on: ${{ matrix.os }} |
| 49 | + strategy: |
| 50 | + matrix: |
| 51 | + os: [ubuntu-latest, macos-latest] |
| 52 | + # Pull requests from the same repository won't trigger this checks as they were already triggered by the push |
| 53 | + if: github.event_name == 'push' || github.event.pull_request.head.repo.full_name != github.repository |
| 54 | + steps: |
| 55 | + - name: Clone the code |
| 56 | + uses: actions/checkout@v2 |
| 57 | + - name: Setup Go |
| 58 | + uses: actions/setup-go@v2 |
| 59 | + with: |
| 60 | + go-version: '^1.15' |
| 61 | + # This step is needed as the following one tries to remove |
| 62 | + # kustomize for each test but has no permission to do so |
| 63 | + - name: Remove pre-installed kustomize |
| 64 | + run: sudo rm -f /usr/local/bin/kustomize |
| 65 | + - name: Perform the test |
| 66 | + run: make test |
| 67 | + |
| 68 | + coverage: |
| 69 | + name: Code coverage |
| 70 | + needs: |
| 71 | + - lint |
| 72 | + - testdata |
| 73 | + - test |
| 74 | + runs-on: ubuntu-latest |
| 75 | + # Pull requests from the same repository won't trigger this checks as they were already triggered by the push |
| 76 | + if: github.event_name == 'push' || github.event.pull_request.head.repo.full_name != github.repository |
| 77 | + steps: |
| 78 | + - name: Clone the code |
| 79 | + uses: actions/checkout@v2 |
| 80 | + - name: Setup Go |
| 81 | + uses: actions/setup-go@v2 |
| 82 | + with: |
| 83 | + go-version: '^1.15' |
| 84 | + - name: Generate the coverage output |
| 85 | + run: make test-coverage |
| 86 | + - name: Send the coverage output |
| 87 | + uses: shogo82148/actions-goveralls@v1 |
| 88 | + with: |
| 89 | + path-to-profile: coverage-all.out |
0 commit comments