|
| 1 | +name: Continuous Integration |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: [main, dev] |
| 6 | + pull_request: |
| 7 | + branches: [main, dev] |
| 8 | + schedule: |
| 9 | + - cron: '0 0 * * 0' |
| 10 | + workflow_dispatch: |
| 11 | + |
| 12 | +permissions: |
| 13 | + contents: read |
| 14 | + security-events: write |
| 15 | + |
| 16 | +jobs: |
| 17 | + build: |
| 18 | + name: Go Build |
| 19 | + runs-on: ubuntu-latest |
| 20 | + steps: |
| 21 | + - name: Git Checkout |
| 22 | + uses: actions/checkout@v4 |
| 23 | + - name: Setup Go |
| 24 | + uses: ./.github/actions/setup-go |
| 25 | + - name: Go Build |
| 26 | + run: go build -v ./... |
| 27 | + |
| 28 | + lint: |
| 29 | + name: Linters |
| 30 | + runs-on: ubuntu-latest |
| 31 | + needs: build |
| 32 | + permissions: |
| 33 | + issues: write |
| 34 | + pull-requests: write |
| 35 | + steps: |
| 36 | + - name: Git Checkout |
| 37 | + uses: actions/checkout@v4 |
| 38 | + - name: Setup Go |
| 39 | + uses: ./.github/actions/setup-go |
| 40 | + - name: GolangCI Lint |
| 41 | + uses: golangci/golangci-lint-action@v8 |
| 42 | + with: |
| 43 | + version: v2.1 |
| 44 | + args: --config=.linters/.golangci.yml |
| 45 | + - name: MegaLinter |
| 46 | + uses: oxsecurity/megalinter/flavors/go@v8 |
| 47 | + id: ml |
| 48 | + env: |
| 49 | + VALIDATE_ALL_CODEBASE: true |
| 50 | + DEFAULT_WORKSPACE: ${{ github.workspace }} |
| 51 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 52 | + - name: Archive reports |
| 53 | + uses: actions/upload-artifact@v4 |
| 54 | + if: ${{ success() || failure() }} |
| 55 | + with: |
| 56 | + name: MegaLinter reports |
| 57 | + path: | |
| 58 | + .ml-reports/ |
| 59 | + mega-linter.log |
| 60 | +
|
| 61 | + tests: |
| 62 | + name: Go All Tests |
| 63 | + runs-on: ubuntu-latest |
| 64 | + needs: build |
| 65 | + strategy: |
| 66 | + matrix: |
| 67 | + tf-version: ['1.11.*', '1.12.*'] |
| 68 | + steps: |
| 69 | + - name: Git Checkout |
| 70 | + uses: actions/checkout@v4 |
| 71 | + - name: Setup Go |
| 72 | + uses: ./.github/actions/setup-go |
| 73 | + - name: Setup Terraform |
| 74 | + uses: hashicorp/setup-terraform@v3 |
| 75 | + with: |
| 76 | + terraform_version: ${{ matrix.tf-version }} |
| 77 | + terraform_wrapper: false |
| 78 | + - name: Run Tests |
| 79 | + run: go test ./internal/provider -v -coverprofile=tests-report.lcov -json > tests-report.log |
| 80 | + env: |
| 81 | + TF_ACC: '1' |
| 82 | + - name: Codecov Upload Coverage |
| 83 | + uses: codecov/codecov-action@v4 |
| 84 | + with: |
| 85 | + token: ${{ secrets.CODECOV_TOKEN }} |
| 86 | + verbose: true |
| 87 | + files: tests-report.lcov |
| 88 | + - name: Codecov Upload Test Results |
| 89 | + if: ${{ !cancelled() }} |
| 90 | + uses: codecov/test-results-action@v1 |
| 91 | + with: |
| 92 | + token: ${{ secrets.CODECOV_TOKEN }} |
| 93 | + - name: Upload Test Artifacts |
| 94 | + uses: actions/upload-artifact@v4 |
| 95 | + with: |
| 96 | + name: tests-report-${{ github.sha }} |
| 97 | + path: | |
| 98 | + tests-report.lcov |
| 99 | + tests-report.log |
| 100 | + retention-days: 7 |
| 101 | + overwrite: true |
| 102 | + |
| 103 | + sonar: |
| 104 | + name: SonarCloud Scan |
| 105 | + if: github.event_name == 'push' |
| 106 | + runs-on: ubuntu-latest |
| 107 | + needs: [tests] |
| 108 | + steps: |
| 109 | + - name: Git Checkout |
| 110 | + uses: actions/checkout@v4 |
| 111 | + with: |
| 112 | + fetch-depth: 0 |
| 113 | + - name: Download Artifacts |
| 114 | + uses: actions/download-artifact@v4 |
| 115 | + with: |
| 116 | + name: tests-report-${{ github.sha }} |
| 117 | + - name: Sonarqube Scan |
| 118 | + uses: SonarSource/sonarqube-scan-action@v5 |
| 119 | + env: |
| 120 | + SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} |
| 121 | + |
| 122 | + codeql: |
| 123 | + name: CodeQL Scan |
| 124 | + runs-on: ubuntu-latest |
| 125 | + if: github.event_name != 'pull_request' |
| 126 | + needs: build |
| 127 | + steps: |
| 128 | + - name: Git Checkout |
| 129 | + uses: actions/checkout@v4 |
| 130 | + - name: CodeQL Analysis |
| 131 | + uses: github/codeql-action/init@v3 |
| 132 | + with: |
| 133 | + languages: go |
| 134 | + - name: CodeQL Analysis |
| 135 | + uses: github/codeql-action/analyze@v3 |
| 136 | + with: |
| 137 | + category: '/language:go' |
0 commit comments