|
| 1 | +# This workflow runs all checks when code is pushed. It does NOT run for pull requests. |
| 2 | + |
| 3 | +name: push |
| 4 | + |
| 5 | +on: |
| 6 | + # The workflow_dispatch event type is for manual workflow execution. |
| 7 | + workflow_dispatch: {} |
| 8 | + push: {} |
| 9 | + # In addition to pushes, run the workflow weekly to detect issues with the latest GitLab version. |
| 10 | + schedule: |
| 11 | + # ┌───────────── minute (0 - 59) |
| 12 | + # │ ┌───────────── hour (0 - 23) |
| 13 | + # │ │ ┌───────────── day of the month (1 - 31) |
| 14 | + # │ │ │ ┌───────────── month (1 - 12 or JAN-DEC) |
| 15 | + # │ │ │ │ ┌───────────── day of the week (0 - 6 or SUN-SAT) |
| 16 | + # * * * * * |
| 17 | + - cron: '0 0 * * 3' |
| 18 | + |
| 19 | +concurrency: |
| 20 | + group: ${{ github.workflow }}-${{ github.ref }} |
| 21 | + cancel-in-progress: true |
| 22 | + |
| 23 | +jobs: |
| 24 | + go-version: |
| 25 | + runs-on: ubuntu-latest |
| 26 | + outputs: |
| 27 | + go-version: ${{ steps.go-version.outputs.go-version }} |
| 28 | + steps: |
| 29 | + - uses: actions/checkout@v2 |
| 30 | + # Read the .go-version file and output it for other jobs to use. |
| 31 | + - id: go-version |
| 32 | + run: echo "::set-output name=go-version::$(cat .go-version)" |
| 33 | + |
| 34 | + lint: |
| 35 | + runs-on: ubuntu-latest |
| 36 | + needs: [go-version] |
| 37 | + strategy: |
| 38 | + fail-fast: false |
| 39 | + # Run all lint targets. |
| 40 | + matrix: |
| 41 | + target: |
| 42 | + - lint-golangci |
| 43 | + - lint-tfprovider |
| 44 | + - lint-examples-tf |
| 45 | + - lint-examples-sh |
| 46 | + - lint-generated |
| 47 | + steps: |
| 48 | + - uses: actions/setup-go@v2 |
| 49 | + with: |
| 50 | + go-version: ${{ needs.go-version.outputs.go-version }} |
| 51 | + - uses: actions/checkout@v2 |
| 52 | + # Cache the Go modules and compiled tools for the specific lint target. |
| 53 | + - uses: actions/cache@v2 |
| 54 | + with: |
| 55 | + path: | |
| 56 | + ~/go/pkg/mod |
| 57 | + bin |
| 58 | + key: ${{ github.job }}-${{ matrix.target }}-${{ runner.os }}-go${{ env.GO_VERSION }}-${{ hashFiles('**/go.sum', 'GNUMakefile') }} |
| 59 | + - run: make ${{ matrix.target }} |
| 60 | + |
| 61 | + unit-test: |
| 62 | + runs-on: ${{ matrix.os }} |
| 63 | + needs: [go-version] |
| 64 | + strategy: |
| 65 | + fail-fast: false |
| 66 | + matrix: |
| 67 | + os: [ubuntu-latest, macos-latest, windows-latest] |
| 68 | + steps: |
| 69 | + - uses: actions/setup-go@v2 |
| 70 | + with: |
| 71 | + go-version: ${{ needs.go-version.outputs.go-version }} |
| 72 | + - uses: actions/checkout@v2 |
| 73 | + # Cache the Go modules. |
| 74 | + - uses: actions/cache@v2 |
| 75 | + with: |
| 76 | + path: ~/go/pkg/mod |
| 77 | + key: ${{ github.job }}-${{ runner.os }}-go${{ env.GO_VERSION }}-${{ hashFiles('**/go.sum', 'GNUMakefile') }} |
| 78 | + - run: make test |
| 79 | + |
| 80 | + # Check whether the LICENSE_ENCRYPTION_PASSWORD secret exists. |
| 81 | + # Workaround for https://github.com/actions/runner/issues/520. |
| 82 | + license-encryption-password: |
| 83 | + runs-on: ubuntu-latest |
| 84 | + outputs: |
| 85 | + defined: ${{ steps.defined.outputs.defined }} |
| 86 | + steps: |
| 87 | + - id: defined |
| 88 | + env: |
| 89 | + LICENSE_ENCRYPTION_PASSWORD: ${{ secrets.LICENSE_ENCRYPTION_PASSWORD }} |
| 90 | + if: ${{ env.LICENSE_ENCRYPTION_PASSWORD != '' }} |
| 91 | + run: echo "::set-output name=defined::true" |
| 92 | + |
| 93 | + acceptance-ce: |
| 94 | + timeout-minutes: 60 |
| 95 | + runs-on: ubuntu-latest |
| 96 | + needs: [go-version] |
| 97 | + steps: |
| 98 | + - uses: actions/setup-go@v2 |
| 99 | + with: |
| 100 | + go-version: ${{ needs.go-version.outputs.go-version }} |
| 101 | + - uses: actions/checkout@v2 |
| 102 | + # Cache the Go modules. |
| 103 | + - uses: actions/cache@v2 |
| 104 | + with: |
| 105 | + path: ~/go/pkg/mod |
| 106 | + key: ${{ github.job }}-${{ runner.os }}-go${{ env.GO_VERSION }}-${{ hashFiles('**/go.sum', 'GNUMakefile') }} |
| 107 | + - run: make testacc-up |
| 108 | + - run: make testacc |
| 109 | + |
| 110 | + acceptance-ee: |
| 111 | + # Only run EE tests if the LICENSE_ENCRYPTION_PASSWORD secret exists, so that the workflow |
| 112 | + # doesn't fail when code is pushed to a fork. |
| 113 | + if: ${{ needs.license-encryption-password.outputs.defined }} |
| 114 | + timeout-minutes: 60 |
| 115 | + runs-on: ubuntu-latest |
| 116 | + needs: [go-version, license-encryption-password] |
| 117 | + steps: |
| 118 | + - uses: actions/setup-go@v2 |
| 119 | + with: |
| 120 | + go-version: ${{ needs.go-version.outputs.go-version }} |
| 121 | + - uses: actions/checkout@v2 |
| 122 | + # Cache the Go modules. |
| 123 | + - uses: actions/cache@v2 |
| 124 | + with: |
| 125 | + path: ~/go/pkg/mod |
| 126 | + key: ${{ github.job }}-${{ runner.os }}-go${{ env.GO_VERSION }}-${{ hashFiles('**/go.sum', 'GNUMakefile') }} |
| 127 | + - name: Decrypt license |
| 128 | + run: | |
| 129 | + openssl version |
| 130 | + openssl enc -d -aes-256-cbc -pbkdf2 -iter 20000 -in Gitlab-license.encrypted -out Gitlab-license.txt -pass "pass:${{ secrets.LICENSE_ENCRYPTION_PASSWORD }}" |
| 131 | + # Note we specifically launch the gitlab-ee service. |
| 132 | + - run: make testacc-up SERVICE=gitlab-ee |
| 133 | + - run: make testacc |
0 commit comments