|
| 1 | +name: CI |
| 2 | +on: [push, pull_request] |
| 3 | +jobs: |
| 4 | + check: |
| 5 | + if: ${{ github.event_name == 'pull_request' }} |
| 6 | + name: HAProxy check commit message |
| 7 | + runs-on: ubuntu-latest |
| 8 | + steps: |
| 9 | + - name: commit-check |
| 10 | + uses: docker://ghcr.io/haproxytech/commit-check:3.0.0 |
| 11 | + env: |
| 12 | + API_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 13 | + generate: |
| 14 | + runs-on: ubuntu-latest |
| 15 | + steps: |
| 16 | + - name: Check out code |
| 17 | + uses: actions/checkout@v2 |
| 18 | + - name: Set the expected Go version |
| 19 | + run: | |
| 20 | + GOMOD_VERSION=$(cat go.mod | grep -i "^go " | sed -e "s/go //g") |
| 21 | + echo "GOMOD_VERSION=${GOMOD_VERSION}" >> $GITHUB_ENV |
| 22 | + - name: Set up Go |
| 23 | + uses: actions/setup-go@v2 |
| 24 | + with: |
| 25 | + go-version: "${{ env.GOMOD_VERSION }}" |
| 26 | + - name: generating documentation |
| 27 | + run: cd documentation/gen && go run . |
| 28 | + - name: changes |
| 29 | + run: test -z "$(git diff 2> /dev/null)" || exit "Documentation is not generated, issue \`cd documentation/gen && go run .\` and commit the result" |
| 30 | + - name: untracked files |
| 31 | + run: test -z "$(git ls-files --others --exclude-standard 2> /dev/null)" || exit "Documentation created untracked files, cannot proceed" |
| 32 | + tidy: |
| 33 | + name: go mod tidy |
| 34 | + runs-on: ubuntu-latest |
| 35 | + steps: |
| 36 | + - name: Check out code |
| 37 | + uses: actions/checkout@v2 |
| 38 | + - name: Set up Go |
| 39 | + uses: actions/setup-go@v2 |
| 40 | + with: |
| 41 | + go-version: 1.17 |
| 42 | + - uses: actions/cache@v2 |
| 43 | + with: |
| 44 | + path: | |
| 45 | + ~/.cache/go-build |
| 46 | + ~/go/pkg/mod |
| 47 | + key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }} |
| 48 | + restore-keys: | |
| 49 | + ${{ runner.os }}-go- |
| 50 | + - name: tidy |
| 51 | + run: go mod tidy |
| 52 | + - name: changes |
| 53 | + run: test -z "$(git diff 2> /dev/null)" || exit "Go modules not tidied, issue \`go mod tidy\` and commit the result" |
| 54 | + lint: |
| 55 | + name: golangci-lint |
| 56 | + needs: ["generate", "tidy"] |
| 57 | + runs-on: ubuntu-latest |
| 58 | + steps: |
| 59 | + - name: Check out code into the Go module directory |
| 60 | + uses: actions/checkout@v2 |
| 61 | + - uses: actions/cache@v2 |
| 62 | + with: |
| 63 | + path: | |
| 64 | + ~/.cache/go-build |
| 65 | + ~/go/pkg/mod |
| 66 | + key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }} |
| 67 | + restore-keys: | |
| 68 | + ${{ runner.os }}-go- |
| 69 | + - name: golangci-lint |
| 70 | + uses: docker://ghcr.io/haproxytech/go-linter:1.33 |
| 71 | + with: |
| 72 | + args: --timeout 5m |
| 73 | + build: |
| 74 | + name: build |
| 75 | + runs-on: ubuntu-latest |
| 76 | + needs: ["lint"] |
| 77 | + steps: |
| 78 | + - name: Check out code |
| 79 | + uses: actions/checkout@v2 |
| 80 | + - name: Set up Go 1.17 |
| 81 | + uses: actions/setup-go@v2 |
| 82 | + with: |
| 83 | + go-version: 1.17 |
| 84 | + id: go |
| 85 | + - uses: actions/cache@v2 |
| 86 | + with: |
| 87 | + path: | |
| 88 | + ~/.cache/go-build |
| 89 | + ~/go/pkg/mod |
| 90 | + key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }} |
| 91 | + restore-keys: | |
| 92 | + ${{ runner.os }}-go- |
| 93 | + - name: Get dependencies |
| 94 | + run: | |
| 95 | + go get -v -t -d ./... |
| 96 | + - name: Build |
| 97 | + run: | |
| 98 | + go build -v . |
| 99 | + e2e: |
| 100 | + strategy: |
| 101 | + matrix: |
| 102 | + k8s-version: ['v1.21.1'] |
| 103 | + needs: ["build"] |
| 104 | + runs-on: ubuntu-latest |
| 105 | + steps: |
| 106 | + - uses: actions/checkout@v2 |
| 107 | + - uses: actions/setup-go@v2 |
| 108 | + with: |
| 109 | + go-version: '^1.17' # The Go version to download (if necessary) and use. |
| 110 | + - uses: actions/cache@v2 |
| 111 | + with: |
| 112 | + path: | |
| 113 | + ~/.cache/go-build |
| 114 | + ~/go/pkg/mod |
| 115 | + key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }} |
| 116 | + restore-keys: | |
| 117 | + ${{ runner.os }}-go- |
| 118 | + - uses: engineerd/[email protected] |
| 119 | + with: |
| 120 | + name: dev |
| 121 | + config: deploy/tests/kind-config.yaml |
| 122 | + image: kindest/node:${{ matrix.k8s-version }} |
| 123 | + version: v0.11.1 |
| 124 | + - name: Setup |
| 125 | + run: CI_ENV=github deploy/tests/create.sh |
| 126 | + - name: Run parallel e2e tests |
| 127 | + run: go test ./... -v --tags=e2e_parallel |
| 128 | + - name: Run sequential e2e tests |
| 129 | + run: go test ./... -v -p 1 --tags=e2e_sequential |
0 commit comments