diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 085c9e87..76e5b976 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -1,4 +1,4 @@ -name: go build +name: build and test on: pull_request: branches: @@ -10,14 +10,64 @@ jobs: steps: - name: Check out code uses: actions/checkout@v4 + with: + fetch-depth: 0 - name: Set up Go uses: actions/setup-go@v5 with: go-version-file: 'go.mod' - id: go - - name: Get dependencies - run: | - go get -v -t -d ./... + - name: Verify dependencies + run: go mod verify - name: Build + run: make build + - name: Upload binary + uses: actions/upload-artifact@v4 + with: + name: dataplaneapi + path: build/dataplaneapi + retention-days: 1 + test: + name: Unit tests + runs-on: ubuntu-latest + steps: + - name: Check out code + uses: actions/checkout@v4 + - name: Set up Go + uses: actions/setup-go@v5 + with: + go-version-file: 'go.mod' + - name: Test + run: make test + e2e: + name: HAProxy ${{ matrix.haproxy_version }} (${{ matrix.testpart }}) + needs: build + strategy: + matrix: + haproxy_version: ["3.4"] + testpart: ["1/4", "2/4", "3/4", "4/4"] + runs-on: ubuntu-latest + steps: + - name: Check out code + uses: actions/checkout@v4 + - name: Install Bats + run: | + git clone --depth 1 --branch v1.10.0 https://github.com/bats-core/bats-core.git "$RUNNER_TEMP/bats-core" + sudo "$RUNNER_TEMP/bats-core/install.sh" /usr/local + - name: Download binary + uses: actions/download-artifact@v4 + with: + name: dataplaneapi + path: build + - name: Run E2E tests run: | - go build -v . + chmod +x build/dataplaneapi + bash ./e2e/run.bash + env: + HAPROXY_VERSION: ${{ matrix.haproxy_version }} + TESTPART: ${{ matrix.testpart }} + - name: Upload failure logs + if: failure() + uses: actions/upload-artifact@v4 + with: + name: e2e-logs-${{ strategy.job-index }} + path: e2e/logs/ diff --git a/.github/workflows/check.yml b/.github/workflows/check.yml index 7068f888..f18e8860 100644 --- a/.github/workflows/check.yml +++ b/.github/workflows/check.yml @@ -7,7 +7,11 @@ jobs: check: runs-on: ubuntu-latest steps: + - name: Check out code + uses: actions/checkout@v4 + with: + fetch-depth: 0 - name: commit-policy - uses: docker://ghcr.io/haproxytech/commit-check:5.0.4 + uses: docker://ghcr.io/haproxytech/commit-check:5.8.1 env: API_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/e2e.yml b/.github/workflows/e2e.yml deleted file mode 100644 index 6219b362..00000000 --- a/.github/workflows/e2e.yml +++ /dev/null @@ -1,24 +0,0 @@ -name: e2e -on: - pull_request: - branches: - - master -jobs: - build: - name: HAProxy - strategy: - matrix: - haproxy_version: ["3.2"] - runs-on: ubuntu-latest - steps: - - name: Check out code into the Go module directory - uses: actions/checkout@v4 - - name: Downloading required packages - run: sudo apt-get install bats - - name: Set up Go - uses: actions/setup-go@v5 - with: - go-version-file: 'go.mod' - - run: make e2e - env: - HAPROXY_VERSION: ${{ matrix.haproxy_version }} diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 73a19e3f..5baa8e04 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -4,6 +4,30 @@ on: branches: - master jobs: + diff: + name: Generated code + runs-on: ubuntu-latest + steps: + - name: Check out code + uses: actions/checkout@v4 + - name: Set up Go + uses: actions/setup-go@v5 + with: + go-version-file: 'go.mod' + - name: Install swagger + run: | + SWAGGER_VERSION=$(curl -fsSL https://raw.githubusercontent.com/haproxytech/client-native/master/Makefile | grep '^SWAGGER_VERSION=' | cut -d= -f2) + curl -fsSL "https://github.com/go-swagger/go-swagger/releases/download/${SWAGGER_VERSION}/swagger_linux_amd64" -o "$RUNNER_TEMP/swagger" + chmod +x "$RUNNER_TEMP/swagger" + printf '%s\n' "$RUNNER_TEMP" >> "$GITHUB_PATH" + - name: Generate code + run: | + make generate-native + make specification + - name: Check generated code + run: | + git diff --exit-code + test -z "$(git ls-files --others --exclude-standard)" gofumpt: name: gofumpt runs-on: ubuntu-latest diff --git a/.github/workflows/vuln.yml b/.github/workflows/vuln.yml new file mode 100644 index 00000000..2a4539b6 --- /dev/null +++ b/.github/workflows/vuln.yml @@ -0,0 +1,19 @@ +name: govulncheck +on: + pull_request: + branches: + - master +jobs: + govulncheck: + runs-on: ubuntu-latest + steps: + - name: Check out code + uses: actions/checkout@v4 + - name: Set up Go + uses: actions/setup-go@v5 + with: + go-version-file: 'go.mod' + - name: Install govulncheck + run: go install golang.org/x/vuln/cmd/govulncheck@latest + - name: Check vulnerabilities + run: govulncheck ./...